From 01399cea3ff5d5d64c987d06c882a1c7c9cdd878 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 20 Jul 2017 08:55:37 +0200 Subject: Add modularized version --- libmprint/.gitignore | 19 +++++++++++++++++++ libmprint/build/.gitignore | 1 + libmprint/build/bootstrap.build | 7 +++++++ libmprint/build/export.build | 6 ++++++ libmprint/build/root.build | 10 ++++++++++ libmprint/buildfile | 8 ++++++++ libmprint/libmprint/buildfile | 15 +++++++++++++++ libmprint/libmprint/print.cxx | 20 ++++++++++++++++++++ libmprint/libmprint/print.mxx | 11 +++++++++++ libmprint/manifest | 21 +++++++++++++++++++++ libmprint/tests/.gitignore | 1 + libmprint/tests/build/.gitignore | 1 + libmprint/tests/build/bootstrap.build | 5 +++++ libmprint/tests/build/root.build | 13 +++++++++++++ libmprint/tests/buildfile | 1 + libmprint/tests/test/buildfile | 5 +++++ libmprint/tests/test/driver.cxx | 10 ++++++++++ libmprint/tests/test/test.out | 1 + 18 files changed, 155 insertions(+) create mode 100644 libmprint/.gitignore create mode 100644 libmprint/build/.gitignore create mode 100644 libmprint/build/bootstrap.build create mode 100644 libmprint/build/export.build create mode 100644 libmprint/build/root.build create mode 100644 libmprint/buildfile create mode 100644 libmprint/libmprint/buildfile create mode 100644 libmprint/libmprint/print.cxx create mode 100644 libmprint/libmprint/print.mxx create mode 100644 libmprint/manifest create mode 100644 libmprint/tests/.gitignore create mode 100644 libmprint/tests/build/.gitignore create mode 100644 libmprint/tests/build/bootstrap.build create mode 100644 libmprint/tests/build/root.build create mode 100644 libmprint/tests/buildfile create mode 100644 libmprint/tests/test/buildfile create mode 100644 libmprint/tests/test/driver.cxx create mode 100644 libmprint/tests/test/test.out (limited to 'libmprint') 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! -- cgit v1.1