summaryrefslogtreecommitdiff
path: root/libhello/libhello
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2018-05-04 14:29:05 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2018-05-04 14:29:05 +0200
commit49261d3c921a16bffd491555d3a41ea1e5410d13 (patch)
treef0081f7a03da5226f60782d9731156cceb7ac9fb /libhello/libhello
parentcb647d3e1affe6b1ebd8a31b1ad5f7a76cde63ab (diff)
Regenerate libhello using bdep-new
Diffstat (limited to 'libhello/libhello')
-rw-r--r--libhello/libhello/.gitignore3
-rw-r--r--libhello/libhello/buildfile39
-rw-r--r--libhello/libhello/export.hxx18
-rw-r--r--libhello/libhello/hello.cxx13
-rw-r--r--libhello/libhello/hello.hxx10
-rw-r--r--libhello/libhello/version.hxx.in33
6 files changed, 85 insertions, 31 deletions
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 <libhello/hello.hxx>
-#include <iostream>
+#include <ostream>
+#include <stdexcept>
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 <iosfwd>
#include <string>
#include <libhello/export.hxx>
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$"