aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/build/script/script.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2020-05-26 13:10:37 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2020-05-27 08:40:59 +0200
commit57e2aaa28e19da1cd4e51982f46ef2630739ff8a (patch)
tree138a169b29aad630150906ffb4a8f30a5f9bdf5a /libbuild2/build/script/script.cxx
parent29c59165396eb842d92367fca74c4e459ea25900 (diff)
Wrap up $<, $> variables and related ($target.path(), hashing, cleanup)
Diffstat (limited to 'libbuild2/build/script/script.cxx')
-rw-r--r--libbuild2/build/script/script.cxx42
1 files changed, 29 insertions, 13 deletions
diff --git a/libbuild2/build/script/script.cxx b/libbuild2/build/script/script.cxx
index b43203c..c258c4c 100644
--- a/libbuild2/build/script/script.cxx
+++ b/libbuild2/build/script/script.cxx
@@ -20,30 +20,46 @@ namespace build2
static const string wd_name ("current directory");
environment::
- environment (const target& pt)
+ environment (action a, const target_type& t)
: build2::script::environment (
- pt.ctx,
- cast<target_triplet> (pt.ctx.global_scope["build.host"]),
+ t.ctx,
+ cast<target_triplet> (t.ctx.global_scope["build.host"]),
work, wd_name,
temp_dir.path, false /* temp_dir_keep */,
redirect (redirect_type::none),
redirect (redirect_type::merge, 2),
redirect (redirect_type::pass)),
- primary_target (pt),
+ target (t),
vars (context, false /* global */)
{
- // Set the $> variable.
+ // Set special variables.
//
{
- //@@ TODO
+ // $>
//
- value& v (assign (var_pool.insert<string> (">")));
+ names ns;
+ for (const target_type* m (&t); m != nullptr; m = m->adhoc_member)
+ m->as_name (ns);
- if (auto* t = pt.is_a<path_target> ())
- v = t->path ().string ();
- else
- //fail << "target " << pt << " is not path-based";
- v = pt.name; //@@ TMP
+ assign (var_pool.insert (">")) = move (ns);
+ }
+
+ {
+ // $<
+ //
+ // Note that at this stage (after execute_prerequisites()) ad hoc
+ // prerequisites are no longer in prerequisite_targets which means
+ // they won't end up in $< either. While at first thought ad hoc
+ // prerequisites in ad hoc recipes don't seem to make much sense,
+ // they could be handy to exclude certain preresquisites from $<
+ // while still treating them as such.
+ //
+ names ns;
+ for (const target_type* pt: t.prerequisite_targets[a])
+ if (pt != nullptr)
+ pt->as_name (ns);
+
+ assign (var_pool.insert ("<")) = move (ns);
}
}
@@ -109,7 +125,7 @@ namespace build2
if (pvar == nullptr)
return lookup_type ();
- return primary_target[*pvar];
+ return target[*pvar];
}
value& environment::