diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2017-03-14 11:37:14 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2017-03-14 11:37:14 +0200 |
commit | 233255f0e14f364841751755958375fe27380ba6 (patch) | |
tree | 1571f125ad89f729cbf0c3d7c0b09aba8fe0fc20 /build2/target.txx | |
parent | f262632b20628136369889ebc67a65b252b233af (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.txx')
-rw-r--r-- | build2/target.txx | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/build2/target.txx b/build2/target.txx index dd087c0..d854ed2 100644 --- a/build2/target.txx +++ b/build2/target.txx @@ -2,6 +2,8 @@ // copyright : Copyright (c) 2014-2017 Code Synthesis Ltd // license : MIT; see accompanying LICENSE file +#include <butl/filesystem> // dir_iterator + #include <build2/scope> #include <build2/diagnostics> #include <build2/prerequisite> @@ -135,4 +137,48 @@ namespace build2 return false; } + + // dir + // + template <typename K> + const target* dir:: + search_implied (const scope& base, const K& k, tracer& trace) + { + using namespace butl; + + // See if we have any subdirectories. + // + prerequisites_type ps; + + for (const dir_entry& e: dir_iterator (base.src_path ())) + { + if (e.type () == entry_type::directory) + ps.push_back ( + prerequisite (nullopt, + dir::static_type, + dir_path (e.path ().representation ()), + dir_path (), // In the out tree. + string (), + nullopt, + base)); + } + + if (ps.empty ()) + return nullptr; + + l5 ([&]{trace << "implying buildfile for " << k;}); + + // We behave as if this target was explicitly mentioned in the (implied) + // buildfile. Thus not implied. + // + target& t (targets.insert (dir::static_type, + base.out_path (), + dir_path (), + string (), + nullopt, + false, + trace).first); + t.prerequisites (move (ps)); + return &t; + } } |