aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2022-05-03 18:11:08 +0300
committerJussi Pakkanen <jpakkane@gmail.com>2022-05-06 18:48:15 +0300
commiteef51fa3d60f2657d9687f99db3b5e989daef8c3 (patch)
tree75f0a410e3cd945d0e75c92a932efe2efe1370ca
parent7183d9d71ee4391b2658943505b8497b58ea8bf3 (diff)
downloadmeson-eef51fa3d60f2657d9687f99db3b5e989daef8c3.zip
meson-eef51fa3d60f2657d9687f99db3b5e989daef8c3.tar.gz
meson-eef51fa3d60f2657d9687f99db3b5e989daef8c3.tar.bz2
Add some scaffolding needed for C++ modules in GCC.
Further work pending GCC bug #105467 and/or Ninja bug #1962.
-rw-r--r--mesonbuild/backend/ninjabackend.py2
-rw-r--r--test cases/unit/85 cpp modules/gcc/main.cpp7
-rw-r--r--test cases/unit/85 cpp modules/gcc/meson.build19
-rw-r--r--test cases/unit/85 cpp modules/gcc/src0.cxx7
-rw-r--r--test cases/unit/85 cpp modules/gcc/src1.cxx7
-rw-r--r--test cases/unit/85 cpp modules/gcc/src2.cxx7
-rw-r--r--test cases/unit/85 cpp modules/gcc/src3.cxx7
-rw-r--r--test cases/unit/85 cpp modules/gcc/src4.cxx7
-rw-r--r--test cases/unit/85 cpp modules/gcc/src5.cxx7
-rw-r--r--test cases/unit/85 cpp modules/gcc/src6.cxx7
-rw-r--r--test cases/unit/85 cpp modules/gcc/src7.cxx7
-rw-r--r--test cases/unit/85 cpp modules/gcc/src8.cxx7
-rw-r--r--test cases/unit/85 cpp modules/gcc/src9.cxx5
-rw-r--r--test cases/unit/85 cpp modules/meson.build2
14 files changed, 98 insertions, 0 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index 1720138..35c14ee 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -913,6 +913,8 @@ class NinjaBackend(backends.Backend):
return True
if 'cpp' not in target.compilers:
return False
+ if '-fmodules-ts' in target.extra_args.get('cpp', []):
+ return True
# Currently only the preview version of Visual Studio is supported.
cpp = target.compilers['cpp']
if cpp.get_id() != 'msvc':
diff --git a/test cases/unit/85 cpp modules/gcc/main.cpp b/test cases/unit/85 cpp modules/gcc/main.cpp
new file mode 100644
index 0000000..d825c7d
--- /dev/null
+++ b/test cases/unit/85 cpp modules/gcc/main.cpp
@@ -0,0 +1,7 @@
+import M0;
+#include<cstdio>
+
+int main() {
+ printf("The value is %d", func0());
+ return 0;
+}
diff --git a/test cases/unit/85 cpp modules/gcc/meson.build b/test cases/unit/85 cpp modules/gcc/meson.build
new file mode 100644
index 0000000..e405c56
--- /dev/null
+++ b/test cases/unit/85 cpp modules/gcc/meson.build
@@ -0,0 +1,19 @@
+# GCC does not recognize .ixx as a C++ source extension so
+# we have to do this instead.
+
+e = executable('modtest',
+ 'main.cpp',
+ 'src0.cxx',
+ 'src1.cxx',
+ 'src2.cxx',
+ 'src3.cxx',
+ 'src4.cxx',
+ 'src5.cxx',
+ 'src6.cxx',
+ 'src7.cxx',
+ 'src8.cxx',
+ 'src9.cxx',
+ cpp_args: ['-fmodules-ts'],
+ )
+
+test('modtest', e)
diff --git a/test cases/unit/85 cpp modules/gcc/src0.cxx b/test cases/unit/85 cpp modules/gcc/src0.cxx
new file mode 100644
index 0000000..3ca4d14
--- /dev/null
+++ b/test cases/unit/85 cpp modules/gcc/src0.cxx
@@ -0,0 +1,7 @@
+export module M0;
+
+import M1;
+
+export int func0() {
+ return func1();
+}
diff --git a/test cases/unit/85 cpp modules/gcc/src1.cxx b/test cases/unit/85 cpp modules/gcc/src1.cxx
new file mode 100644
index 0000000..cea6696
--- /dev/null
+++ b/test cases/unit/85 cpp modules/gcc/src1.cxx
@@ -0,0 +1,7 @@
+export module M1;
+
+import M2;
+
+export int func1() {
+ return func2();
+}
diff --git a/test cases/unit/85 cpp modules/gcc/src2.cxx b/test cases/unit/85 cpp modules/gcc/src2.cxx
new file mode 100644
index 0000000..415714c
--- /dev/null
+++ b/test cases/unit/85 cpp modules/gcc/src2.cxx
@@ -0,0 +1,7 @@
+export module M2;
+
+import M3;
+
+export int func2() {
+ return func3();
+}
diff --git a/test cases/unit/85 cpp modules/gcc/src3.cxx b/test cases/unit/85 cpp modules/gcc/src3.cxx
new file mode 100644
index 0000000..96f135c
--- /dev/null
+++ b/test cases/unit/85 cpp modules/gcc/src3.cxx
@@ -0,0 +1,7 @@
+export module M3;
+
+import M4;
+
+export int func3() {
+ return func4();
+}
diff --git a/test cases/unit/85 cpp modules/gcc/src4.cxx b/test cases/unit/85 cpp modules/gcc/src4.cxx
new file mode 100644
index 0000000..1ac1a6a
--- /dev/null
+++ b/test cases/unit/85 cpp modules/gcc/src4.cxx
@@ -0,0 +1,7 @@
+export module M4;
+
+import M5;
+
+export int func4() {
+ return func5();
+}
diff --git a/test cases/unit/85 cpp modules/gcc/src5.cxx b/test cases/unit/85 cpp modules/gcc/src5.cxx
new file mode 100644
index 0000000..96cf707
--- /dev/null
+++ b/test cases/unit/85 cpp modules/gcc/src5.cxx
@@ -0,0 +1,7 @@
+export module M5;
+
+import M6;
+
+export int func5() {
+ return func6();
+}
diff --git a/test cases/unit/85 cpp modules/gcc/src6.cxx b/test cases/unit/85 cpp modules/gcc/src6.cxx
new file mode 100644
index 0000000..760b71c
--- /dev/null
+++ b/test cases/unit/85 cpp modules/gcc/src6.cxx
@@ -0,0 +1,7 @@
+export module M6;
+
+import M7;
+
+export int func6() {
+ return func7();
+}
diff --git a/test cases/unit/85 cpp modules/gcc/src7.cxx b/test cases/unit/85 cpp modules/gcc/src7.cxx
new file mode 100644
index 0000000..8ce6608
--- /dev/null
+++ b/test cases/unit/85 cpp modules/gcc/src7.cxx
@@ -0,0 +1,7 @@
+export module M7;
+
+import M8;
+
+export int func7() {
+ return func8();
+}
diff --git a/test cases/unit/85 cpp modules/gcc/src8.cxx b/test cases/unit/85 cpp modules/gcc/src8.cxx
new file mode 100644
index 0000000..6a3ef96
--- /dev/null
+++ b/test cases/unit/85 cpp modules/gcc/src8.cxx
@@ -0,0 +1,7 @@
+export module M8;
+
+import M9;
+
+export int func8() {
+ return func9();
+}
diff --git a/test cases/unit/85 cpp modules/gcc/src9.cxx b/test cases/unit/85 cpp modules/gcc/src9.cxx
new file mode 100644
index 0000000..3ecb3be
--- /dev/null
+++ b/test cases/unit/85 cpp modules/gcc/src9.cxx
@@ -0,0 +1,5 @@
+export module M9;
+
+export int func9() {
+ return 42;
+}
diff --git a/test cases/unit/85 cpp modules/meson.build b/test cases/unit/85 cpp modules/meson.build
index 3dd5033..579ea9b 100644
--- a/test cases/unit/85 cpp modules/meson.build
+++ b/test cases/unit/85 cpp modules/meson.build
@@ -4,6 +4,8 @@ cpp = meson.get_compiler('cpp')
if cpp.get_id() == 'msvc'
subdir('vs')
+elif cpp.get_id() == 'gcc'
+ subdir('gcc')
else
error('Unknown compiler')
endif