aboutsummaryrefslogtreecommitdiff
path: root/build2/cc/module.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-09-07 18:09:44 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-09-07 18:09:44 +0200
commite2ba7fa123213fcc5673119b8d993d7967a1fb24 (patch)
tree22b545150af90ec2831a2665afbac9b19828e65f /build2/cc/module.cxx
parentd01c30fa81a849ea7545b8235656eb1dcbba877b (diff)
Implement {c,cxx}.guess modules
These can be loaded before {c,cxx} to guess the compiler. Based on this information we can then choose the standard, experimental features, etc. For example: using cxx.guess if ($cxx.id == 'clang') cxx.features.modules = false cxx.std = experimental using cxx
Diffstat (limited to 'build2/cc/module.cxx')
-rw-r--r--build2/cc/module.cxx75
1 files changed, 41 insertions, 34 deletions
diff --git a/build2/cc/module.cxx b/build2/cc/module.cxx
index 56b74e9..a18271c 100644
--- a/build2/cc/module.cxx
+++ b/build2/cc/module.cxx
@@ -25,16 +25,12 @@ namespace build2
namespace cc
{
void config_module::
- init (scope& rs, const location& loc, const variable_map&)
+ guess (scope& rs, const location&, const variable_map&)
{
- tracer trace (x, "config_init");
+ tracer trace (x, "guess_init");
bool cc_loaded (cast_false<bool> (rs["cc.core.config.loaded"]));
- // Configure.
- //
- compiler_info ci; // For program patterns.
-
// Adjust module priority (compiler). Also order cc module before us
// (we don't want to use priorities for that in case someone manages
// to slot in-between).
@@ -81,10 +77,10 @@ namespace build2
// Figure out which compiler we are dealing with, its target, etc.
//
const path& xc (cast<path> (*p.first));
- ci = guess (x_lang,
- xc,
- cast_null<strings> (rs[config_c_coptions]),
- cast_null<strings> (rs[config_x_coptions]));
+ ci = cc::guess (x_lang,
+ xc,
+ cast_null<strings> (rs[config_c_coptions]),
+ cast_null<strings> (rs[config_x_coptions]));
// Split/canonicalize the target. First see if the user asked us to
// use config.sub.
@@ -118,6 +114,39 @@ namespace build2
}
}
+ // Assign value to variables that describe the compile.
+ //
+ rs.assign (x_id) = ci.id.string ();
+ rs.assign (x_id_type) = ci.id.type;
+ rs.assign (x_id_variant) = ci.id.variant;
+
+ rs.assign (x_version) = ci.version.string;
+ rs.assign (x_version_major) = ci.version.major;
+ rs.assign (x_version_minor) = ci.version.minor;
+ rs.assign (x_version_patch) = ci.version.patch;
+ rs.assign (x_version_build) = ci.version.build;
+
+ // Also enter as x.target.{cpu,vendor,system,version,class} for
+ // convenience of access.
+ //
+ rs.assign (x_target_cpu) = tt.cpu;
+ rs.assign (x_target_vendor) = tt.vendor;
+ rs.assign (x_target_system) = tt.system;
+ rs.assign (x_target_version) = tt.version;
+ rs.assign (x_target_class) = tt.class_;
+
+ rs.assign (x_target) = move (tt);
+
+ new_ = p.second;
+ }
+
+ void config_module::
+ init (scope& rs, const location& loc, const variable_map&)
+ {
+ tracer trace (x, "config_init");
+
+ const target_triplet& tt (cast<target_triplet> (rs[x_target]));
+
// Translate x_std value (if any) to the compiler option(s) (if any).
//
tstd = translate_std (ci, rs, cast_null<string> (rs[x_std]));
@@ -154,7 +183,7 @@ namespace build2
// If this is a new value (e.g., we are configuring), then print the
// report at verbosity level 2 and up (-v).
//
- if (verb >= (p.second ? 2 : 3))
+ if (verb >= (new_ ? 2 : 3))
{
diag_record dr (text);
@@ -220,31 +249,9 @@ namespace build2
rs.assign (x_sys_lib_dirs) = move (lib_dirs);
rs.assign (x_sys_inc_dirs) = move (inc_dirs);
- cid = ci.id.value ();
- rs.assign (x_id) = ci.id.string ();
- rs.assign (x_id_type) = move (ci.id.type);
- rs.assign (x_id_variant) = move (ci.id.variant);
-
- rs.assign (x_version) = move (ci.version.string);
- rs.assign (x_version_major) = ci.version.major;
- rs.assign (x_version_minor) = ci.version.minor;
- rs.assign (x_version_patch) = ci.version.patch;
- rs.assign (x_version_build) = move (ci.version.build);
-
rs.assign (x_signature) = move (ci.signature);
rs.assign (x_checksum) = move (ci.checksum);
- // Also enter as x.target.{cpu,vendor,system,version,class} for
- // convenience of access.
- //
- rs.assign (x_target_cpu) = tt.cpu;
- rs.assign (x_target_vendor) = tt.vendor;
- rs.assign (x_target_system) = tt.system;
- rs.assign (x_target_version) = tt.version;
- rs.assign (x_target_class) = tt.class_;
-
- rs.assign (x_target) = move (tt);
-
// config.x.{p,c,l}options
// config.x.libs
//
@@ -275,7 +282,7 @@ namespace build2
// Load cc.core.config.
//
- if (!cc_loaded)
+ if (!cast_false<bool> (rs["cc.core.config.loaded"]))
{
// Prepare configuration hints.
//