From 9ae4897cfe935598333a5f709e967fefc4c161aa Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 31 May 2017 16:35:50 +0200 Subject: C++ modules work: add target types --- build2/cxx/init.cxx | 11 ++++++++--- build2/cxx/target.cxx | 13 +++++++++++++ build2/cxx/target.hxx | 15 +++++++++++++++ 3 files changed, 36 insertions(+), 3 deletions(-) (limited to 'build2/cxx') diff --git a/build2/cxx/init.cxx b/build2/cxx/init.cxx index fde12e3..a5422d2 100644 --- a/build2/cxx/init.cxx +++ b/build2/cxx/init.cxx @@ -375,19 +375,21 @@ namespace build2 static const target_type* const hdr[] = { &hxx::static_type, + &h::static_type, &ixx::static_type, &txx::static_type, - &h::static_type, + &mxx::static_type, nullptr }; static const target_type* const inc[] = { &hxx::static_type, + &h::static_type, &ixx::static_type, &txx::static_type, + &mxx::static_type, &cxx::static_type, - &h::static_type, &c::static_type, nullptr }; @@ -414,6 +416,8 @@ namespace build2 if (!cast_false (rs["cxx.config.loaded"])) load_module (rs, rs, "cxx.config", loc, false, hints); + bool modules (cast (rs["cxx.features.modules"])); + config_module& cm (*rs.modules.lookup ("cxx.config")); cc::data d { @@ -433,13 +437,14 @@ namespace build2 cm.tstd, - cast (rs["cxx.features.modules"]), + modules, cast_null (rs["pkgconfig.path"]), cast (rs[cm.x_sys_lib_dirs]), cast (rs[cm.x_sys_inc_dirs]), cxx::static_type, + modules ? &mxx::static_type : nullptr, hdr, inc }; diff --git a/build2/cxx/target.cxx b/build2/cxx/target.cxx index 7fb9971..5641e7a 100644 --- a/build2/cxx/target.cxx +++ b/build2/cxx/target.cxx @@ -63,5 +63,18 @@ namespace build2 &file_search, false }; + + extern const char mxx_ext_def[] = "mxx"; + const target_type mxx::static_type + { + "mxx", + &cc::static_type, + &target_factory, + &target_extension_var, + &target_pattern_var, + nullptr, + &file_search, + false + }; } } diff --git a/build2/cxx/target.hxx b/build2/cxx/target.hxx index 4dd93e3..f5591d1 100644 --- a/build2/cxx/target.hxx +++ b/build2/cxx/target.hxx @@ -57,6 +57,21 @@ namespace build2 static const target_type static_type; virtual const target_type& dynamic_type () const {return static_type;} }; + + // The module interface unit is both like a header (e.g., we need to + // install it) and like a source (we need to compile it). Plus, to + // support dual use (modules/headers) it could actually be #include'd + // (and in both cases). + // + class mxx: public cc::cc + { + public: + using cc::cc; + + public: + static const target_type static_type; + virtual const target_type& dynamic_type () const {return static_type;} + }; } } -- cgit v1.1