aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2019-11-05 13:16:21 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2019-11-05 13:16:21 +0200
commit55ddc71fd801e06115ad6e33098b0eed2517daab (patch)
treec68892733b899e39c2bdc49b0ffa73282c1644d4
parent4fe1c3c083acecf7eabe46b67cb540e8390f3122 (diff)
Add support for automatic importing of libbuild2 of installed case
-rw-r--r--libbuild2/buildfile10
-rw-r--r--libbuild2/cc/common.cxx17
-rw-r--r--libbuild2/file.cxx3
-rw-r--r--libbuild2/utility-installed.cxx4
-rw-r--r--libbuild2/utility-uninstalled.cxx1
-rw-r--r--libbuild2/utility.hxx4
6 files changed, 37 insertions, 2 deletions
diff --git a/libbuild2/buildfile b/libbuild2/buildfile
index 325d54a..545ccba 100644
--- a/libbuild2/buildfile
+++ b/libbuild2/buildfile
@@ -117,9 +117,19 @@ cross = ($cxx.target.cpu != $build.host.cpu || \
$cxx.target.system != $build.host.system)
if! $cross
+{
{obja objs}{context}: cxx.poptions += \
-DBUILD2_IMPORT_PATH=\"$regex.replace($out_root, '\\', '\\\\')\"
+ # While this object file should only be linked when we are installing, it
+ # will be compiled even in the uninstalled case.
+ #
+ if ($install.root != [null])
+ {obja objs}{utility-installed}: cxx.poptions += \
+ -DBUILD2_INSTALL_LIB=\"$regex.replace(\
+ $install.resolve($install.lib), '\\', '\\\\')\"
+}
+
if ($cxx.target.class != 'windows')
{
libul{build2}: cxx.libs += -lpthread
diff --git a/libbuild2/cc/common.cxx b/libbuild2/cc/common.cxx
index f14f973..587ae08 100644
--- a/libbuild2/cc/common.cxx
+++ b/libbuild2/cc/common.cxx
@@ -786,13 +786,28 @@ namespace build2
return a != nullptr || s != nullptr;
};
- // First try user directories (i.e., -L).
+ // First try user directories (i.e., -L or /LIBPATH).
//
bool sys (false);
if (!usrd)
+ {
usrd = extract_library_dirs (*p.scope);
+ // Handle automatic importing of installed build2 libraries. This is a
+ // mirror side of the uninstalled case that is handled via the special
+ // import.build2 value in import_search().
+ //
+ 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).
+ //
+ usrd->insert (usrd->begin (), build_install_lib);
+ }
+ }
+
const dir_path* pd (nullptr);
for (const dir_path& d: *usrd)
{
diff --git a/libbuild2/file.cxx b/libbuild2/file.cxx
index b55d576..974dc2b 100644
--- a/libbuild2/file.cxx
+++ b/libbuild2/file.cxx
@@ -1435,6 +1435,9 @@ namespace build2
// import.build2
//
+ // Note that the installed case is taken care of by special code in the
+ // cc module's search_library().
+ //
if (proj == "build2")
{
// Note that this variable can be set to NULL to disable relying on
diff --git a/libbuild2/utility-installed.cxx b/libbuild2/utility-installed.cxx
index c8f08b6..29c822b 100644
--- a/libbuild2/utility-installed.cxx
+++ b/libbuild2/utility-installed.cxx
@@ -11,6 +11,10 @@
namespace build2
{
const bool build_installed = true;
+
+#ifdef BUILD2_INSTALL_LIB
+ const dir_path build_install_lib (BUILD2_INSTALL_LIB);
+#endif
}
#endif
diff --git a/libbuild2/utility-uninstalled.cxx b/libbuild2/utility-uninstalled.cxx
index 0006e1a..dc56244 100644
--- a/libbuild2/utility-uninstalled.cxx
+++ b/libbuild2/utility-uninstalled.cxx
@@ -7,4 +7,5 @@
namespace build2
{
const bool build_installed = false;
+ const dir_path build_install_lib; // Empty.
}
diff --git a/libbuild2/utility.hxx b/libbuild2/utility.hxx
index 415dc8b..8cd33cf 100644
--- a/libbuild2/utility.hxx
+++ b/libbuild2/utility.hxx
@@ -160,9 +160,11 @@ namespace build2
LIBBUILD2_SYMEXPORT extern const standard_version build_version;
LIBBUILD2_SYMEXPORT extern const string build_version_interface;
- // Whether running installed build.
+ // Whether running installed build and, if so, the library installation
+ // directory (empty otherwise).
//
LIBBUILD2_SYMEXPORT extern const bool build_installed;
+ LIBBUILD2_SYMEXPORT extern const dir_path build_install_lib; // $install.lib
// --[no-]mtime-check
//