From 4429bd6724a4668464e8a7920e3c77860b127678 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 4 May 2018 16:16:41 +0200 Subject: Regenerate libhello using bdep-new --- libhello/.gitignore | 8 ++++++-- libhello/INSTALL | 1 - libhello/build/.gitignore | 2 ++ libhello/build/bootstrap.build | 2 +- libhello/build/root.build | 8 +++++++- libhello/buildfile | 15 +++----------- libhello/libhello/.gitignore | 3 +++ libhello/libhello/buildfile | 39 +++++++++++++++++++++++------------- libhello/libhello/export.hxx | 18 ++++++++--------- libhello/libhello/hello.cxx | 6 ++---- libhello/libhello/hello.hxx | 22 +++++++++++--------- libhello/libhello/version.hxx.in | 33 ++++++++++++++++++++++++++++++ libhello/manifest | 5 ++--- libhello/tests/.gitignore | 7 +++++++ libhello/tests/basics/buildfile | 3 +++ libhello/tests/basics/driver.cxx | 33 ++++++++++++++++++++++++++++++ libhello/tests/build/.gitignore | 2 ++ libhello/tests/build/bootstrap.build | 4 ++-- libhello/tests/build/root.build | 6 ++++-- libhello/tests/buildfile | 2 +- libhello/tests/test/buildfile | 4 ---- libhello/tests/test/driver.cxx | 14 ------------- libhello/tests/test/test.out | 3 --- repositories.manifest | 11 +++++----- 24 files changed, 162 insertions(+), 89 deletions(-) delete mode 100644 libhello/INSTALL create mode 100644 libhello/libhello/.gitignore create mode 100644 libhello/libhello/version.hxx.in create mode 100644 libhello/tests/basics/buildfile create mode 100644 libhello/tests/basics/driver.cxx delete mode 100644 libhello/tests/test/buildfile delete mode 100644 libhello/tests/test/driver.cxx delete mode 100644 libhello/tests/test/test.out diff --git a/libhello/.gitignore b/libhello/.gitignore index abe2889..c3de2e7 100644 --- a/libhello/.gitignore +++ b/libhello/.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/libhello/INSTALL b/libhello/INSTALL deleted file mode 100644 index 485b10f..0000000 --- a/libhello/INSTALL +++ /dev/null @@ -1 +0,0 @@ -Just use build2, bro. diff --git a/libhello/build/.gitignore b/libhello/build/.gitignore index 225c27f..4a730a3 100644 --- a/libhello/build/.gitignore +++ b/libhello/build/.gitignore @@ -1 +1,3 @@ config.build +root/ +bootstrap/ diff --git a/libhello/build/bootstrap.build b/libhello/build/bootstrap.build index 1ff153d..adf8e92 100644 --- a/libhello/build/bootstrap.build +++ b/libhello/build/bootstrap.build @@ -2,6 +2,6 @@ project = libhello using version using config -using dist using test +using dist using install diff --git a/libhello/build/root.build b/libhello/build/root.build index 8ceadfa..9c83a8a 100644 --- a/libhello/build/root.build +++ b/libhello/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/libhello/buildfile b/libhello/buildfile index 04bf55d..d8caddc 100644 --- a/libhello/buildfile +++ b/libhello/buildfile @@ -1,14 +1,5 @@ -./: libhello/ tests/ doc{INSTALL version} file{manifest} +./: {*/ -build/} 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). +# Don't install tests. # -doc{version}: file{manifest} -doc{version}: dist = true -doc{version}: clean = ($src_root != $out_root) - -# Don't install tests or the INSTALL file. -# -dir{tests/}: install = false -doc{INSTALL}@./: install = false +tests/: install = false diff --git a/libhello/libhello/.gitignore b/libhello/libhello/.gitignore new file mode 100644 index 0000000..0c9102a --- /dev/null +++ b/libhello/libhello/.gitignore @@ -0,0 +1,3 @@ +# Generated version header. +# +version.hxx diff --git a/libhello/libhello/buildfile b/libhello/libhello/buildfile index 4b3ab81..4322117 100644 --- a/libhello/libhello/buildfile +++ b/libhello/libhello/buildfile @@ -1,26 +1,37 @@ -import int_libs = libformat%lib{format} -import imp_libs = libprint%lib{print} +import int_libs = libformat%lib{format} # Interface dependency. +import imp_libs = libprint%lib{print} # Implementation dependency. -lib{hello}: {hxx cxx}{hello} hxx{export} $imp_libs $int_libs +lib{hello}: {hxx ixx txx cxx}{* -version} hxx{version} $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. +# 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). # -if $version.pre_release - lib{hello}: bin.lib.version = @"-$version.project_id" -else - lib{hello}: bin.lib.version = @"-$version.major.$version.minor" +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" -obja{*}: cxx.poptions += -DLIBHELLO_STATIC_BUILD -objs{*}: cxx.poptions += -DLIBHELLO_SHARED_BUILD - lib{hello}: cxx.export.poptions = "-I$out_root" "-I$src_root" + liba{hello}: cxx.export.poptions += -DLIBHELLO_STATIC libs{hello}: cxx.export.poptions += -DLIBHELLO_SHARED +obja{*}: cxx.poptions += -DLIBHELLO_STATIC_BUILD +objs{*}: cxx.poptions += -DLIBHELLO_SHARED_BUILD + lib{hello}: cxx.export.libs = $int_libs -# Install into the libhello/ subdirectory of, say, /usr/include/. +# 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{hello}: bin.lib.version = @"-$version.project_id" +else + lib{hello}: bin.lib.version = @"-$version.major.$version.minor" + +# Install into the libhello/ 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/libhello/libhello/export.hxx b/libhello/libhello/export.hxx index e6c723e..576543d 100644 --- a/libhello/libhello/export.hxx +++ b/libhello/libhello/export.hxx @@ -1,30 +1,28 @@ -// file: libhello/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(LIBHELLO_STATIC) // Using static. -# define LIBHELLO_EXPORT +# define LIBHELLO_SYMEXPORT #elif defined(LIBHELLO_STATIC_BUILD) // Building static. -# define LIBHELLO_EXPORT +# define LIBHELLO_SYMEXPORT #elif defined(LIBHELLO_SHARED) // Using shared. # ifdef _WIN32 -# define LIBHELLO_EXPORT __declspec(dllimport) +# define LIBHELLO_SYMEXPORT __declspec(dllimport) # else -# define LIBHELLO_EXPORT +# define LIBHELLO_SYMEXPORT # endif #elif defined(LIBHELLO_SHARED_BUILD) // Building shared. # ifdef _WIN32 -# define LIBHELLO_EXPORT __declspec(dllexport) +# define LIBHELLO_SYMEXPORT __declspec(dllexport) # else -# define LIBHELLO_EXPORT +# define LIBHELLO_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 LIBHELLO_EXPORT // Using static or shared. +# define LIBHELLO_SYMEXPORT // Using static or shared. #endif diff --git a/libhello/libhello/hello.cxx b/libhello/libhello/hello.cxx index ee5c555..f9e60bd 100644 --- a/libhello/libhello/hello.cxx +++ b/libhello/libhello/hello.cxx @@ -1,5 +1,3 @@ -// file: libhello/hello.cxx -*- C++ -*- - #include #include @@ -9,8 +7,8 @@ using namespace std; namespace hello { void - say_formatted (const string& m) + say_hello_formatted (ostream& o, const string& h) { - print::to_stdout (m); + print::print_hello (o, h); } } diff --git a/libhello/libhello/hello.hxx b/libhello/libhello/hello.hxx index d9e41d9..f0fc49e 100644 --- a/libhello/libhello/hello.hxx +++ b/libhello/libhello/hello.hxx @@ -1,7 +1,6 @@ -// file: libhello/hello.hxx -*- C++ -*- - #pragma once +#include #include #include @@ -12,18 +11,21 @@ namespace hello { // If you compare this interface to version 1.0, then you will notice that // while it is API/source-compatible (the call via the old signature of - // say() is still valid) it is not ABI/binary-compatible (say() now has an - // extra argument and is inline). + // say_hello() is still valid) it is not ABI/binary-compatible (say_hello() + // now has an extra argument and is inline). // - // Notice also that inline say() now uses a type and calls a function from - // format which means libformat is an "interface dependency" of libhello. + // Notice also that say_hello() now uses a type and calls (from its inline + // implementation) a function from format which means libformat is an + // "interface dependency" of libhello. - LIBHELLO_EXPORT void - say_formatted (const std::string& message); + LIBHELLO_SYMEXPORT void + say_hello_formatted (std::ostream&, const std::string& hello); inline void - say (const std::string& name, format::volume v = format::volume::normal) + say_hello (std::ostream& o, + const std::string& name, + format::volume v = format::volume::normal) { - say_formatted (format::message ("Hello", name, v)); + say_hello_formatted (o, format::format_hello ("Hello", name, v)); } } diff --git a/libhello/libhello/version.hxx.in b/libhello/libhello/version.hxx.in new file mode 100644 index 0000000..b94c05a --- /dev/null +++ b/libhello/libhello/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 LIBHELLO_VERSION $libhello.version.project_number$ULL +#define LIBHELLO_VERSION_STR "$libhello.version.project$" +#define LIBHELLO_VERSION_ID "$libhello.version.project_id$" + +#define LIBHELLO_VERSION_MAJOR $libhello.version.major$ +#define LIBHELLO_VERSION_MINOR $libhello.version.minor$ +#define LIBHELLO_VERSION_PATCH $libhello.version.patch$ + +#define LIBHELLO_PRE_RELEASE $libhello.version.pre_release$ + +#define LIBHELLO_SNAPSHOT_SN $libhello.version.snapshot_sn$ULL +#define LIBHELLO_SNAPSHOT_ID "$libhello.version.snapshot_id$" diff --git a/libhello/manifest b/libhello/manifest index db0d981..ff95657 100644 --- a/libhello/manifest +++ b/libhello/manifest @@ -12,8 +12,7 @@ url: http://www.example.org/libhello src-url: https://git.build2.org/cgit/hello/libhello/tree/libhello email: hello-users@example.org build-email: builds@build2.org -requires: c++11 depends: * build2 >= 0.7.0- depends: * bpkg >= 0.7.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 +depends: libformat [1.0.0 2.0.0-); @@ TMP ^1.0.0 +depends: libprint [1.0.0 2.0.0-); @@ TMP ^1.0.0 diff --git a/libhello/tests/.gitignore b/libhello/tests/.gitignore index e54525b..662178d 100644 --- a/libhello/tests/.gitignore +++ b/libhello/tests/.gitignore @@ -1 +1,8 @@ +# Test executables. +# driver + +# Testscript output directories (can be symlinks). +# +test +test-* diff --git a/libhello/tests/basics/buildfile b/libhello/tests/basics/buildfile new file mode 100644 index 0000000..a436a8c --- /dev/null +++ b/libhello/tests/basics/buildfile @@ -0,0 +1,3 @@ +import libs = libhello%lib{hello} + +exe{driver}: {hxx ixx txx cxx}{*} $libs diff --git a/libhello/tests/basics/driver.cxx b/libhello/tests/basics/driver.cxx new file mode 100644 index 0000000..2cef70b --- /dev/null +++ b/libhello/tests/basics/driver.cxx @@ -0,0 +1,33 @@ +#include +#include + +#include +#include + +using namespace std; +using namespace hello; + +int main () +{ + // Basics. + // + { + ostringstream o; + say_hello_formatted (o, "Hi, World!"); + assert (o.str () == "Hi, World!\n"); + } + + { + ostringstream o; + say_hello (o, "World"); + assert (o.str () == "Hello, World!\n"); + } + + // Volume. + // + { + ostringstream o; + say_hello (o, "World", format::volume::loud); + assert (o.str () == "HELLO, World!\n"); + } +} diff --git a/libhello/tests/build/.gitignore b/libhello/tests/build/.gitignore index 225c27f..4a730a3 100644 --- a/libhello/tests/build/.gitignore +++ b/libhello/tests/build/.gitignore @@ -1 +1,3 @@ config.build +root/ +bootstrap/ diff --git a/libhello/tests/build/bootstrap.build b/libhello/tests/build/bootstrap.build index 2c2de24..a07b5ea 100644 --- a/libhello/tests/build/bootstrap.build +++ b/libhello/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/libhello/tests/build/root.build b/libhello/tests/build/root.build index a2ee38a..a67b2fe 100644 --- a/libhello/tests/build/root.build +++ b/libhello/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/libhello/tests/buildfile b/libhello/tests/buildfile index 1a8bcc9..aeeab15 100644 --- a/libhello/tests/buildfile +++ b/libhello/tests/buildfile @@ -1 +1 @@ -./: test/ +./: {*/ -build/} diff --git a/libhello/tests/test/buildfile b/libhello/tests/test/buildfile deleted file mode 100644 index 2ff528a..0000000 --- a/libhello/tests/test/buildfile +++ /dev/null @@ -1,4 +0,0 @@ -import libs = libhello%lib{hello} - -exe{driver}: cxx{driver} $libs -exe{driver}: file{test.out}: test.stdout = true diff --git a/libhello/tests/test/driver.cxx b/libhello/tests/test/driver.cxx deleted file mode 100644 index 1c08bca..0000000 --- a/libhello/tests/test/driver.cxx +++ /dev/null @@ -1,14 +0,0 @@ -// file: tests/test/driver.cxx -*- C++ -*- - -#include -#include // volume - -int -main () -{ - using namespace hello; - - say ("World"); - say ("World", format::volume::loud); - say_formatted ("Hi, World!"); -} diff --git a/libhello/tests/test/test.out b/libhello/tests/test/test.out deleted file mode 100644 index a9ec19f..0000000 --- a/libhello/tests/test/test.out +++ /dev/null @@ -1,3 +0,0 @@ -Hello, World! -HELLO, World! -Hi, World! diff --git a/repositories.manifest b/repositories.manifest index 4d2d747..076037a 100644 --- a/repositories.manifest +++ b/repositories.manifest @@ -1,9 +1,10 @@ : 1 -role: prerequisite -location: https://git.build2.org/hello/libprint.git#master +summary: libhello project repository + : role: prerequisite -location: https://git.build2.org/hello/libformat.git#master +location: https://git.build2.org/hello/libprint.git##HEAD + : -role: base -summary: libhello project repository +role: prerequisite +location: https://git.build2.org/hello/libformat.git##HEAD -- cgit v1.1