diff options
-rw-r--r-- | libhello/.gitignore | 8 | ||||
-rw-r--r-- | libhello/INSTALL | 1 | ||||
-rw-r--r-- | libhello/build/.gitignore | 2 | ||||
-rw-r--r-- | libhello/build/bootstrap.build | 2 | ||||
-rw-r--r-- | libhello/build/root.build | 8 | ||||
-rw-r--r-- | libhello/buildfile | 15 | ||||
-rw-r--r-- | libhello/libhello/.gitignore | 3 | ||||
-rw-r--r-- | libhello/libhello/buildfile | 39 | ||||
-rw-r--r-- | libhello/libhello/export.hxx | 18 | ||||
-rw-r--r-- | libhello/libhello/hello.cxx | 13 | ||||
-rw-r--r-- | libhello/libhello/hello.hxx | 10 | ||||
-rw-r--r-- | libhello/libhello/version.hxx.in | 33 | ||||
-rw-r--r-- | libhello/tests/.gitignore | 7 | ||||
-rw-r--r-- | libhello/tests/basics/buildfile | 3 | ||||
-rw-r--r-- | libhello/tests/basics/driver.cxx | 33 | ||||
-rw-r--r-- | libhello/tests/build/.gitignore | 2 | ||||
-rw-r--r-- | libhello/tests/build/bootstrap.build | 4 | ||||
-rw-r--r-- | libhello/tests/build/root.build | 6 | ||||
-rw-r--r-- | libhello/tests/buildfile | 2 | ||||
-rw-r--r-- | libhello/tests/test/buildfile | 4 | ||||
-rw-r--r-- | libhello/tests/test/driver.cxx | 11 | ||||
-rw-r--r-- | libhello/tests/test/test.out | 1 | ||||
-rw-r--r-- | repositories.manifest | 2 |
23 files changed, 158 insertions, 69 deletions
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 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$" 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..1f0a479 --- /dev/null +++ b/libhello/tests/basics/driver.cxx @@ -0,0 +1,33 @@ +#include <cassert> +#include <sstream> +#include <stdexcept> + +#include <libhello/version.hxx> +#include <libhello/hello.hxx> + +using namespace std; +using namespace hello; + +int main () +{ + // Basics. + // + { + ostringstream o; + say_hello (o, "World"); + assert (o.str () == "Hello, World!\n"); + } + + // Empty name. + // + try + { + ostringstream o; + say_hello (o, ""); + assert (false); + } + catch (const invalid_argument& e) + { + assert (e.what () == string ("empty name")); + } +} 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 38937f0..0000000 --- a/libhello/tests/test/driver.cxx +++ /dev/null @@ -1,11 +0,0 @@ -// file: tests/test/driver.cxx -*- C++ -*- - -#include <libhello/hello.hxx> - -int -main () -{ - using hello::say; - - say ("World"); -} diff --git a/libhello/tests/test/test.out b/libhello/tests/test/test.out deleted file mode 100644 index 8ab686e..0000000 --- a/libhello/tests/test/test.out +++ /dev/null @@ -1 +0,0 @@ -Hello, World! diff --git a/repositories.manifest b/repositories.manifest new file mode 100644 index 0000000..7b9f536 --- /dev/null +++ b/repositories.manifest @@ -0,0 +1,2 @@ +: 1 +summary: libhello project repository |