summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libformat/.gitignore8
-rw-r--r--libformat/build/.gitignore2
-rw-r--r--libformat/build/bootstrap.build2
-rw-r--r--libformat/build/root.build8
-rw-r--r--libformat/buildfile12
-rw-r--r--libformat/libformat/.gitignore3
-rw-r--r--libformat/libformat/buildfile39
-rw-r--r--libformat/libformat/export.hxx18
-rw-r--r--libformat/libformat/format.cxx4
-rw-r--r--libformat/libformat/format.hxx6
-rw-r--r--libformat/libformat/version.hxx.in33
-rw-r--r--libformat/manifest1
-rw-r--r--libformat/tests/.gitignore7
-rw-r--r--libformat/tests/basics/buildfile3
-rw-r--r--libformat/tests/basics/driver.cxx14
-rw-r--r--libformat/tests/build/.gitignore2
-rw-r--r--libformat/tests/build/bootstrap.build4
-rw-r--r--libformat/tests/build/root.build6
-rw-r--r--libformat/tests/buildfile2
-rw-r--r--libformat/tests/test/buildfile4
-rw-r--r--libformat/tests/test/driver.cxx16
-rw-r--r--libformat/tests/test/test.out3
-rw-r--r--repositories.manifest2
23 files changed, 128 insertions, 71 deletions
diff --git a/libformat/.gitignore b/libformat/.gitignore
index abe2889..c3de2e7 100644
--- a/libformat/.gitignore
+++ b/libformat/.gitignore
@@ -1,6 +1,10 @@
+.bdep/
+
# Compiler/linker output.
#
*.d
+*.t
+*.i
*.ii
*.o
*.obj
@@ -9,9 +13,9 @@
*.a
*.lib
*.exp
+*.pdb
+*.ilk
*.exe
*.exe.dlls/
*.exe.manifest
*.pc
-
-version
diff --git a/libformat/build/.gitignore b/libformat/build/.gitignore
index 225c27f..4a730a3 100644
--- a/libformat/build/.gitignore
+++ b/libformat/build/.gitignore
@@ -1 +1,3 @@
config.build
+root/
+bootstrap/
diff --git a/libformat/build/bootstrap.build b/libformat/build/bootstrap.build
index b6e8537..3351dc4 100644
--- a/libformat/build/bootstrap.build
+++ b/libformat/build/bootstrap.build
@@ -2,6 +2,6 @@ project = libformat
using version
using config
-using dist
using test
+using dist
using install
diff --git a/libformat/build/root.build b/libformat/build/root.build
index 8ceadfa..9c83a8a 100644
--- a/libformat/build/root.build
+++ b/libformat/build/root.build
@@ -1,6 +1,12 @@
-cxx.std = 11
+cxx.std = latest
using cxx
hxx{*}: extension = hxx
+ixx{*}: extension = ixx
+txx{*}: extension = txx
cxx{*}: extension = cxx
+
+# The test target for cross-testing (running tests under Wine, etc).
+#
+test.target = $cxx.target
diff --git a/libformat/buildfile b/libformat/buildfile
index 04a951f..d8caddc 100644
--- a/libformat/buildfile
+++ b/libformat/buildfile
@@ -1,13 +1,5 @@
-./: libformat/ tests/ doc{version} file{manifest}
-
-# The version file is auto-generated (by the version module) from manifest.
-# Include it in distribution and don't remove when cleaning in src (so that
-# clean results in a state identical to distributed).
-#
-doc{version}: file{manifest}
-doc{version}: dist = true
-doc{version}: clean = ($src_root != $out_root)
+./: {*/ -build/} file{manifest}
# Don't install tests.
#
-dir{tests/}: install = false
+tests/: install = false
diff --git a/libformat/libformat/.gitignore b/libformat/libformat/.gitignore
new file mode 100644
index 0000000..0c9102a
--- /dev/null
+++ b/libformat/libformat/.gitignore
@@ -0,0 +1,3 @@
+# Generated version header.
+#
+version.hxx
diff --git a/libformat/libformat/buildfile b/libformat/libformat/buildfile
index fc342d4..96f7133 100644
--- a/libformat/libformat/buildfile
+++ b/libformat/libformat/buildfile
@@ -1,4 +1,27 @@
-lib{format}: {hxx cxx}{format} hxx{export}
+int_libs = # Interface dependencies.
+imp_libs = # Implementation dependencies.
+#import imp_libs += libhello%lib{hello}
+
+lib{format}: {hxx ixx txx cxx}{* -version} hxx{version} $imp_libs $int_libs
+
+# Include the generated version header into the distribution (so that we don't
+# pick up an installed one) and don't remove it when cleaning in src (so that
+# clean results in a state identical to distributed).
+#
+hxx{version}: in{version} $src_root/file{manifest}
+hxx{version}: dist = true
+hxx{version}: clean = ($src_root != $out_root)
+
+cxx.poptions =+ "-I$out_root" "-I$src_root"
+lib{format}: cxx.export.poptions = "-I$out_root" "-I$src_root"
+
+liba{format}: cxx.export.poptions += -DLIBFORMAT_STATIC
+libs{format}: cxx.export.poptions += -DLIBFORMAT_SHARED
+
+obja{*}: cxx.poptions += -DLIBFORMAT_STATIC_BUILD
+objs{*}: cxx.poptions += -DLIBFORMAT_SHARED_BUILD
+
+lib{format}: cxx.export.libs = $int_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.
@@ -8,14 +31,8 @@ if $version.pre_release
else
lib{format}: bin.lib.version = @"-$version.major.$version.minor"
-cxx.poptions =+ "-I$out_root" "-I$src_root"
-obja{*}: cxx.poptions += -DLIBFORMAT_STATIC_BUILD
-objs{*}: cxx.poptions += -DLIBFORMAT_SHARED_BUILD
-
-lib{format}: cxx.export.poptions = "-I$out_root" "-I$src_root"
-liba{format}: cxx.export.poptions += -DLIBFORMAT_STATIC
-libs{format}: cxx.export.poptions += -DLIBFORMAT_SHARED
-
-# Install into the libformat/ subdirectory of, say, /usr/include/.
+# Install into the libformat/ subdirectory of, say, /usr/include/
+# recreating subdirectories.
#
-{hxx ixx txx}{*}: install = include/$project/
+{hxx ixx txx}{*}: install = include/$project/
+{hxx ixx txx}{*}: install.subdirs = true
diff --git a/libformat/libformat/export.hxx b/libformat/libformat/export.hxx
index 125c9df..1691181 100644
--- a/libformat/libformat/export.hxx
+++ b/libformat/libformat/export.hxx
@@ -1,30 +1,28 @@
-// file: libformat/export.hxx -*- C++ -*-
-
#pragma once
// Normally we don't export class templates (but do complete specializations),
// inline functions, and classes with only inline member functions. Exporting
// classes that inherit from non-exported/imported bases (e.g., std::string)
// will end up badly. The only known workarounds are to not inherit or to not
-// export. Also, MinGW GCC doesn't like seeing non-exported function being
+// export. Also, MinGW GCC doesn't like seeing non-exported functions being
// used before their inline definition. The workaround is to reorder code. In
// the end it's all trial and error.
#if defined(LIBFORMAT_STATIC) // Using static.
-# define LIBFORMAT_EXPORT
+# define LIBFORMAT_SYMEXPORT
#elif defined(LIBFORMAT_STATIC_BUILD) // Building static.
-# define LIBFORMAT_EXPORT
+# define LIBFORMAT_SYMEXPORT
#elif defined(LIBFORMAT_SHARED) // Using shared.
# ifdef _WIN32
-# define LIBFORMAT_EXPORT __declspec(dllimport)
+# define LIBFORMAT_SYMEXPORT __declspec(dllimport)
# else
-# define LIBFORMAT_EXPORT
+# define LIBFORMAT_SYMEXPORT
# endif
#elif defined(LIBFORMAT_SHARED_BUILD) // Building shared.
# ifdef _WIN32
-# define LIBFORMAT_EXPORT __declspec(dllexport)
+# define LIBFORMAT_SYMEXPORT __declspec(dllexport)
# else
-# define LIBFORMAT_EXPORT
+# define LIBFORMAT_SYMEXPORT
# endif
#else
// If none of the above macros are defined, then we assume we are being used
@@ -32,5 +30,5 @@
// type. Note that this fallback works for both static and shared but in case
// of shared will be sub-optimal compared to having dllimport.
//
-# define LIBFORMAT_EXPORT // Using static or shared.
+# define LIBFORMAT_SYMEXPORT // Using static or shared.
#endif
diff --git a/libformat/libformat/format.cxx b/libformat/libformat/format.cxx
index 493f13c..de8a782 100644
--- a/libformat/libformat/format.cxx
+++ b/libformat/libformat/format.cxx
@@ -1,5 +1,3 @@
-// file: libformat/format.cxx -*- C++ -*-
-
#include <libformat/format.hxx>
#include <cctype> // to{upper,lower}()
@@ -10,7 +8,7 @@ using namespace std;
namespace format
{
string
- message (const string& g, const string& n, volume v)
+ format_hello (const string& g, const string& n, volume v)
{
string r (g);
diff --git a/libformat/libformat/format.hxx b/libformat/libformat/format.hxx
index c711c16..3641b67 100644
--- a/libformat/libformat/format.hxx
+++ b/libformat/libformat/format.hxx
@@ -1,5 +1,3 @@
-// file: libformat/format.hxx -*- C++ -*-
-
#pragma once
#include <string>
@@ -10,6 +8,6 @@ namespace format
{
enum class volume {quiet, normal, loud};
- LIBFORMAT_EXPORT std::string
- message (const std::string& greeting, const std::string& name, volume);
+ LIBFORMAT_SYMEXPORT std::string
+ format_hello (const std::string& greeting, const std::string& name, volume);
}
diff --git a/libformat/libformat/version.hxx.in b/libformat/libformat/version.hxx.in
new file mode 100644
index 0000000..eee04b1
--- /dev/null
+++ b/libformat/libformat/version.hxx.in
@@ -0,0 +1,33 @@
+#pragma once
+
+// The numeric version format is AAABBBCCCDDDE where:
+//
+// AAA - major version number
+// BBB - minor version number
+// CCC - bugfix version number
+// DDD - alpha / beta (DDD + 500) version number
+// E - final (0) / snapshot (1)
+//
+// When DDDE is not 0, 1 is subtracted from AAABBBCCC. For example:
+//
+// Version AAABBBCCCDDDE
+//
+// 0.1.0 0000010000000
+// 0.1.2 0000010010000
+// 1.2.3 0010020030000
+// 2.2.0-a.1 0020019990010
+// 3.0.0-b.2 0029999995020
+// 2.2.0-a.1.z 0020019990011
+//
+#define LIBFORMAT_VERSION $libformat.version.project_number$ULL
+#define LIBFORMAT_VERSION_STR "$libformat.version.project$"
+#define LIBFORMAT_VERSION_ID "$libformat.version.project_id$"
+
+#define LIBFORMAT_VERSION_MAJOR $libformat.version.major$
+#define LIBFORMAT_VERSION_MINOR $libformat.version.minor$
+#define LIBFORMAT_VERSION_PATCH $libformat.version.patch$
+
+#define LIBFORMAT_PRE_RELEASE $libformat.version.pre_release$
+
+#define LIBFORMAT_SNAPSHOT_SN $libformat.version.snapshot_sn$ULL
+#define LIBFORMAT_SNAPSHOT_ID "$libformat.version.snapshot_id$"
diff --git a/libformat/manifest b/libformat/manifest
index 4b3df97..6437d73 100644
--- a/libformat/manifest
+++ b/libformat/manifest
@@ -11,6 +11,5 @@ url: http://www.example.org/libformat
src-url: https://git.build2.org/cgit/hello/libformat/tree/libformat
email: hello-users@example.org
build-email: builds@build2.org
-requires: c++11
depends: * build2 >= 0.7.0-
depends: * bpkg >= 0.7.0-
diff --git a/libformat/tests/.gitignore b/libformat/tests/.gitignore
index e54525b..662178d 100644
--- a/libformat/tests/.gitignore
+++ b/libformat/tests/.gitignore
@@ -1 +1,8 @@
+# Test executables.
+#
driver
+
+# Testscript output directories (can be symlinks).
+#
+test
+test-*
diff --git a/libformat/tests/basics/buildfile b/libformat/tests/basics/buildfile
new file mode 100644
index 0000000..813cb7e
--- /dev/null
+++ b/libformat/tests/basics/buildfile
@@ -0,0 +1,3 @@
+import libs = libformat%lib{format}
+
+exe{driver}: {hxx ixx txx cxx}{*} $libs
diff --git a/libformat/tests/basics/driver.cxx b/libformat/tests/basics/driver.cxx
new file mode 100644
index 0000000..03faea7
--- /dev/null
+++ b/libformat/tests/basics/driver.cxx
@@ -0,0 +1,14 @@
+#include <cassert>
+
+#include <libformat/version.hxx>
+#include <libformat/format.hxx>
+
+using namespace std;
+using namespace format;
+
+int main ()
+{
+ assert (format_hello ("Hello", "World", volume::quiet) == "hello, World!");
+ assert (format_hello ("Hello", "World", volume::normal) == "Hello, World!");
+ assert (format_hello ("Hello", "World", volume::loud) == "HELLO, World!");
+}
diff --git a/libformat/tests/build/.gitignore b/libformat/tests/build/.gitignore
index 225c27f..4a730a3 100644
--- a/libformat/tests/build/.gitignore
+++ b/libformat/tests/build/.gitignore
@@ -1 +1,3 @@
config.build
+root/
+bootstrap/
diff --git a/libformat/tests/build/bootstrap.build b/libformat/tests/build/bootstrap.build
index 2c2de24..a07b5ea 100644
--- a/libformat/tests/build/bootstrap.build
+++ b/libformat/tests/build/bootstrap.build
@@ -1,5 +1,5 @@
-project = # Unnamed subproject.
+project = # Unnamed tests subproject.
using config
-using dist
using test
+using dist
diff --git a/libformat/tests/build/root.build b/libformat/tests/build/root.build
index a2ee38a..a67b2fe 100644
--- a/libformat/tests/build/root.build
+++ b/libformat/tests/build/root.build
@@ -1,14 +1,16 @@
-cxx.std = 11
+cxx.std = latest
using cxx
hxx{*}: extension = hxx
+ixx{*}: extension = ixx
+txx{*}: extension = txx
cxx{*}: extension = cxx
# Every exe{} in this subproject is by default a test.
#
exe{*}: test = true
-# Specify the test target for cross-testing.
+# The test target for cross-testing (running tests under Wine, etc).
#
test.target = $cxx.target
diff --git a/libformat/tests/buildfile b/libformat/tests/buildfile
index 1a8bcc9..aeeab15 100644
--- a/libformat/tests/buildfile
+++ b/libformat/tests/buildfile
@@ -1 +1 @@
-./: test/
+./: {*/ -build/}
diff --git a/libformat/tests/test/buildfile b/libformat/tests/test/buildfile
deleted file mode 100644
index e99af23..0000000
--- a/libformat/tests/test/buildfile
+++ /dev/null
@@ -1,4 +0,0 @@
-import libs = libformat%lib{format}
-
-exe{driver}: cxx{driver} $libs
-exe{driver}: file{test.out}: test.stdout = true
diff --git a/libformat/tests/test/driver.cxx b/libformat/tests/test/driver.cxx
deleted file mode 100644
index 1cf2959..0000000
--- a/libformat/tests/test/driver.cxx
+++ /dev/null
@@ -1,16 +0,0 @@
-// file: tests/test/driver.cxx -*- C++ -*-
-
-#include <iostream>
-
-#include <libformat/format.hxx>
-
-int
-main ()
-{
- using namespace std;
- using namespace format;
-
- cout << message ("Hello", "World", volume::quiet) << endl;
- cout << message ("Hello", "World", volume::normal) << endl;
- cout << message ("Hello", "World", volume::loud) << endl;
-}
diff --git a/libformat/tests/test/test.out b/libformat/tests/test/test.out
deleted file mode 100644
index 7ce133b..0000000
--- a/libformat/tests/test/test.out
+++ /dev/null
@@ -1,3 +0,0 @@
-hello, World!
-Hello, World!
-HELLO, World!
diff --git a/repositories.manifest b/repositories.manifest
new file mode 100644
index 0000000..aee9dba
--- /dev/null
+++ b/repositories.manifest
@@ -0,0 +1,2 @@
+: 1
+summary: libformat project repository