diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2016-08-30 16:50:01 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2016-08-30 18:14:12 +0200 |
commit | bb6a97a8f3e4e046442eaf8814b30d9c9995bfd2 (patch) | |
tree | 1334a6d70ca46a3955ea4895a0f2522992d10444 | |
parent | 45afda9752d8d30bf3c606d63f7a718b32ebe7c8 (diff) |
Build infrastructure update
-rw-r--r-- | .gitignore | 12 | ||||
-rw-r--r-- | INSTALL | 1 | ||||
-rw-r--r-- | build/bootstrap.build | 20 | ||||
-rw-r--r-- | build/root.build | 8 | ||||
-rw-r--r-- | buildfile | 7 | ||||
-rw-r--r-- | hello/buildfile | 23 | ||||
-rw-r--r-- | hello/export | 36 | ||||
-rw-r--r-- | hello/hello | 21 | ||||
-rw-r--r-- | hello/hello.cxx | 5 | ||||
-rw-r--r-- | manifest | 1 | ||||
-rw-r--r-- | tests/build/root.build | 4 |
11 files changed, 111 insertions, 27 deletions
@@ -1,5 +1,13 @@ -*.o +# Compiler/linker output. +# *.d +*.o +*.obj *.so +*.dll *.a -core +*.lib +*.exp +*.exe +*.exe.dlls/ +*.exe.manifest @@ -0,0 +1 @@ +Just use build2, bro. diff --git a/build/bootstrap.build b/build/bootstrap.build index d0ea1f7..612be77 100644 --- a/build/bootstrap.build +++ b/build/bootstrap.build @@ -1,15 +1,21 @@ project = libhello + +using build@0.4.0-a1 + version = 1.1.1 -revision = 0 +abi_major = 1 +abi_minor = 1 +abi_patch = 1 +abi_prerelease = false -using config -using dist -using test -using install +revision = 0 dist.package = $project-$version if ($revision != 0) -{ dist.package += +$revision -} + +using config +using dist +using test +using install diff --git a/build/root.build b/build/root.build index ebe16d5..4f70114 100644 --- a/build/root.build +++ b/build/root.build @@ -1,10 +1,6 @@ +cxx.std = 11 + using cxx hxx{*}: extension = cxx{*}: extension = cxx - -cxx.std = 11 - -# Don't install tests. -# -tests/: install = false @@ -1,3 +1,8 @@ d = hello/ tests/ -./: $d doc{version} file{manifest} +./: $d doc{INSTALL version} file{manifest} include $d + +# Don't install tests or the INSTALL file. +# +dir{tests/}: install = false +doc{INSTALL}@./: install = false diff --git a/hello/buildfile b/hello/buildfile index c18fa98..8807f1b 100644 --- a/hello/buildfile +++ b/hello/buildfile @@ -1,11 +1,26 @@ -import libs = libformat%lib{format} -import libs += libprint%lib{print} +import int_libs = libformat%lib{format} +import imp_libs = libprint%lib{print} -lib{hello}: {hxx cxx}{hello} $libs +lib{hello}: {hxx cxx}{hello} hxx{export} $imp_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. +# +if $abi_prerelease + lib{hello}: bin.lib.version = @-$version +else + lib{hello}: bin.lib.version = @-$abi_major.$abi_minor cxx.poptions += -I$src_root +obja{*}: cxx.poptions += -DLIBHELLO_STATIC_BUILD +objs{*}: cxx.poptions += -DLIBHELLO_SHARED_BUILD + lib{hello}: cxx.export.poptions = -I$src_root +liba{hello}: cxx.export.poptions += -DLIBHELLO_STATIC +libs{hello}: cxx.export.poptions += -DLIBHELLO_SHARED + +lib{hello}: cxx.export.libs = $int_libs # Install into the hello/ subdirectory of, say, /usr/include/. # -install.include = $install.include/hello +install.include = $install.include/hello/ diff --git a/hello/export b/hello/export new file mode 100644 index 0000000..18f4968 --- /dev/null +++ b/hello/export @@ -0,0 +1,36 @@ +// file: hello/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(LIBHELLO_STATIC) // Using static. +# define LIBHELLO_EXPORT +#elif defined(LIBHELLO_STATIC_BUILD) // Building static. +# define LIBHELLO_EXPORT +#elif defined(LIBHELLO_SHARED) // Using shared. +# ifdef _WIN32 +# define LIBHELLO_EXPORT __declspec(dllimport) +# else +# define LIBHELLO_EXPORT +# endif +#elif defined(LIBHELLO_SHARED_BUILD) // Building shared. +# ifdef _WIN32 +# define LIBHELLO_EXPORT __declspec(dllexport) +# else +# define LIBHELLO_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 LIBHELLO_EXPORT // Using static or shared. +#endif diff --git a/hello/hello b/hello/hello index 4f85114..75a47a0 100644 --- a/hello/hello +++ b/hello/hello @@ -4,8 +4,25 @@ #include <string> +#include <format/format> + +#include <hello/export> + namespace hello { - void - say (const std::string& name); + // If you compare this interface to version 1.0, then you will notice that + // while it is API/source-compatible (the signature of say() is unchanged) + // it is not ABI/binary-compatible (say() is now inline). + // + // Notice also that inline say() calls format() which means libformat is an + // interface dependency of libhello. + + LIBHELLO_EXPORT void + say_formatted (const std::string& message); + + inline void + say (const std::string& name) + { + say_formatted (format ("Hello", name)); + } } diff --git a/hello/hello.cxx b/hello/hello.cxx index 46d9f6e..8fdd5a6 100644 --- a/hello/hello.cxx +++ b/hello/hello.cxx @@ -2,7 +2,6 @@ #include <hello/hello> -#include <format/format> #include <print/print> using namespace std; @@ -10,8 +9,8 @@ using namespace std; namespace hello { void - say (const string& n) + say_formatted (const string& m) { - print (format ("Hello", n)); + print (m); } } @@ -11,5 +11,6 @@ goal is to show a canonical build2/bpkg project/package. url: http://www.example.org/libhello email: hello-users@example.org requires: c++11 +requires: build2 >= 0.4.0 depends: libformat [1.0.0 2.0.0-); compatible with libformat-1.X.Y depends: libprint [1.0.0 2.0.0-); compatible with libprint-1.X.Y diff --git a/tests/build/root.build b/tests/build/root.build index 4bf103e..1f7c350 100644 --- a/tests/build/root.build +++ b/tests/build/root.build @@ -1,10 +1,10 @@ +cxx.std = 11 + using cxx hxx{*}: extension = cxx{*}: extension = cxx -cxx.std = 11 - # Every exe{} in this subproject is by default a test. # exe{*}: test = true |