From 49261d3c921a16bffd491555d3a41ea1e5410d13 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 4 May 2018 14:29:05 +0200 Subject: Regenerate libhello using bdep-new --- libhello/libhello/.gitignore | 3 +++ libhello/libhello/buildfile | 39 ++++++++++++++++++++++++++++----------- libhello/libhello/export.hxx | 18 ++++++++---------- libhello/libhello/hello.cxx | 13 +++++++------ libhello/libhello/hello.hxx | 10 ++++++---- libhello/libhello/version.hxx.in | 33 +++++++++++++++++++++++++++++++++ 6 files changed, 85 insertions(+), 31 deletions(-) create mode 100644 libhello/libhello/.gitignore create mode 100644 libhello/libhello/version.hxx.in (limited to 'libhello/libhello') 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 c43a4ae..45aa7e4 100644 --- a/libhello/libhello/buildfile +++ b/libhello/libhello/buildfile @@ -1,4 +1,27 @@ -lib{hello}: {hxx cxx}{hello} hxx{export} +int_libs = # Interface dependencies. +imp_libs = # Implementation dependencies. +#import imp_libs += libhello%lib{hello} + +lib{hello}: {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{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 # 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{hello}: bin.lib.version = @"-$version.major.$version.minor" -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 - -# Install into the libhello/ subdirectory of, say, /usr/include/. +# 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 677815d..4fbd917 100644 --- a/libhello/libhello/hello.cxx +++ b/libhello/libhello/hello.cxx @@ -1,16 +1,17 @@ -// file: libhello/hello.cxx -*- C++ -*- - #include -#include +#include +#include using namespace std; namespace hello { - void - say (const string& n) + void say_hello (ostream& o, const string& n) { - cout << "Hello, " << n << '!' << endl; + if (n.empty ()) + throw invalid_argument ("empty name"); + + o << "Hello, " << n << '!' << endl; } } diff --git a/libhello/libhello/hello.hxx b/libhello/libhello/hello.hxx index 58bd7b2..9b069b0 100644 --- a/libhello/libhello/hello.hxx +++ b/libhello/libhello/hello.hxx @@ -1,13 +1,15 @@ -// file: libhello/hello.hxx -*- C++ -*- - #pragma once +#include #include #include namespace hello { - LIBHELLO_EXPORT void - say (const std::string& name); + // Print a greeting for the specified name into the specified + // stream. Throw std::invalid_argument if the name is empty. + // + LIBHELLO_SYMEXPORT void + say_hello (std::ostream&, const std::string& name); } 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$" -- cgit v1.1