aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-07-19 17:59:44 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-07-19 17:59:44 +0200
commitfc94d68a0389e3e9fc4f143e519f527e1770aa8f (patch)
tree3e2a61930ef5748444707674b721f596cbbbaddb
parenta0f96b95900108705261881b164d779e2db5b824 (diff)
Make distributable with any compiler
-rw-r--r--build/root.build2
-rw-r--r--buildfile82
-rw-r--r--tests/buildfile16
3 files changed, 63 insertions, 37 deletions
diff --git a/build/root.build b/build/root.build
index 7b4a007..cfbcda9 100644
--- a/build/root.build
+++ b/build/root.build
@@ -6,7 +6,7 @@ cxx.std = experimental
using cxx
-assert $cxx.features.modules 'c++ compiler does not support modules'
+#assert $cxx.features.modules 'c++ compiler does not support modules'
mxx{*}: extension = mxx
cxx{*}: extension = cxx
diff --git a/buildfile b/buildfile
index 0efdd29..26bd1b8 100644
--- a/buildfile
+++ b/buildfile
@@ -17,49 +17,65 @@ doc{version}: dist = true
dir{tests/}: install = false
doc{INSTALL}@./: install = false
-# Building of the modules gets rather compiler-specific.
-#
-if ($cxx.id.type == 'clang')
+if! $cxx.features.modules
{
- # Use the naming scheme expected by -fprebuilt-module-path=. Can also be
- # specified with -fmodule-file=.
+ # List sources as files so that we can prepare a distribution with any
+ # compiler.
#
- core = std.core.pcm
- io = std.io.pcm
+ ./: {mxx cxx}{*}
}
-elif ($cxx.id.type == 'msvc')
+else
{
- # Use the naming scheme expected by /module:stdIfcDir. Note that IFCPATH
- # would require an extra directory (x64 or x86; e.g., x64/Release/).
+ # We only do the static library since this is what we would have gotten
+ # should we have used headers (i.e., whatever object code generated from
+ # those headers would have ended up in each executable/library).
#
- # @@ Currently VC looks in Release regardless of /MD or /MDd.
+ ./: liba{std-modules}
+
+ # Building of the modules gets rather compiler-specific.
#
- dir = release/
- core = $dir/std.core.ifc
- io = $dir/std.io.ifc
+ if ($cxx.id.type == 'clang')
+ {
+ # Use the naming scheme expected by -fprebuilt-module-path=. Can also be
+ # specified with -fmodule-file=.
+ #
+ core = std.core.pcm
+ io = std.io.pcm
+ }
+ elif ($cxx.id.type == 'msvc')
+ {
+ # Use the naming scheme expected by /module:stdIfcDir. Note that IFCPATH
+ # would require an extra directory (x64 or x86; e.g., x64/Release/).
+ #
+ # @@ Currently VC looks in Release regardless of /MD or /MDd.
+ #
+ dir = release/
+ core = $dir/std.core.ifc
+ io = $dir/std.io.ifc
- bmia{$core $io}: fsdir{$dir}
+ bmia{$core $io}: fsdir{$dir}
- # VC expects to find std.lib next to the .ifc's. Make it a dummy one.
- #
- liba{std-modules}: $dir/liba{std}
- $dir/liba{std}: cxx{dummy.cxx}
-}
+ # VC expects to find std.lib next to the .ifc's. Make it a dummy one.
+ #
+ liba{std-modules}: $dir/liba{std}
+ $dir/liba{std}: cxx{dummy.cxx}
+ }
-# @@ TMP: use utility library instead?
-#
-if ($cxx.target.class == 'linux' || $cxx.target.class == 'bsd')
- cxx.coptions += -fPIC
+ # @@ TMP: use utility library instead?
+ #
+ if ($cxx.target.class == 'linux' || $cxx.target.class == 'bsd')
+ cxx.coptions += -fPIC
-# Clang 5.0 with libc++ (sometimes) needs it -- go figure.
-#
-if ($cxx.target.class != "windows")
- cxx.libs += -lpthread
+ # Clang 5.0 with libc++ (sometimes) needs it -- go figure.
+ #
+ if ($cxx.target.class != "windows")
+ cxx.libs += -lpthread
-liba{std-modules}: bmia{$core $io}
+ liba{std-modules}: bmia{$core $io}
-bmia{$core}: mxx{std-core}
-bmia{$io}: mxx{std-io} bmia{$core}
+ bmia{$core}: mxx{std-core}
+ bmia{$io}: mxx{std-io} bmia{$core}
-mxx{std-core}@./: cc.module_name = std.core
-mxx{std-io}@./: cc.module_name = std.io
+ mxx{std-core}@./: cc.module_name = std.core
+ mxx{std-io}@./: cc.module_name = std.io
+}
diff --git a/tests/buildfile b/tests/buildfile
index 881153e..8941a94 100644
--- a/tests/buildfile
+++ b/tests/buildfile
@@ -2,7 +2,17 @@
# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd
# license : MIT; see accompanying LICENSE file
-import libs = libstd-modules%liba{std-modules}
+if! $cxx.features.modules
+{
+ # List sources as files so that we can prepare a distribution with any
+ # compiler.
+ #
+ ./: cxx{*} file{test.out}
+}
+else
+{
+ import libs = libstd-modules%liba{std-modules}
-exe{driver}: cxx{driver} $libs
-exe{driver}: test.output = test.out
+ exe{driver}: cxx{driver} $libs
+ exe{driver}: test.output = test.out
+}