aboutsummaryrefslogtreecommitdiff
path: root/build2/target.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-03-14 11:37:14 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-03-14 11:37:14 +0200
commit233255f0e14f364841751755958375fe27380ba6 (patch)
tree1571f125ad89f729cbf0c3d7c0b09aba8fe0fc20 /build2/target.cxx
parentf262632b20628136369889ebc67a65b252b233af (diff)
Implement implied buildfile support
In essence, if the buildfile is: ./: */ Then it can be omitted entirely (provided there is at least one subdirectory).
Diffstat (limited to 'build2/target.cxx')
-rw-r--r--build2/target.cxx22
1 files changed, 16 insertions, 6 deletions
diff --git a/build2/target.cxx b/build2/target.cxx
index 676dc6b..668db92 100644
--- a/build2/target.cxx
+++ b/build2/target.cxx
@@ -14,6 +14,7 @@
#include <build2/diagnostics>
using namespace std;
+using namespace butl;
namespace build2
{
@@ -732,7 +733,7 @@ namespace build2
const target* t (search_existing_target (pk));
if (t == nullptr || t->implied)
- fail << "no explicit target for prerequisite " << pk;
+ fail << "no explicit target for " << pk;
return t;
}
@@ -762,7 +763,10 @@ namespace build2
return t;
// If not found (or is implied), then try to load the corresponding
- // buildfile which would normally define this target.
+ // buildfile (which would normally define this target). Failed that, see
+ // if we can assume an implied buildfile which would be equivalent to:
+ //
+ // ./: */
//
const dir_path& d (*pk.tk.dir);
@@ -809,18 +813,25 @@ namespace build2
scope& base (sp.first);
scope& root (*sp.second);
- path bf (base.src_path () / "buildfile");
+ const dir_path& src_base (base.src_path ());
+
+ path bf (src_base / "buildfile");
if (exists (bf))
{
l5 ([&]{trace << "loading buildfile " << bf << " for " << pk;});
retest = source_once (root, base, bf, root);
}
+ else if (exists (src_base))
+ {
+ t = dir::search_implied (base, pk, trace);
+ retest = (t != nullptr);
+ }
}
}
assert (phase == run_phase::match);
- // If we loaded the buildfile, examine the target again.
+ // If we loaded/implied the buildfile, examine the target again.
//
if (retest)
{
@@ -832,8 +843,7 @@ namespace build2
}
}
- fail << "no explicit target for prerequisite " << pk <<
- info << "did you forget to include the corresponding buildfile?" << endf;
+ fail << "no explicit target for " << pk << endf;
}
static bool