aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/cc/compile-rule.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2021-11-30 10:15:33 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2021-11-30 10:42:02 +0200
commit76f1988539c477ad3b906f254654929aec04283c (patch)
tree5d824b8a3db4d95c79ddf6903f530ae578daffaf /libbuild2/cc/compile-rule.cxx
parent445c89468c7d361fe891aa09f2c28e943f6fe7c5 (diff)
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.
Diffstat (limited to 'libbuild2/cc/compile-rule.cxx')
-rw-r--r--libbuild2/cc/compile-rule.cxx38
1 files changed, 22 insertions, 16 deletions
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<const file*, bool> 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<const file*, bool> 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<const file*, bool> 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<const file*, bool> 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<prefix_map>& 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<bool> 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)