From 0fb42229a5bf13170667701ad6cb468d58348007 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 2 Apr 2020 12:49:10 +0200 Subject: Fix ~host config to only contain cc and bin modules configuration Also add ~build2 that contains everything (except config.dist.*) to be used for build system modules. --- libbuild2/buildfile | 30 ++++++++++++++++++++---------- libbuild2/cc/module.cxx | 2 +- libbuild2/config/host-config.cxx.in | 1 + libbuild2/config/init.cxx | 9 ++++++--- libbuild2/functions-regex.cxx | 3 +++ 5 files changed, 31 insertions(+), 14 deletions(-) diff --git a/libbuild2/buildfile b/libbuild2/buildfile index a253ab1..578a4c8 100644 --- a/libbuild2/buildfile +++ b/libbuild2/buildfile @@ -45,21 +45,31 @@ libul{build2}: config/{hxx ixx txx cxx}{** -host-config -**.test...} \ config/cxx{host-config} # This will of course blow up spectacularly if we are cross-compiling. But -# let's wait and enjoy the fireworks (and get a sense of why would someone -# need to cross-compile a build system). +# let's wait and enjoy the fireworks (and get a sense of why someone would +# want to cross-compile a build system). # config/cxx{host-config}: config/in{host-config} { - # Remove comment lines which could be confused with preprocessor directives - # by some lesser compilers. + # For the ~host configuration we only want c/cxx/cc and bin that they load. + # For ~build2 we want to keep everything except dist. # - # Also filter out config.install.chroot -- we definitely don't want it - # carried through. + # We also remove comment lines which could be confused with preprocessor + # directives by some lesser compilers. # - host_config = $regex.replace_lines($config.save(), \ - '^ *(#|config.install.chroot).*$', \ - [null], \ - return_lines) + # For ~build2 also filter out config.install.chroot -- we definitely don't + # want it carried through. + # + build2_config = $regex.replace_lines( \ + $config.save(), \ + '^ *(#|config\.dist\.|config\.install\.chroot).*$', \ + [null], \ + return_lines) + + host_config = $regex.replace_lines( \ + $build2_config, \ + '^ *config\.(c[. ]|cxx[. ]|cc[.]|bin[.]).*$', \ + '$&', \ + format_no_copy return_lines) } libul{build2}: dist/{hxx ixx txx cxx}{** -**.test...} diff --git a/libbuild2/cc/module.cxx b/libbuild2/cc/module.cxx index 2b2604b..a485b46 100644 --- a/libbuild2/cc/module.cxx +++ b/libbuild2/cc/module.cxx @@ -89,7 +89,7 @@ namespace build2 } } - // If cc.core.config is already loaded then use its toolchain id, + // If cc.core.guess is already loaded then use its toolchain id, // (optional) pattern, and mode to guess an appropriate default // (e.g., for {gcc, *-4.9 -m64} we will get g++-4.9 -m64). // diff --git a/libbuild2/config/host-config.cxx.in b/libbuild2/config/host-config.cxx.in index 2e45c46..9e3e0c2 100644 --- a/libbuild2/config/host-config.cxx.in +++ b/libbuild2/config/host-config.cxx.in @@ -8,5 +8,6 @@ namespace build2 // This is a raw string literal, in case you are unfamiliar. // extern const char host_config[] = R"###($host_config$)###"; + extern const char build2_config[] = R"###($build2_config$)###"; } } diff --git a/libbuild2/config/init.cxx b/libbuild2/config/init.cxx index 75193bb..f0f4841 100644 --- a/libbuild2/config/init.cxx +++ b/libbuild2/config/init.cxx @@ -142,8 +142,11 @@ namespace build2 return true; // Initialize first (load config.build). } + // host-config.cxx.in + // #ifndef BUILD2_BOOTSTRAP - extern const char host_config[]; // host-config.cxx.in + extern const char host_config[]; + extern const char build2_config[]; #endif bool @@ -251,12 +254,12 @@ namespace build2 if (s[0] != '~') load_config_file (f, l); - else if (s == "~host") + else if (s == "~host" || s == "~build2") { #ifdef BUILD2_BOOTSTRAP assert (false); #else - istringstream is (host_config); + istringstream is (s[1] == 'h' ? host_config : build2_config); load_config (is, path_name (s), l); #endif } diff --git a/libbuild2/functions-regex.cxx b/libbuild2/functions-regex.cxx index 48955ae..6a8c83a 100644 --- a/libbuild2/functions-regex.cxx +++ b/libbuild2/functions-regex.cxx @@ -555,6 +555,9 @@ namespace build2 // containing the unmatched lines and line replacements // seperated with newlines. // + // Note that if format_no_copy is specified, unmatched lines are not + // copied either. + // f[".replace_lines"] = [](value s, string re, string fmt, -- cgit v1.1