summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore12
-rw-r--r--build/bootstrap.build19
-rw-r--r--build/root.build4
-rw-r--r--format/buildfile17
-rw-r--r--format/export36
-rw-r--r--format/format4
-rw-r--r--manifest1
7 files changed, 80 insertions, 13 deletions
diff --git a/.gitignore b/.gitignore
index e062bf3..01994ef 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,13 @@
-*.o
+# Compiler/linker output.
+#
*.d
+*.o
+*.obj
*.so
+*.dll
*.a
-core
+*.lib
+*.exp
+*.exe
+*.exe.dlls/
+*.exe.manifest
diff --git a/build/bootstrap.build b/build/bootstrap.build
index 9101716..4fab770 100644
--- a/build/bootstrap.build
+++ b/build/bootstrap.build
@@ -1,14 +1,21 @@
project = libformat
+
+using build@0.4.0-a1
+
version = 1.0.0
-revision = 0
-using config
-using dist
-using install
+abi_major = 1
+abi_minor = 0
+abi_patch = 0
+abi_prerelease = false
+
+revision = 0
dist.package = $project-$version
if ($revision != 0)
-{
dist.package += +$revision
-}
+
+using config
+using dist
+using install
diff --git a/build/root.build b/build/root.build
index 9ade644..4f70114 100644
--- a/build/root.build
+++ b/build/root.build
@@ -1,6 +1,6 @@
+cxx.std = 11
+
using cxx
hxx{*}: extension =
cxx{*}: extension = cxx
-
-cxx.std = 11
diff --git a/format/buildfile b/format/buildfile
index 4edb840..5e86503 100644
--- a/format/buildfile
+++ b/format/buildfile
@@ -1,8 +1,21 @@
-lib{format}: {hxx cxx}{format}
+lib{format}: {hxx cxx}{format} hxx{export}
+
+# 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 $abi_prerelease
+ lib{format}: bin.lib.version = @-$version
+else
+ lib{format}: bin.lib.version = @-$abi_major.$abi_minor
cxx.poptions += -I$src_root
+obja{*}: cxx.poptions += -DLIBFORMAT_STATIC_BUILD
+objs{*}: cxx.poptions += -DLIBFORMAT_SHARED_BUILD
+
lib{format}: cxx.export.poptions = -I$src_root
+liba{format}: cxx.export.poptions += -DLIBFORMAT_STATIC
+libs{format}: cxx.export.poptions += -DLIBFORMAT_SHARED
# Install into the format/ subdirectory of, say, /usr/include/.
#
-install.include = $install.include/format
+install.include = $install.include/format/
diff --git a/format/export b/format/export
new file mode 100644
index 0000000..39a37da
--- /dev/null
+++ b/format/export
@@ -0,0 +1,36 @@
+// file: format/export -*- 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
+// 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
+#elif defined(LIBFORMAT_STATIC_BUILD) // Building static.
+# define LIBFORMAT_EXPORT
+#elif defined(LIBFORMAT_SHARED) // Using shared.
+# ifdef _WIN32
+# define LIBFORMAT_EXPORT __declspec(dllimport)
+# else
+# define LIBFORMAT_EXPORT
+# endif
+#elif defined(LIBFORMAT_SHARED_BUILD) // Building shared.
+# ifdef _WIN32
+# define LIBFORMAT_EXPORT __declspec(dllexport)
+# else
+# define LIBFORMAT_EXPORT
+# endif
+#else
+// If none of the above macros are defined, then we assume we are being used
+// by some third-party build system that cannot/doesn't signal the library
+// 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.
+#endif
diff --git a/format/format b/format/format
index 6c4d5f8..69350b0 100644
--- a/format/format
+++ b/format/format
@@ -4,5 +4,7 @@
#include <string>
-std::string
+#include <format/export>
+
+LIBFORMAT_EXPORT std::string
format (const std::string& greeting, const std::string& name);
diff --git a/manifest b/manifest
index 7083f18..1440057 100644
--- a/manifest
+++ b/manifest
@@ -10,3 +10,4 @@ A simple library that implements the "Hello World" formatting in C++.
url: http://www.example.org/libformat
email: hello-users@example.org
requires: c++11
+requires: build2 >= 0.4.0