aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-05-30 14:11:50 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-05-30 14:11:50 +0200
commit4a74374e20d275722067e773d7ea99fc85ca2a0b (patch)
tree6da80735a2677ebd415db862233fc5de90950504
parent01463f681243d569e38a87e92bdc3630a11a9f65 (diff)
Diagnose lack of module support in extract_modules()
-rw-r--r--build2/c/init.cxx2
-rw-r--r--build2/cc/common.hxx4
-rw-r--r--build2/cc/compile.cxx17
-rw-r--r--build2/cxx/init.cxx2
-rw-r--r--tests/cc/preprocessed/testscript2
5 files changed, 21 insertions, 6 deletions
diff --git a/build2/c/init.cxx b/build2/c/init.cxx
index 30c324a..b4b2bca 100644
--- a/build2/c/init.cxx
+++ b/build2/c/init.cxx
@@ -262,6 +262,8 @@ namespace build2
cm.tstd,
+ false, // No C modules for now.
+
cast_null<process_path> (rs["pkgconfig.path"]),
cast<dir_paths> (rs[cm.x_sys_lib_dirs]),
cast<dir_paths> (rs[cm.x_sys_inc_dirs]),
diff --git a/build2/cc/common.hxx b/build2/cc/common.hxx
index fa6ec5a..155d670 100644
--- a/build2/cc/common.hxx
+++ b/build2/cc/common.hxx
@@ -114,6 +114,8 @@ namespace build2
const strings& tstd; // Translated x_std value (options).
+ bool modules; // x.feaures.modules
+
const process_path* pkgconfig; // pkgconfig.path (can be NULL).
const dir_paths& sys_lib_dirs; // x.sys_lib_dirs
const dir_paths& sys_inc_dirs; // x.sys_inc_dirs
@@ -154,6 +156,7 @@ namespace build2
const process_path& path,
const target_triplet& tg,
const strings& std,
+ bool mod,
const process_path* pkgc,
const dir_paths& sld,
const dir_paths& sid,
@@ -168,6 +171,7 @@ namespace build2
cid (id), cvar (var), cmaj (mj), cmin (mi), cpath (path),
ctg (tg), tsys (ctg.system), tclass (ctg.class_),
tstd (std),
+ modules (mod),
pkgconfig (pkgc), sys_lib_dirs (sld), sys_inc_dirs (sid),
x_src (src), x_hdr (hdr), x_inc (inc) {}
};
diff --git a/build2/cc/compile.cxx b/build2/cc/compile.cxx
index ce96e00..c7fc3ea 100644
--- a/build2/cc/compile.cxx
+++ b/build2/cc/compile.cxx
@@ -610,9 +610,8 @@ namespace build2
dd.close ();
- // If C++ modules support is enabled then we need to extract the
- // module dependency information in addition to header dependencies
- // above.
+ // Extract the module dependency information in addition to header
+ // dependencies above.
//
if (u) // @@ TMP (depdb validation similar to extract_headers()).
{
@@ -2207,8 +2206,16 @@ namespace build2
throw failed ();
}
- if (!tu.module_name.empty () || !tu.module_imports.empty ())
- fail << "module support not yet implemented";
+ //@@ TODO: if bmi{}, make sure module_name is not empty.
+
+ if (tu.module_name.empty () && tu.module_imports.empty ())
+ return;
+
+ // Modules are used by this translation unit. Make sure module support
+ // is enabled.
+ //
+ if (!modules)
+ fail << "modules support not enabled or unavailable";
}
// Filter cl.exe noise (msvc.cxx).
diff --git a/build2/cxx/init.cxx b/build2/cxx/init.cxx
index f6162ab..fde12e3 100644
--- a/build2/cxx/init.cxx
+++ b/build2/cxx/init.cxx
@@ -433,6 +433,8 @@ namespace build2
cm.tstd,
+ cast<bool> (rs["cxx.features.modules"]),
+
cast_null<process_path> (rs["pkgconfig.path"]),
cast<dir_paths> (rs[cm.x_sys_lib_dirs]),
cast<dir_paths> (rs[cm.x_sys_inc_dirs]),
diff --git a/tests/cc/preprocessed/testscript b/tests/cc/preprocessed/testscript
index 118bed5..61a6fda 100644
--- a/tests/cc/preprocessed/testscript
+++ b/tests/cc/preprocessed/testscript
@@ -98,7 +98,7 @@ $* <<EOI 2>>EOE != 0 ;#@@ &test*
cc.preprocessed = modules
exe{test}: cxx{test}
EOI
- error: module support not yet implemented
+ error: modules support not enabled or unavailable
EOE
rm -f test.o.d test.exe.o.d test.exe.obj.d #@@ TMP