diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2018-11-14 13:08:29 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2018-11-14 13:08:29 +0200 |
commit | b611e797ad9db9794f4d151f454fa731d12b0bd3 (patch) | |
tree | b202ef1d894a313fb791d5f0af254f67d2ae84b7 /build2/target.cxx | |
parent | 6c3d3f62f8560cbb8d1e983a8dd8cc98266bfe37 (diff) |
Fallback to loading outer buildfile if there isn't one in src_base
This covers the case where the target is defined in the outer buildfile which
is common with non-intrusive project conversions where everything is built
from a single root buildfile.
Diffstat (limited to 'build2/target.cxx')
-rw-r--r-- | build2/target.cxx | 69 |
1 files changed, 68 insertions, 1 deletions
diff --git a/build2/target.cxx b/build2/target.cxx index 20b9fd6..e70a386 100644 --- a/build2/target.cxx +++ b/build2/target.cxx @@ -791,6 +791,73 @@ namespace build2 false }; + // dir + // + bool dir:: + check_implied (const dir_path& d) + { + try + { + for (const dir_entry& e: dir_iterator (d, true /* ignore_dangling */)) + { + switch (e.type ()) + { + case entry_type::directory: + { + if (check_implied (d / path_cast<dir_path> (e.path ()))) + return true; + + break; + } + case entry_type::regular: + { + if (e.path () == buildfile_file) + return true; + + break; + } + default: + break; + } + } + } + catch (const system_error& e) + { + fail << "unable to iterate over " << d << ": " << e << endf; + } + + return false; + } + + prerequisites dir:: + collect_implied (const scope& bs) + { + prerequisites_type r; + const dir_path& d (bs.src_path ()); + + try + { + for (const dir_entry& e: dir_iterator (d, true /* ignore_dangling */)) + { + if (e.type () == entry_type::directory) + r.push_back ( + prerequisite (nullopt, + dir::static_type, + dir_path (e.path ().representation ()), // Relative. + dir_path (), // In the out tree. + string (), + nullopt, + bs)); + } + } + catch (const system_error& e) + { + fail << "unable to iterate over " << d << ": " << e; + } + + return r; + } + static const target* dir_search (const target&, const prerequisite_key& pk) { @@ -869,7 +936,7 @@ namespace build2 const dir_path& src_base (base.src_path ()); - path bf (src_base / "buildfile"); + path bf (src_base / buildfile_file); if (exists (bf)) { |