From fc18a6dc1fcb02b505f07914e484cebbaf268698 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 19 Apr 2016 09:24:38 +0200 Subject: Redesign src/out scoping We no longer enter paths from the src tree into scope map. Instead, targets from the src tree now include their out tree directory (in essence their "configuration"). This is then used to find a target's scope. See the comment in class target for details. The result of this change is that we can now again build multiple configurations (out trees) for same project at once. --- build2/dist/operation.cxx | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) (limited to 'build2/dist') diff --git a/build2/dist/operation.cxx b/build2/dist/operation.cxx index 9ae5773..aea957a 100644 --- a/build2/dist/operation.cxx +++ b/build2/dist/operation.cxx @@ -139,21 +139,30 @@ namespace build2 // ignored on the next step if the user explicitly marked them // nodist. // - auto add_adhoc = [&src_root, &trace] (const dir_path& d, const char* f) + auto add_adhoc = [&trace] (scope& rs, const char* f) + { + path p (rs.src_path () / path (f)); + if (file_exists (p)) { - path p (d / path (f)); - if (file_exists (p)) - { - const char* e (p.extension ()); - targets.insert ( - p.directory (), - p.leaf ().base ().string (), - &extension_pool.find (e == nullptr ? "" : e), // Specified. - trace); - } - }; + dir_path d (p.directory ()); - add_adhoc (src_root, "build/export.build"); + // Figure out if we need out. + // + dir_path out (rs.src_path () != rs.out_path () + ? out_src (d, rs) + : dir_path ()); + + const char* e (p.extension ()); + targets.insert ( + move (d), + move (out), + p.leaf ().base ().string (), + &extension_pool.find (e == nullptr ? "" : e), // Specified. + trace); + } + }; + + add_adhoc (*rs, "build/export.build"); // The same for subprojects that have been loaded. // @@ -168,12 +177,10 @@ namespace build2 if (nrs.out_path () != out_nroot) // This subproject not loaded. continue; - const dir_path& src_nroot (nrs.src_path ()); - - if (!src_nroot.sub (src_root)) // Not a strong amalgamation. + if (!nrs.src_path ().sub (src_root)) // Not a strong amalgamation. continue; - add_adhoc (src_nroot, "build/export.build"); + add_adhoc (nrs, "build/export.build"); } } -- cgit v1.1