aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2019-11-07 13:11:22 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2019-11-07 13:11:22 +0200
commit828573b2a230e37ccbf0b0f2f34c4ece2a5ef2a4 (patch)
tree8122c4c6340fb2674b79dc0e1109aa320b3ba29e
parentecd3e83d384cad36c3ae28988d0a95b77f627f4c (diff)
Don't add $install.lib to module library search path if import.build2 is NULL
-rw-r--r--libbuild2/cc/common.cxx27
1 files changed, 21 insertions, 6 deletions
diff --git a/libbuild2/cc/common.cxx b/libbuild2/cc/common.cxx
index 587ae08..d24eb02 100644
--- a/libbuild2/cc/common.cxx
+++ b/libbuild2/cc/common.cxx
@@ -528,6 +528,8 @@ namespace build2
assert (p.scope != nullptr);
+ context& ctx (p.scope->ctx);
+
// @@ This is hairy enough to warrant a separate implementation for
// Windows.
@@ -800,11 +802,25 @@ namespace build2
//
if (build_installed && p.proj && *p.proj == "build2")
{
- // Note that we prepend it to other user directories instead of
- // making it the only one to allow things to be overriden (e.g., if
- // build2 was moved or some such).
+ const scope& rs (*p.scope->root_scope ());
+
+ // Check if import.build2 is set to NULL to disable relying on the
+ // built-in path. We use this in our tests to make sure we are
+ // importing and testing the build system being built and not the
+ // one doing the building.
+ //
+ // Note that for the installed case this value is undefined by
+ // default.
//
- usrd->insert (usrd->begin (), build_install_lib);
+ lookup l (rs[ctx.var_import_build2]);
+ if (!(l.defined () && l->null))
+ {
+ // Note that we prepend it to other user directories instead of
+ // making it the only one to allow things to be overriden (e.g.,
+ // if build2 was moved or some such).
+ //
+ usrd->insert (usrd->begin (), build_install_lib);
+ }
}
}
@@ -840,8 +856,7 @@ namespace build2
// Enter (or find) the lib{} target group.
//
lib* lt;
- insert_library (
- p.scope->ctx, lt, name, *pd, l ? p.tk.ext : nullopt, exist, trace);
+ insert_library (ctx, lt, name, *pd, l ? p.tk.ext : nullopt, exist, trace);
// Result.
//