summaryrefslogtreecommitdiff
path: root/libmprint
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-07-20 08:55:37 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-07-20 08:55:37 +0200
commit01399cea3ff5d5d64c987d06c882a1c7c9cdd878 (patch)
treeb0df201f3bec90a94e6d373b71448d97ea6fa5fc /libmprint
parentd8c1605ced6e9445b8ef6fdf7ab5dde4021d454a (diff)
Add modularized version
Diffstat (limited to 'libmprint')
-rw-r--r--libmprint/.gitignore19
-rw-r--r--libmprint/build/.gitignore1
-rw-r--r--libmprint/build/bootstrap.build7
-rw-r--r--libmprint/build/export.build6
-rw-r--r--libmprint/build/root.build10
-rw-r--r--libmprint/buildfile8
-rw-r--r--libmprint/libmprint/buildfile15
-rw-r--r--libmprint/libmprint/print.cxx20
-rw-r--r--libmprint/libmprint/print.mxx11
-rw-r--r--libmprint/manifest21
-rw-r--r--libmprint/tests/.gitignore1
-rw-r--r--libmprint/tests/build/.gitignore1
-rw-r--r--libmprint/tests/build/bootstrap.build5
-rw-r--r--libmprint/tests/build/root.build13
-rw-r--r--libmprint/tests/buildfile1
-rw-r--r--libmprint/tests/test/buildfile5
-rw-r--r--libmprint/tests/test/driver.cxx10
-rw-r--r--libmprint/tests/test/test.out1
18 files changed, 155 insertions, 0 deletions
diff --git a/libmprint/.gitignore b/libmprint/.gitignore
new file mode 100644
index 0000000..1173da4
--- /dev/null
+++ b/libmprint/.gitignore
@@ -0,0 +1,19 @@
+# Compiler/linker output.
+#
+*.d
+*.ii
+*.o
+*.obj
+*.nms
+*.pcm
+*.ifc
+*.so
+*.dll
+*.a
+*.lib
+*.exp
+*.exe
+*.exe.dlls/
+*.exe.manifest
+
+version
diff --git a/libmprint/build/.gitignore b/libmprint/build/.gitignore
new file mode 100644
index 0000000..225c27f
--- /dev/null
+++ b/libmprint/build/.gitignore
@@ -0,0 +1 @@
+config.build
diff --git a/libmprint/build/bootstrap.build b/libmprint/build/bootstrap.build
new file mode 100644
index 0000000..9290506
--- /dev/null
+++ b/libmprint/build/bootstrap.build
@@ -0,0 +1,7 @@
+project = libmprint
+
+using version
+using config
+using dist
+using test
+using install
diff --git a/libmprint/build/export.build b/libmprint/build/export.build
new file mode 100644
index 0000000..25c9281
--- /dev/null
+++ b/libmprint/build/export.build
@@ -0,0 +1,6 @@
+$out_root/:
+{
+ include libmprint/
+}
+
+export $out_root/libmprint/lib{mprint}
diff --git a/libmprint/build/root.build b/libmprint/build/root.build
new file mode 100644
index 0000000..0f4a099
--- /dev/null
+++ b/libmprint/build/root.build
@@ -0,0 +1,10 @@
+cxx.std = experimental
+
+cxx.features.symexport = true
+
+using cxx
+
+assert $cxx.features.modules 'c++ compiler does not support modules'
+
+mxx{*}: extension = mxx
+cxx{*}: extension = cxx
diff --git a/libmprint/buildfile b/libmprint/buildfile
new file mode 100644
index 0000000..f02884e
--- /dev/null
+++ b/libmprint/buildfile
@@ -0,0 +1,8 @@
+./: libmprint/ tests/ doc{version} file{manifest}
+
+doc{version}: file{manifest} # Generated by the version module.
+doc{version}: dist = true
+
+# Don't install tests.
+#
+dir{tests/}: install = false
diff --git a/libmprint/libmprint/buildfile b/libmprint/libmprint/buildfile
new file mode 100644
index 0000000..31286c2
--- /dev/null
+++ b/libmprint/libmprint/buildfile
@@ -0,0 +1,15 @@
+import libs = libstd-modules%liba{std-modules}
+
+lib{mprint}: {mxx cxx}{print} $libs
+
+# For pre-releases use the complete version to make sure they cannot be used
+# in place of another pre-release or the final version.
+#
+if $version.pre_release
+ lib{mprint}: bin.lib.version = @"-$version.project_id"
+else
+ lib{mprint}: bin.lib.version = @"-$version.major.$version.minor"
+
+# Install into the libmprint/ subdirectory of, say, /usr/include/.
+#
+install.include = $install.include/$project/
diff --git a/libmprint/libmprint/print.cxx b/libmprint/libmprint/print.cxx
new file mode 100644
index 0000000..e9e7a3c
--- /dev/null
+++ b/libmprint/libmprint/print.cxx
@@ -0,0 +1,20 @@
+// file: libmprint/print.cxx -*- C++ -*-
+
+module print;
+
+#ifdef __clang__
+import std.core;
+#endif
+
+import std.io;
+
+using namespace std;
+
+namespace print
+{
+ void
+ to_stdout (const string& s)
+ {
+ cout << s << endl;
+ }
+}
diff --git a/libmprint/libmprint/print.mxx b/libmprint/libmprint/print.mxx
new file mode 100644
index 0000000..4b459e1
--- /dev/null
+++ b/libmprint/libmprint/print.mxx
@@ -0,0 +1,11 @@
+// file: libmprint/print.mxx -*- C++ -*-
+
+export module print;
+
+import std.core;
+
+export namespace print
+{
+ __symexport void
+ to_stdout (const std::string&);
+}
diff --git a/libmprint/manifest b/libmprint/manifest
new file mode 100644
index 0000000..2ece2e4
--- /dev/null
+++ b/libmprint/manifest
@@ -0,0 +1,21 @@
+: 1
+name: libmprint
+version: 1.0.0
+summary: The modularized "Hello World" example printer library
+license: MIT
+tags: c++, hello, world, printer, example, modules
+description: \
+A simple library that implements the "Hello World" example printer in C++
+with modules.
+\
+url: http://www.example.org/libmprint
+email: hello-users@example.org
+build-email: builds@build2.org
+build-exclude: *-msvc_15u0* ; Broken C++ modules support
+build-include: *-msvc_15*
+build-include: *-clang_5.0*
+build-exclude: * ; Requires C++ modules support
+requires: c++20
+depends: * build2 >= 0.6.0-
+depends: * bpkg >= 0.6.0-
+depends: libstd-modules
diff --git a/libmprint/tests/.gitignore b/libmprint/tests/.gitignore
new file mode 100644
index 0000000..e54525b
--- /dev/null
+++ b/libmprint/tests/.gitignore
@@ -0,0 +1 @@
+driver
diff --git a/libmprint/tests/build/.gitignore b/libmprint/tests/build/.gitignore
new file mode 100644
index 0000000..225c27f
--- /dev/null
+++ b/libmprint/tests/build/.gitignore
@@ -0,0 +1 @@
+config.build
diff --git a/libmprint/tests/build/bootstrap.build b/libmprint/tests/build/bootstrap.build
new file mode 100644
index 0000000..2c2de24
--- /dev/null
+++ b/libmprint/tests/build/bootstrap.build
@@ -0,0 +1,5 @@
+project = # Unnamed subproject.
+
+using config
+using dist
+using test
diff --git a/libmprint/tests/build/root.build b/libmprint/tests/build/root.build
new file mode 100644
index 0000000..58dffed
--- /dev/null
+++ b/libmprint/tests/build/root.build
@@ -0,0 +1,13 @@
+cxx.std = experimental
+
+using cxx
+
+cxx{*}: extension = cxx
+
+# Every exe{} in this subproject is by default a test.
+#
+exe{*}: test = true
+
+# Specify the test target for cross-testing.
+#
+test.target = $cxx.target
diff --git a/libmprint/tests/buildfile b/libmprint/tests/buildfile
new file mode 100644
index 0000000..1a8bcc9
--- /dev/null
+++ b/libmprint/tests/buildfile
@@ -0,0 +1 @@
+./: test/
diff --git a/libmprint/tests/test/buildfile b/libmprint/tests/test/buildfile
new file mode 100644
index 0000000..0fe3fea
--- /dev/null
+++ b/libmprint/tests/test/buildfile
@@ -0,0 +1,5 @@
+import libs = libmprint%lib{mprint}
+import libs += libstd-modules%liba{std-modules}
+
+exe{driver}: cxx{driver} $libs
+exe{driver}: test.output = test.out
diff --git a/libmprint/tests/test/driver.cxx b/libmprint/tests/test/driver.cxx
new file mode 100644
index 0000000..32fa1ae
--- /dev/null
+++ b/libmprint/tests/test/driver.cxx
@@ -0,0 +1,10 @@
+// file: tests/test/driver.cxx -*- C++ -*-
+
+import std.core;
+import print;
+
+int
+main ()
+{
+ print::to_stdout ("Hello, World!");
+}
diff --git a/libmprint/tests/test/test.out b/libmprint/tests/test/test.out
new file mode 100644
index 0000000..8ab686e
--- /dev/null
+++ b/libmprint/tests/test/test.out
@@ -0,0 +1 @@
+Hello, World!