aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/install
diff options
context:
space:
mode:
Diffstat (limited to 'libbuild2/install')
-rw-r--r--libbuild2/install/init.cxx28
-rw-r--r--libbuild2/install/operation.cxx3
-rw-r--r--libbuild2/install/rule.cxx45
3 files changed, 41 insertions, 35 deletions
diff --git a/libbuild2/install/init.cxx b/libbuild2/install/init.cxx
index ef9de05..35c2d13 100644
--- a/libbuild2/install/init.cxx
+++ b/libbuild2/install/init.cxx
@@ -250,6 +250,21 @@ namespace build2
context& ctx (rs.ctx);
+ // Enter module variables (note that init() below enters some more).
+ //
+ auto& vp (rs.var_pool ());
+
+ // The install variable is a path, not dir_path, since it can be used
+ // to both specify the target directory (to install with the same file
+ // name) or target file (to install with a different name). And the
+ // way we distinguish between the two is via the presence/absence of
+ // the trailing directory separator.
+ //
+ // Plus it can have the special true/false values when acting as a
+ // operation variable.
+ //
+ auto& ovar (vp.insert<path> ("install", variable_visibility::target));
+
// Register the install function family if this is the first instance of
// the install modules.
//
@@ -258,9 +273,9 @@ namespace build2
// Register our operations.
//
- rs.insert_operation (install_id, op_install);
- rs.insert_operation (uninstall_id, op_uninstall);
- rs.insert_operation (update_for_install_id, op_update_for_install);
+ rs.insert_operation (install_id, op_install, &ovar);
+ rs.insert_operation (uninstall_id, op_uninstall, &ovar);
+ rs.insert_operation (update_for_install_id, op_update_for_install, &ovar);
}
static const path cmd ("install");
@@ -317,13 +332,6 @@ namespace build2
// Note that the set_dir() calls below enter some more.
//
{
- // The install variable is a path, not dir_path, since it can be used
- // to both specify the target directory (to install with the same file
- // name) or target file (to install with a different name). And the
- // way we distinguish between the two is via the presence/absence of
- // the trailing directory separator.
- //
- vp.insert<path> ("install", variable_visibility::target);
vp.insert<bool> ("for_install", variable_visibility::prereq);
vp.insert<string> ("install.mode");
vp.insert<bool> ("install.subdirs");
diff --git a/libbuild2/install/operation.cxx b/libbuild2/install/operation.cxx
index 8c59ac1..52e8c94 100644
--- a/libbuild2/install/operation.cxx
+++ b/libbuild2/install/operation.cxx
@@ -37,7 +37,6 @@ namespace build2
0,
"install",
"install",
- "install",
"installing",
"installed",
"has nothing to install", // We cannot "be installed".
@@ -62,7 +61,6 @@ namespace build2
uninstall_id,
0,
"uninstall",
- "install",
"uninstall",
"uninstalling",
"uninstalled",
@@ -81,7 +79,6 @@ namespace build2
update_id, // Note: not update_for_install_id.
install_id,
op_update.name,
- op_update.var_name,
op_update.name_do,
op_update.name_doing,
op_update.name_did,
diff --git a/libbuild2/install/rule.cxx b/libbuild2/install/rule.cxx
index 6458a54..756d5a8 100644
--- a/libbuild2/install/rule.cxx
+++ b/libbuild2/install/rule.cxx
@@ -40,12 +40,17 @@ namespace build2
// Note that the below rules are called for both install and
// update-for-install.
//
+ // @@ TODO: we clearly need a module class.
+ //
static inline const variable&
- var_install (context& ctx)
+ var_install (const scope& rs)
{
- return ctx.current_outer_ovar != nullptr
- ? *ctx.current_outer_ovar
- : *ctx.current_inner_ovar;
+ context& ctx (rs.ctx);
+
+ return *rs.root_extra->operations[
+ (ctx.current_outer_oif != nullptr
+ ? ctx.current_outer_oif
+ : ctx.current_inner_oif)->id].ovar;
}
// alias_rule
@@ -85,8 +90,6 @@ namespace build2
{
tracer trace ("install::alias_rule::apply");
- context& ctx (t.ctx);
-
// Pass-through to our installable prerequisites.
//
// @@ Shouldn't we do match in parallel (here and below)?
@@ -138,7 +141,7 @@ namespace build2
//
// Note: not the same as lookup_install() above.
//
- auto l ((*pt)[var_install (ctx)]);
+ auto l ((*pt)[var_install (*p.scope.root_scope ())]);
if (l && cast<path> (l).string () == "false")
{
l5 ([&]{trace << "ignoring " << *pt << " (not installable)";});
@@ -223,8 +226,10 @@ namespace build2
//
if (p.is_a<exe> ())
{
+ const scope& rs (*p.scope.root_scope ());
+
if (p.vars.empty () ||
- cast_empty<path> (p.vars[var_install (t.ctx)]).string () != "true")
+ cast_empty<path> (p.vars[var_install (rs)]).string () != "true")
return nullptr;
}
@@ -237,8 +242,6 @@ namespace build2
{
tracer trace ("install::group_rule::apply");
- context& ctx (t.ctx);
-
// Resolve group members.
//
// Remember that we are called twice: first during update for install
@@ -253,8 +256,10 @@ namespace build2
? resolve_members (a, t)
: t.group_members (a));
- if (gv.members != nullptr)
+ if (gv.members != nullptr && gv.count != 0)
{
+ const scope& rs (t.root_scope ());
+
auto& pts (t.prerequisite_targets[a]);
for (size_t i (0); i != gv.count; ++i)
{
@@ -277,7 +282,7 @@ namespace build2
//
// Note: not the same as lookup_install() above.
//
- auto l ((*mt)[var_install (ctx)]);
+ auto l ((*mt)[var_install (rs)]);
if (l && cast<path> (l).string () == "false")
{
l5 ([&]{trace << "ignoring " << *mt << " (not installable)";});
@@ -324,13 +329,15 @@ namespace build2
//
if (p.is_a<exe> ())
{
+ const scope& rs (*p.scope.root_scope ());
+
// Note that while include() checks for install=false, here we need to
// check for explicit install=true. We could have re-used the lookup
// performed by include(), but then we would have had to drag it
// through and also diagnose any invalid values.
//
if (p.vars.empty () ||
- cast_empty<path> (p.vars[var_install (t.ctx)]).string () != "true")
+ cast_empty<path> (p.vars[var_install (rs)]).string () != "true")
return nullptr;
}
@@ -350,8 +357,6 @@ namespace build2
{
tracer trace ("install::file_rule::apply");
- context& ctx (t.ctx);
-
// Note that we are called both as the outer part during the update-for-
// un/install pre-operation and as the inner part during the un/install
// operation itself.
@@ -419,7 +424,7 @@ namespace build2
//
// Note: not the same as lookup_install() above.
//
- auto l ((*pt)[var_install (ctx)]);
+ auto l ((*pt)[var_install (*p.scope.root_scope ())]);
if (l && cast<path> (l).string () == "false")
{
l5 ([&]{trace << "ignoring " << *pt << " (not installable)";});
@@ -974,8 +979,6 @@ namespace build2
target_state file_rule::
perform_install (action a, const target& xt) const
{
- context& ctx (xt.ctx);
-
const file& t (xt.as<file> ());
const path& tp (t.path ());
@@ -1073,7 +1076,7 @@ namespace build2
//
if (!tp.empty ())
{
- install_target (t, cast<path> (t[var_install (ctx)]), 1);
+ install_target (t, cast<path> (t[var_install (rs)]), 1);
r |= target_state::changed;
}
@@ -1277,8 +1280,6 @@ namespace build2
target_state file_rule::
perform_uninstall (action a, const target& xt) const
{
- context& ctx (xt.ctx);
-
const file& t (xt.as<file> ());
const path& tp (t.path ());
@@ -1342,7 +1343,7 @@ namespace build2
target_state r (target_state::unchanged);
if (!tp.empty ())
- r |= uninstall_target (t, cast<path> (t[var_install (ctx)]), 1);
+ r |= uninstall_target (t, cast<path> (t[var_install (rs)]), 1);
// Then installable ad hoc group members, if any. To be anally precise,
// we would have to do it in reverse, but that's not easy (it's a