aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-07-19 17:50:36 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-07-19 17:50:36 +0200
commita0f96b95900108705261881b164d779e2db5b824 (patch)
tree108e595a366ed83f6ae690f9f8980f76d71bd029
Initial implementation
-rw-r--r--.gitignore18
-rw-r--r--INSTALL6
-rw-r--r--LICENSE20
-rw-r--r--NEWS3
-rw-r--r--README15
-rw-r--r--build/.gitignore1
-rw-r--r--build/bootstrap.build11
-rw-r--r--build/export.build10
-rw-r--r--build/root.build12
-rw-r--r--buildfile65
-rw-r--r--dummy.cxx5
-rw-r--r--manifest17
-rw-r--r--std-core.mxx41
-rw-r--r--std-io.mxx28
-rw-r--r--tests/.gitignore1
-rw-r--r--tests/build/.gitignore1
-rw-r--r--tests/build/bootstrap.build9
-rw-r--r--tests/build/root.build17
-rw-r--r--tests/buildfile8
-rw-r--r--tests/driver.cxx14
-rw-r--r--tests/test.out1
21 files changed, 303 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..0067877
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,18 @@
+# Compiler/linker output.
+#
+*.d
+*.ii
+*.o
+*.obj
+*.nms
+*.pcm
+*.ifc
+*.so
+*.dll
+*.a
+*.lib
+*.exp
+*.exe
+*.exe.dlls/
+*.exe.manifest
+
diff --git a/INSTALL b/INSTALL
new file mode 100644
index 0000000..1fbd2af
--- /dev/null
+++ b/INSTALL
@@ -0,0 +1,6 @@
+The easiest way to build this package is with the bpkg package manager:
+
+$ bpkg build libstd-modules
+
+But if you don't want to use the package manager, then you can also build it
+manually using the standard build2 build system.
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..91c0877
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,20 @@
+Copyright (c) 2014-2017 Code Synthesis Ltd
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/NEWS b/NEWS
new file mode 100644
index 0000000..b6532fc
--- /dev/null
+++ b/NEWS
@@ -0,0 +1,3 @@
+Version 0.1.0
+
+ * First public release.
diff --git a/README b/README
new file mode 100644
index 0000000..5e815e4
--- /dev/null
+++ b/README
@@ -0,0 +1,15 @@
+This package contains the module interface units for the standard C++ library
+(approximately) as proposed in P0581R0. It is maintained as part of the build2
+project:
+
+https://build2.org/
+
+See the NEWS file for the user-visible changes from the previous release.
+
+See the LICENSE file for the distribution conditions.
+
+See the INSTALL file for the prerequisites and installation instructions.
+
+Send questions, bug reports, or any other feedback to the users@build2.org
+mailing list. You can post without subscribing. See https://lists.build2.org
+for searchable archives, posting guidelines, etc.
diff --git a/build/.gitignore b/build/.gitignore
new file mode 100644
index 0000000..225c27f
--- /dev/null
+++ b/build/.gitignore
@@ -0,0 +1 @@
+config.build
diff --git a/build/bootstrap.build b/build/bootstrap.build
new file mode 100644
index 0000000..3b0f1ae
--- /dev/null
+++ b/build/bootstrap.build
@@ -0,0 +1,11 @@
+# file : build/bootstrap.build
+# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd
+# license : MIT; see accompanying LICENSE file
+
+project = libstd-modules
+
+using version
+using config
+using dist
+using test
+using install
diff --git a/build/export.build b/build/export.build
new file mode 100644
index 0000000..8ce55ab
--- /dev/null
+++ b/build/export.build
@@ -0,0 +1,10 @@
+# file : build/export.build
+# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd
+# license : MIT; see accompanying LICENSE file
+
+$out_root/:
+{
+ include buildfile
+}
+
+export $out_root/liba{std-modules}
diff --git a/build/root.build b/build/root.build
new file mode 100644
index 0000000..7b4a007
--- /dev/null
+++ b/build/root.build
@@ -0,0 +1,12 @@
+# file : build/bootstrap.build
+# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd
+# license : MIT; see accompanying LICENSE file
+
+cxx.std = experimental
+
+using cxx
+
+assert $cxx.features.modules 'c++ compiler does not support modules'
+
+mxx{*}: extension = mxx
+cxx{*}: extension = cxx
diff --git a/buildfile b/buildfile
new file mode 100644
index 0000000..0efdd29
--- /dev/null
+++ b/buildfile
@@ -0,0 +1,65 @@
+# file : buildfile
+# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd
+# license : MIT; see accompanying LICENSE file
+
+# 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).
+#
+./: liba{std-modules} tests/ doc{INSTALL LICENSE NEWS README version} \
+ file{manifest}
+
+doc{version}: file{manifest} # Generated by the version module.
+doc{version}: dist = true
+
+# Don't install tests or the INSTALL file.
+#
+dir{tests/}: install = false
+doc{INSTALL}@./: install = false
+
+# Building of the modules gets rather compiler-specific.
+#
+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}
+
+ # 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
+
+# Clang 5.0 with libc++ (sometimes) needs it -- go figure.
+#
+if ($cxx.target.class != "windows")
+ cxx.libs += -lpthread
+
+liba{std-modules}: bmia{$core $io}
+
+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
diff --git a/dummy.cxx b/dummy.cxx
new file mode 100644
index 0000000..fabedbf
--- /dev/null
+++ b/dummy.cxx
@@ -0,0 +1,5 @@
+// file : dummy.cxx -*- C++ -*-
+// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd
+// license : MIT; see accompanying LICENSE file
+
+// Dummy translation unit used to create dummy std.lib for VC.
diff --git a/manifest b/manifest
new file mode 100644
index 0000000..b26bb9e
--- /dev/null
+++ b/manifest
@@ -0,0 +1,17 @@
+: 1
+name: libstd-modules
+version: 0.1.0-a.0.z
+summary: Standard C++ library module interfaces
+license: MIT
+tags: c++, modules, standard, library, std.core, std.io
+description-file: README
+changes-file: NEWS
+url: https://build2.org
+email: users@build2.org
+build-email: builds@build2.org
+build-exclude: * ; Requires C++ modules support
+build-include: *-msvc_15*
+build-include: *-clang_5.0*
+requires: c++20
+depends: * build2 >= 0.6.0-
+depends: * bpkg >= 0.6.0-
diff --git a/std-core.mxx b/std-core.mxx
new file mode 100644
index 0000000..6ee4a9e
--- /dev/null
+++ b/std-core.mxx
@@ -0,0 +1,41 @@
+// file : std-core.mxx -*- C++ -*-
+// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd
+// license : MIT; see accompanying LICENSE file
+
+export module std.core;
+
+export
+{
+#include <cstddef>
+#include <cstdint>
+#include <cstdlib>
+
+#include <utility>
+
+#include <exception>
+#include <stdexcept>
+}
+
+export
+{
+#include <iterator>
+#include <algorithm>
+
+#include <string>
+#include <cstring> // @@ Not in the proposal.
+
+#include <vector>
+}
+
+#if defined(_MSC_VER) || defined(__clang__)
+export
+{
+#include <cctype>
+#include <iosfwd>
+#include <istream>
+#include <ostream>
+#include <iostream>
+#include <sstream>
+#include <fstream>
+}
+#endif
diff --git a/std-io.mxx b/std-io.mxx
new file mode 100644
index 0000000..5370817
--- /dev/null
+++ b/std-io.mxx
@@ -0,0 +1,28 @@
+// file : std-io.mxx -*- C++ -*-
+// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd
+// license : MIT; see accompanying LICENSE file
+
+export module std.io;
+
+#ifdef _MSC_VER
+
+export import std.core;
+
+#elif defined(__clang__)
+// Empty: can't handle the below and doesn't suppor re-export.
+#else
+
+import std.core;
+
+export
+{
+#include <cctype>
+#include <iosfwd>
+#include <istream>
+#include <ostream>
+#include <iostream>
+#include <sstream>
+#include <fstream>
+}
+
+#endif
diff --git a/tests/.gitignore b/tests/.gitignore
new file mode 100644
index 0000000..e54525b
--- /dev/null
+++ b/tests/.gitignore
@@ -0,0 +1 @@
+driver
diff --git a/tests/build/.gitignore b/tests/build/.gitignore
new file mode 100644
index 0000000..225c27f
--- /dev/null
+++ b/tests/build/.gitignore
@@ -0,0 +1 @@
+config.build
diff --git a/tests/build/bootstrap.build b/tests/build/bootstrap.build
new file mode 100644
index 0000000..355a05a
--- /dev/null
+++ b/tests/build/bootstrap.build
@@ -0,0 +1,9 @@
+# file : tests/build/bootstrap.build
+# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd
+# license : MIT; see accompanying LICENSE file
+
+project = # Unnamed subproject.
+
+using config
+using dist
+using test
diff --git a/tests/build/root.build b/tests/build/root.build
new file mode 100644
index 0000000..42d528e
--- /dev/null
+++ b/tests/build/root.build
@@ -0,0 +1,17 @@
+# file : tests/build/root.build
+# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd
+# license : MIT; see accompanying LICENSE file
+
+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/tests/buildfile b/tests/buildfile
new file mode 100644
index 0000000..881153e
--- /dev/null
+++ b/tests/buildfile
@@ -0,0 +1,8 @@
+# file : tests/buildfile
+# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd
+# license : MIT; see accompanying LICENSE file
+
+import libs = libstd-modules%liba{std-modules}
+
+exe{driver}: cxx{driver} $libs
+exe{driver}: test.output = test.out
diff --git a/tests/driver.cxx b/tests/driver.cxx
new file mode 100644
index 0000000..64a5fb1
--- /dev/null
+++ b/tests/driver.cxx
@@ -0,0 +1,14 @@
+// file : tests/driver.cxx -*- C++ -*-
+// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd
+// license : MIT; see accompanying LICENSE file
+
+import std.core;
+import std.io;
+
+using namespace std;
+
+int
+main ()
+{
+ cout << string ("Hello, World!") << endl;
+}
diff --git a/tests/test.out b/tests/test.out
new file mode 100644
index 0000000..8ab686e
--- /dev/null
+++ b/tests/test.out
@@ -0,0 +1 @@
+Hello, World!