aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/cxx/init.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'libbuild2/cxx/init.cxx')
-rw-r--r--libbuild2/cxx/init.cxx79
1 files changed, 71 insertions, 8 deletions
diff --git a/libbuild2/cxx/init.cxx b/libbuild2/cxx/init.cxx
index cd5169d..3ca920e 100644
--- a/libbuild2/cxx/init.cxx
+++ b/libbuild2/cxx/init.cxx
@@ -93,7 +93,7 @@ namespace build2
// Feature flags.
//
- auto& vp (rs.var_pool ());
+ auto& vp (rs.var_pool (true /* public */)); // All qualified.
// Similar to config.cxx.std, config.cxx.features.* overrides
// cxx.features.*.
@@ -194,6 +194,8 @@ namespace build2
// for this mode. So starting from 16 we only enable it in
// `experimental`.
//
+ // Note: no /std:c++23 yet as of MSVC 17.6.
+ //
if (v16_11)
o = "/std:c++20";
else if (v16_0)
@@ -316,12 +318,14 @@ namespace build2
;
else
{
- // Translate 11 to 0x, 14 to 1y, 17 to 1z, 20 to 2a, and 23 to 2b
- // for compatibility with older versions of the compilers.
+ // Translate 11 to 0x, 14 to 1y, 17 to 1z, 20 to 2a, 23 to 2b, and
+ // 26 to 2c for compatibility with older versions of the
+ // compilers.
//
o = "-std=";
- if (*v == "23") o += "c++2b";
+ if (*v == "26") o += "c++2c";
+ else if (*v == "23") o += "c++2b";
else if (*v == "20") o += "c++2a";
else if (*v == "17") o += "c++1z";
else if (*v == "14") o += "c++1y";
@@ -469,15 +473,20 @@ namespace build2
// Enter all the variables and initialize the module data.
//
- auto& vp (rs.var_pool ());
+ // All the variables we enter are qualified so go straight for the
+ // public variable pool.
+ //
+ auto& vp (rs.var_pool (true /* public */));
cc::config_data d {
cc::lang::cxx,
"cxx",
"c++",
+ "obj-c++",
BUILD2_DEFAULT_CXX,
".ii",
+ ".mii",
hinters,
@@ -668,6 +677,9 @@ namespace build2
vp["cc.export.libs"],
vp["cc.export.impl_libs"],
+ vp["cc.pkconfig.include"],
+ vp["cc.pkconfig.lib"],
+
vp.insert<string> ("cxx.stdlib"),
vp["cc.runtime"],
@@ -733,6 +745,9 @@ namespace build2
vp.insert_alias (d.c_module_name, "cxx.module_name");
vp.insert_alias (d.c_importable, "cxx.importable");
+ vp.insert_alias (d.c_pkgconfig_include, "cxx.pkgconfig.include");
+ vp.insert_alias (d.c_pkgconfig_lib, "cxx.pkgconfig.lib");
+
auto& m (extra.set_module (new config_module (move (d))));
m.guess (rs, loc, extra.hints);
@@ -772,6 +787,10 @@ namespace build2
nullptr
};
+ // Note that we don't include S{} here because none of the files we
+ // compile can plausibly want to include .S. (Maybe in inline assember
+ // instrcutions?)
+ //
static const target_type* const inc[] =
{
&hxx::static_type,
@@ -781,6 +800,8 @@ namespace build2
&mxx::static_type,
&cxx::static_type,
&c::static_type,
+ &mm::static_type,
+ &m::static_type,
nullptr
};
@@ -805,7 +826,7 @@ namespace build2
auto& cm (
load_module<config_module> (rs, rs, "cxx.config", loc, extra.hints));
- auto& vp (rs.var_pool ());
+ auto& vp (rs.var_pool (true /* public */)); // All qualified.
bool modules (cast<bool> (rs["cxx.features.modules"]));
@@ -823,7 +844,6 @@ namespace build2
"cxx.compile",
"cxx.link",
"cxx.install",
- "cxx.uninstall",
cm.x_info->id.type,
cm.x_info->id.variant,
@@ -863,12 +883,54 @@ namespace build2
inc
};
- auto& m (extra.set_module (new module (move (d))));
+ auto& m (extra.set_module (new module (move (d), rs)));
m.init (rs, loc, extra.hints, *cm.x_info);
return true;
}
+ bool
+ objcxx_init (scope& rs,
+ scope& bs,
+ const location& loc,
+ bool,
+ bool,
+ module_init_extra&)
+ {
+ tracer trace ("cxx::objcxx_init");
+ l5 ([&]{trace << "for " << bs;});
+
+ // We only support root loading (which means there can only be one).
+ //
+ if (rs != bs)
+ fail (loc) << "cxx.objcxx module must be loaded in project root";
+
+ module* mod (rs.find_module<module> ("cxx"));
+
+ if (mod == nullptr)
+ fail (loc) << "cxx.objcxx module must be loaded after cxx module";
+
+ // Register the target type and "enable" it in the module.
+ //
+ // Note that we must register the target type regardless of whether the
+ // C++ compiler is capable of compiling Objective-C++. But we enable
+ // only if it is.
+ //
+ // Note: see similar code in the c module.
+ //
+ rs.insert_target_type<mm> ();
+
+ // Note that while Objective-C++ is supported by MinGW GCC, it's
+ // unlikely Clang supports it when targeting MSVC or Emscripten. But
+ // let's keep the check simple for now.
+ //
+ if (mod->ctype == compiler_type::gcc ||
+ mod->ctype == compiler_type::clang)
+ mod->x_obj = &mm::static_type;
+
+ return true;
+ }
+
static const module_functions mod_functions[] =
{
// NOTE: don't forget to also update the documentation in init.hxx if
@@ -876,6 +938,7 @@ namespace build2
{"cxx.guess", nullptr, guess_init},
{"cxx.config", nullptr, config_init},
+ {"cxx.objcxx", nullptr, objcxx_init},
{"cxx", nullptr, init},
{nullptr, nullptr, nullptr}
};