From 76f1988539c477ad3b906f254654929aec04283c Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 30 Nov 2021 10:15:33 +0200 Subject: Add support for dynamic dependencies as byproduct of script body Specifically, the `depdb dyndep` builtin now has the --byproduct option (which must come first). In this mode only the --file input is supported. For example: obje{hello.o}: cxx{hello} {{ o = $path($>) t = $(o).t depdb dyndep --byproduct --what=header --default-type=h --file $t diag c++ ($<[0]) $cxx.path $cxx.poptions $cc.poptions $cc.coptions $cxx.coptions $cxx.mode -o $o -MD -MF $t -c $path($<[0]) }} Naturally, this mode does not support dynamic auto-generated prerequisites. If present, such prerequisites must be specified statically in the buildfile. Note also that the --default-prereq-type option has been rename to --default-type. --- libbuild2/cc/compile-rule.cxx | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) (limited to 'libbuild2/cc/compile-rule.cxx') diff --git a/libbuild2/cc/compile-rule.cxx b/libbuild2/cc/compile-rule.cxx index db9e6cb..44d1fd5 100644 --- a/libbuild2/cc/compile-rule.cxx +++ b/libbuild2/cc/compile-rule.cxx @@ -2046,9 +2046,10 @@ namespace build2 try { pair er ( - enter_header (a, bs, t, li, - move (f), false /* cache */, false /* norm */, - pfx_map, so_map)); + enter_header ( + a, bs, t, li, + f, false /* cache */, false /* normalized */, + pfx_map, so_map)); ht = er.first; remapped = er.second; @@ -2574,9 +2575,10 @@ namespace build2 if (exists) { pair r ( - enter_header (a, bs, t, li, - move (f), false /* cache */, false /* norm */, - pfx_map, so_map)); + enter_header ( + a, bs, t, li, + f, false /* cache */, false /* normalized */, + pfx_map, so_map)); if (!r.second) // Shouldn't be remapped. ht = r.first; @@ -2601,9 +2603,10 @@ namespace build2 try { pair er ( - enter_header (a, bs, t, li, - move (f), false /* cache */, false /* norm */, - pfx_map, so_map)); + enter_header ( + a, bs, t, li, + f, false /* cache */, false /* normalized */, + pfx_map, so_map)); ht = er.first; remapped = er.second; @@ -2796,7 +2799,7 @@ namespace build2 // pair compile_rule:: enter_header (action a, const scope& bs, file& t, linfo li, - path&& f, bool cache, bool norm, + path& fp, bool cache, bool norm, optional& pfx_map, const srcout_map& so_map) const { @@ -2814,7 +2817,7 @@ namespace build2 return enter_file ( trace, "header", a, bs, t, - move (f), cache, norm, + fp, cache, norm, [this] (const scope& bs, const string& n, const string& e) { return map_extension (bs, n, e, x_inc); @@ -3566,9 +3569,10 @@ namespace build2 dr << endf; }; - if (const file* ht = enter_header (a, bs, t, li, - move (hp), cache, false /* norm */, - pfx_map, so_map).first) + if (const file* ht = enter_header ( + a, bs, t, li, + hp, cache, cache /* normalized */, + pfx_map, so_map).first) { // If we are reading the cache, then it is possible the file has // since been removed (think of a header in /usr/local/include that @@ -3576,12 +3580,14 @@ namespace build2 // /usr/include). This will lead to the match failure which we // translate to a restart. // + // @@ Won't this fail in enter_header() rather? + // if (optional u = inject_header (a, t, *ht, mt, false /*fail*/)) { // Verify/add it to the dependency database. // if (!cache) - dd.expect (ht->path ()); + dd.expect (ht->path ()); // @@ Use hp (or verify match)? skip_count++; return *u; @@ -3612,7 +3618,7 @@ namespace build2 const file* ht ( enter_header (a, bs, t, li, - move (hp), true /* cache */, true /* norm */, + hp, true /* cache */, false /* normalized */, pfx_map, so_map).first); if (ht == nullptr) -- cgit v1.1