diff options
Diffstat (limited to 'build2/cxx')
-rw-r--r-- | build2/cxx/compile.cxx | 20 | ||||
-rw-r--r-- | build2/cxx/link.cxx | 28 |
2 files changed, 33 insertions, 15 deletions
diff --git a/build2/cxx/compile.cxx b/build2/cxx/compile.cxx index 914cd10..b7577d4 100644 --- a/build2/cxx/compile.cxx +++ b/build2/cxx/compile.cxx @@ -679,9 +679,19 @@ namespace build2 // purposes: it is only important for us to accurately determine // target types for headers that could be auto-generated. // - scope& b (scopes.find (d)); - if (b.root_scope () != nullptr) - tt = map_extension (b, n, *e); + // While at it also try to determine if this target is from the src + // or out tree of said project. + // + dir_path out; + + scope& bs (scopes.find (d)); + if (bs.root_scope () != nullptr) + { + tt = map_extension (bs, n, *e); + + if (bs.out_path () != bs.src_path () && d.sub (bs.src_path ())) + out = out_src (d, bs); + } // If it is outside any project, or the project doesn't have // such an extension, assume it is a plain old C header. @@ -691,8 +701,10 @@ namespace build2 // Find or insert target. // + // @@ OPT: move d, out, n + // path_target& pt ( - static_cast<path_target&> (search (*tt, d, n, e, &ds))); + static_cast<path_target&> (search (*tt, d, out, n, e, &ds))); // Assign path. // diff --git a/build2/cxx/link.cxx b/build2/cxx/link.cxx index e4154ab..555c094 100644 --- a/build2/cxx/link.cxx +++ b/build2/cxx/link.cxx @@ -304,7 +304,10 @@ namespace build2 // Enter the target. Note that because the search paths are // normalized, the result is automatically normalized as well. // - a = &targets.insert<liba> (d, p.name, ae, trace); + // Note that this target is outside any project which we treat + // as out trees. + // + a = &targets.insert<liba> (d, dir_path (), p.name, ae, trace); if (a->path ().empty ()) a->path (move (f)); @@ -322,7 +325,7 @@ namespace build2 if ((mt = file_mtime (f)) != timestamp_nonexistent) { - s = &targets.insert<libso> (d, p.name, se, trace); + s = &targets.insert<libso> (d, dir_path (), p.name, se, trace); if (s->path ().empty ()) s->path (move (f)); @@ -345,7 +348,7 @@ namespace build2 { // Enter the target group. // - lib& l (targets.insert<lib> (*pd, p.name, p.ext, trace)); + lib& l (targets.insert<lib> (*pd, dir_path (), p.name, p.ext, trace)); // It should automatically link-up to the members we have found. // @@ -597,12 +600,12 @@ namespace build2 ? obj::static_type : (so ? objso::static_type : obja::static_type)); - // Come up with the obj*{} target. The c(xx){} prerequisite - // directory can be relative (to the scope) or absolute. If it is - // relative, then use it as is. If it is absolute, then translate - // it to the corresponding directory under out_root. While the - // c(xx){} directory is most likely under src_root, it is also - // possible it is under out_root (e.g., generated source). + // Come up with the obj*{} target. The c(xx){} prerequisite directory + // can be relative (to the scope) or absolute. If it is relative, then + // use it as is. If absolute, then translate it to the corresponding + // directory under out_root. While the c(xx){} directory is most + // likely under src_root, it is also possible it is under out_root + // (e.g., generated source). // dir_path d; { @@ -621,7 +624,10 @@ namespace build2 } } - target& ot (search (o_type, d, *cp.tk.name, nullptr, cp.scope)); + // obj*{} is always in the out tree. + // + target& ot ( + search (o_type, d, dir_path (), *cp.tk.name, nullptr, cp.scope)); // If we are cleaning, check that this target is in the same or // a subdirectory of our project root. @@ -646,7 +652,7 @@ namespace build2 if (pt == nullptr) pt = &search (so ? objso::static_type : obja::static_type, - o.dir, o.name, o.ext, nullptr); + o.dir, o.out, o.name, o.ext, nullptr); } else pt = &ot; |