diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2019-08-26 17:24:48 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2019-08-26 18:04:22 +0200 |
commit | 4a23b4cdf3102a8fef8ac6ebd8a884cd613c28ee (patch) | |
tree | 9fdd028cddde76ea4037c55fd7430950a0d05dd5 /libbuild2 | |
parent | 4177d70e63893d0a2c76beb9166ebbf79c4697a0 (diff) |
Implement auto-import of development build2 build
Diffstat (limited to 'libbuild2')
-rw-r--r-- | libbuild2/buildfile | 20 | ||||
-rw-r--r-- | libbuild2/context.cxx | 10 | ||||
-rw-r--r-- | libbuild2/context.hxx | 3 | ||||
-rw-r--r-- | libbuild2/file.cxx | 33 | ||||
-rw-r--r-- | libbuild2/utility-installed.cxx | 24 | ||||
-rw-r--r-- | libbuild2/utility.cxx | 2 | ||||
-rw-r--r-- | libbuild2/utility.hxx | 6 |
7 files changed, 88 insertions, 10 deletions
diff --git a/libbuild2/buildfile b/libbuild2/buildfile index 7d91e08..deda991 100644 --- a/libbuild2/buildfile +++ b/libbuild2/buildfile @@ -9,8 +9,14 @@ import int_libs = libbutl%lib{butl} -lib{build2}: libul{build2}: {hxx ixx txx cxx}{* -config -version -*.test...} \ - {hxx}{config version} +lib{build2}: libul{build2}: \ + {hxx ixx txx cxx}{* -utility-installed -config -version -*.test...} \ + {hxx}{config version} + +# Note that this won't work on libul{} since it's never installed. +# +lib{build2}: cxx{utility-installed}: for_install = true +liba{build2}: bin.whole = true # See utility-installed.cxx. # These are "core modules" that come bundled with libbuild2 (see also unit # tests loop below). Note that the build system core can still function @@ -66,9 +72,15 @@ for t: cxx{ *.test...} \ obja{*}: cxx.poptions += -DLIBBUILD2_STATIC_BUILD objs{*}: cxx.poptions += -DLIBBUILD2_SHARED_BUILD -# Pass our compiler target to be used as libbuild2 host. +# Pass our compiler target to be used as build2 host and our out_root to +# be used as the build system import path. # -obj{context}: cxx.poptions += -DBUILD2_HOST_TRIPLET=\"$cxx.target\" +obj{context}: +{ + cxx.poptions += "-DBUILD2_HOST_TRIPLET=\"$cxx.target\"" + cxx.poptions += "-DBUILD2_IMPORT_PATH=\"$out_root\"" +} + obja{context}: cxx.poptions += -DLIBBUILD2_STATIC_BUILD objs{context}: cxx.poptions += -DLIBBUILD2_SHARED_BUILD diff --git a/libbuild2/context.cxx b/libbuild2/context.cxx index e35f308..a715c59 100644 --- a/libbuild2/context.cxx +++ b/libbuild2/context.cxx @@ -124,6 +124,16 @@ namespace build2 path (argv0.recall_string ()), path (argv0.effect)); + // Build system import path for modules. We only set it for the + // development build. + // + var_import_build2 = &vp.insert<abs_dir_path> ("import.build2"); + +#ifndef BUILD2_BOOTSTRAP + if (!build_installed) + gs.assign (var_import_build2) = abs_dir_path (BUILD2_IMPORT_PATH); +#endif + // Build system verbosity level. // gs.assign<uint64_t> ("build.verbosity") = verb; diff --git a/libbuild2/context.hxx b/libbuild2/context.hxx index 338b8a1..57ae65d 100644 --- a/libbuild2/context.hxx +++ b/libbuild2/context.hxx @@ -315,8 +315,9 @@ namespace build2 // const variable* var_project_summary; - // import.target + // import.* // + const variable* var_import_build2; const variable* var_import_target; // [string] target visibility diff --git a/libbuild2/file.cxx b/libbuild2/file.cxx index 1c6bb1d..f0215df 100644 --- a/libbuild2/file.cxx +++ b/libbuild2/file.cxx @@ -1296,6 +1296,13 @@ namespace build2 { string n ("config.import." + proj.variable ()); + auto skip = [&target, &proj, &trace] () + { + target.proj = move (proj); + l5 ([&]{trace << "skipping " << target;}); + return make_pair (move (target), dir_path ()); + }; + // config.import.<proj> // { @@ -1318,11 +1325,7 @@ namespace build2 // to use system-installed). // if (out_root.empty ()) - { - target.proj = move (proj); - l5 ([&]{trace << "skipping " << target;}); - return make_pair (move (target), dir_path ()); - } + return skip (); break; } @@ -1383,6 +1386,26 @@ namespace build2 } } + // import.build2 + // + if (proj == "build2") + { + // Note that this variable can be 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. + // + if (auto l = iroot[ctx.var_import_build2]) + { + out_root = cast<dir_path> (l); + + if (out_root.empty ()) + return skip (); + + break; + } + } + // Otherwise search subprojects, starting with our root and then trying // outer roots for as long as we are inside an amalgamation. // diff --git a/libbuild2/utility-installed.cxx b/libbuild2/utility-installed.cxx new file mode 100644 index 0000000..8fcb271 --- /dev/null +++ b/libbuild2/utility-installed.cxx @@ -0,0 +1,24 @@ +// file : libbuild2/utility-installed.cxx -*- C++ -*- +// copyright : Copyright (c) 2014-2019 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +// Bootstrap build is never condidered installed. +// +#ifndef BUILD2_BOOTSTRAP + +#include <libbuild2/utility.hxx> + +namespace build2 +{ + struct build_installed_init + { + build_installed_init () + { + build_installed = true; + } + }; + + static build_installed_init init_; +} + +#endif diff --git a/libbuild2/utility.cxx b/libbuild2/utility.cxx index ba50c5a..4f6874e 100644 --- a/libbuild2/utility.cxx +++ b/libbuild2/utility.cxx @@ -81,6 +81,8 @@ namespace build2 : (to_string (build_version.major ()) + '.' + to_string (build_version.minor ()))); + bool build_installed; + optional<bool> mtime_check_option; optional<path> config_sub; diff --git a/libbuild2/utility.hxx b/libbuild2/utility.hxx index a6a7ac3..d9c530b 100644 --- a/libbuild2/utility.hxx +++ b/libbuild2/utility.hxx @@ -142,6 +142,12 @@ namespace build2 LIBBUILD2_SYMEXPORT extern const standard_version build_version; LIBBUILD2_SYMEXPORT extern const string build_version_interface; + // Whether running installed build. + // + // Note: only available after static initialization. + // + LIBBUILD2_SYMEXPORT extern bool build_installed; + // --[no-]mtime-check // LIBBUILD2_SYMEXPORT extern optional<bool> mtime_check_option; |