diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2022-01-18 10:54:23 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2022-01-18 10:54:23 +0200 |
commit | 70e095024ab33404ba0cf20c184a7a9560bca5f0 (patch) | |
tree | ea56d10fb9efbb1361863c7fc59e9ff74cde6f7b /libbuild2/build/script/parser.cxx | |
parent | 1da1ae7733b7ef329b85df16cd15b91709cf4db9 (diff) |
Add dynamic prerequisites to $< unless --adhoc is specified
Also add a few tests for depdb-dyndep.
Diffstat (limited to 'libbuild2/build/script/parser.cxx')
-rw-r--r-- | libbuild2/build/script/parser.cxx | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/libbuild2/build/script/parser.cxx b/libbuild2/build/script/parser.cxx index 6f3c300..dd6fa2d 100644 --- a/libbuild2/build/script/parser.cxx +++ b/libbuild2/build/script/parser.cxx @@ -1604,6 +1604,14 @@ namespace build2 else def_pt = &file::static_type; + // --adhoc + // + if (ops.adhoc ()) + { + if (byprod) + fail (ll) << "depdb dyndep: --adhoc specified with --byproduct"; + } + // Update prerequisite targets. // using dyndep = dyndep_rule; @@ -1858,10 +1866,6 @@ namespace build2 // Enter as a target, update, and add to the list of prerequisite // targets a file. // - // Note that these targets don't end up in $< (which is the right - // thing) because that variable has already been initialized (in the - // environment ctor). - // size_t skip_count (0); auto add = [this, &trace, what, @@ -1959,10 +1963,19 @@ namespace build2 trace, what, a, t, *ft, mt, - false /* fail */, - false /* adhoc */, - 1 /* data */)) + false /* fail */, + ops.adhoc () /* adhoc */)) { + prerequisite_target& pt (pts.back ()); + + if (pt.adhoc) + { + pt.data = reinterpret_cast<uintptr_t> (pt.target); + pt.target = nullptr; + } + else + pt.data = 1; // Already updated. + if (!cache) dd.expect (ft->path ()); // @@ Use fp (or verify match)? @@ -2221,6 +2234,12 @@ namespace build2 // Add the terminating blank line (we are updating depdb). // dd.expect (""); + + // Reload $< and $> to make sure they contain the newly discovered + // prerequisites and targets. + // + if (update) + environment_->set_special_variables (a); } // When add a special variable don't forget to update lexer::word(). |