aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2018-11-02 12:44:17 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2018-11-02 12:44:17 +0200
commite78c6c8dd0d4fb66b888c962d50da33c6704c395 (patch)
tree6ec460e830ec463c91f2b996745241da7b292d26
parent009e3bdd4743fb6bb74334ec5567f43830df1722 (diff)
Use rule-specific variables for backlink value
-rw-r--r--build2/algorithm.cxx25
-rw-r--r--build2/cc/link-rule.cxx8
-rw-r--r--build2/context.hxx2
3 files changed, 22 insertions, 13 deletions
diff --git a/build2/algorithm.cxx b/build2/algorithm.cxx
index b4f2843..2eb5dd8 100644
--- a/build2/algorithm.cxx
+++ b/build2/algorithm.cxx
@@ -1277,7 +1277,7 @@ namespace build2
if (!cast_false<bool> (rs->vars[var_forwarded]))
return nullopt;
- lookup l (t[var_backlink]);
+ lookup l (t.state[a][var_backlink]);
// If not found, check for some defaults in the global scope (this does
// not happen automatically since target type/pattern-specific lookup
@@ -1290,7 +1290,7 @@ namespace build2
}
static backlinks
- backlink_collect (target& t, backlink_mode m)
+ backlink_collect (action a, target& t, backlink_mode m)
{
using mode = backlink_mode;
@@ -1328,7 +1328,14 @@ namespace build2
// inherit the one from the group (so if the user asked to copy .exe,
// we will also copy .pdb).
//
- lookup l (mt->vars[var_backlink]); // Note: no group or tt/patter-spec.
+ // Note that we want to avoid group or tt/patter-spec lookup. And
+ // since this is an ad hoc member (which means it was added by the
+ // rule), we assume that the value, if any, will be set as a rule-
+ // specific variable (since setting it as a target-specific wouldn't
+ // be MT-safe).
+ //
+ lookup l (mt->state[a].vars[var_backlink]);
+
optional<mode> bm (l ? backlink_test (*mt, l) : m);
if (bm)
@@ -1340,9 +1347,9 @@ namespace build2
}
static inline backlinks
- backlink_update_pre (target& t, backlink_mode m)
+ backlink_update_pre (action a, target& t, backlink_mode m)
{
- return backlink_collect (t, m);
+ return backlink_collect (a, t, m);
}
static void
@@ -1373,9 +1380,9 @@ namespace build2
}
static void
- backlink_clean_pre (target& t, backlink_mode m)
+ backlink_clean_pre (action a, target& t, backlink_mode m)
{
- backlinks bls (backlink_collect (t, m));
+ backlinks bls (backlink_collect (a, t, m));
for (auto b (bls.begin ()), i (b); i != bls.end (); ++i)
{
@@ -1410,9 +1417,9 @@ namespace build2
if (blm)
{
if (a == perform_update_id)
- bls = backlink_update_pre (t, *blm);
+ bls = backlink_update_pre (a, t, *blm);
else
- backlink_clean_pre (t, *blm);
+ backlink_clean_pre (a, t, *blm);
}
ts = execute_recipe (a, t, s.recipe);
diff --git a/build2/cc/link-rule.cxx b/build2/cc/link-rule.cxx
index ba6a22d..a9ee0e9 100644
--- a/build2/cc/link-rule.cxx
+++ b/build2/cc/link-rule.cxx
@@ -799,14 +799,14 @@ namespace build2
// The problem is the Windows DLL assembly "logic" refuses to
// recognize a junction as a valid assembly for some reason. So we
// are going to resort to copy-link (i.e., a real directory with a
- // bunch on links).
+ // bunch of links).
//
// Interestingly, the directory symlink works just fine under
- // Wine. So we only resort to copy-link'ing if we are running
- // on Windows.
+ // Wine. So we only resort to copy-link'ing if we are running on
+ // Windows.
//
#ifdef _WIN32
- dir.target->assign (var_backlink) = "copy";
+ dir.target->state[a].assign (var_backlink) = "copy";
#endif
match_recipe (dir, group_recipe); // Set recipe and unlock.
}
diff --git a/build2/context.hxx b/build2/context.hxx
index cf7eee6..0675e6c 100644
--- a/build2/context.hxx
+++ b/build2/context.hxx
@@ -287,6 +287,8 @@ namespace build2
// copy - make a copy.
// overwrite - copy over but don't remove on clean (committed gen code).
//
+ // Note that it can be set by a matching rule as a rule-specific variable.
+ //
extern const variable* var_backlink; // [string] target visibility
// Prerequisite inclusion/exclusion. Valid values are: