From 77bc33bcdf611d0f5c703d3d8e20d6f5aff8814c Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 31 Aug 2016 12:57:01 +0200 Subject: Add build2-based build system --- .gitignore | 11 ++++-- build/.gitignore | 1 + build/bootstrap.build | 26 +++++++++++++ build/export.build | 10 +++++ build/root.build | 14 +++++++ buildfile | 12 ++++++ doc/buildfile | 9 +++++ manifest | 12 ++++++ xml/buildfile | 87 ++++++++++++++++++++++++++++++++++++++++++ xml/details/build2/config-vc.h | 20 ++++++++++ xml/details/build2/config.h | 44 +++++++++++++++++++++ xml/details/config.hxx | 16 ++++++-- xml/details/expat/config.h | 14 +++++-- xml/details/export.hxx | 39 +++++++++++++++++++ xml/exception | 4 +- xml/forward | 1 + xml/parser | 10 ++--- xml/qname | 3 +- xml/serializer | 5 +-- xml/value-traits | 2 +- xml/version | 1 + 21 files changed, 317 insertions(+), 24 deletions(-) create mode 100644 build/.gitignore create mode 100644 build/bootstrap.build create mode 100644 build/export.build create mode 100644 build/root.build create mode 100644 buildfile create mode 100644 doc/buildfile create mode 100644 manifest create mode 100644 xml/buildfile create mode 100644 xml/details/build2/config-vc.h create mode 100644 xml/details/build2/config.h diff --git a/.gitignore b/.gitignore index 3b9998d..6473b20 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,16 @@ # Compiler/linker output. # +*.d *.o -*.o.d +*.obj *.so +*.dll *.a -*.l -*.l.cpp-options +*.lib +*.exp +*.exe +*.exe.dlls/ +*.exe.manifest # Generated documentation. # diff --git a/build/.gitignore b/build/.gitignore new file mode 100644 index 0000000..225c27f --- /dev/null +++ b/build/.gitignore @@ -0,0 +1 @@ +config.build diff --git a/build/bootstrap.build b/build/bootstrap.build new file mode 100644 index 0000000..e4b58a9 --- /dev/null +++ b/build/bootstrap.build @@ -0,0 +1,26 @@ +# file : build/bootstrap.build +# copyright : Copyright (c) 2013-2014 Code Synthesis Tools CC +# license : MIT; see accompanying LICENSE file + +project = libstudxml + +using build@0.4.0-a1 + +version = 1.1.0-a4 + +abi_major = 1 +abi_minor = 1 +abi_patch = 0 +abi_prerelease = true + +revision = 0 + +dist.package = $project-$version + +if ($revision != 0) + dist.package += +$revision + +using config +using dist +using test +using install diff --git a/build/export.build b/build/export.build new file mode 100644 index 0000000..6d62864 --- /dev/null +++ b/build/export.build @@ -0,0 +1,10 @@ +# file : build/export.build +# copyright : Copyright (c) 2013-2014 Code Synthesis Tools CC +# license : MIT; see accompanying LICENSE file + +$out_root/: +{ + include xml/ +} + +export $out_root/xml/lib{studxml} diff --git a/build/root.build b/build/root.build new file mode 100644 index 0000000..a6cb63a --- /dev/null +++ b/build/root.build @@ -0,0 +1,14 @@ +# file : build/root.build +# copyright : Copyright (c) 2013-2014 Code Synthesis Tools CC +# license : MIT; see accompanying LICENSE file + +cxx.std = 11 + +using cxx + +hxx{*}: extension = +cxx{*}: extension = cxx +ixx{*}: extension = ixx +txx{*}: extension = txx + +using c diff --git a/buildfile b/buildfile new file mode 100644 index 0000000..92e7c19 --- /dev/null +++ b/buildfile @@ -0,0 +1,12 @@ +# file : buildfile +# copyright : Copyright (c) 2013-2014 Code Synthesis Tools CC +# license : MIT; see accompanying LICENSE file + +d = xml/ doc/ +./: $d doc{INSTALL LICENSE NEWS README version} file{manifest} +include $d + +# Don't install tests or the INSTALL file. +# +dir{tests/}: install = false +doc{INSTALL}@./: install = false diff --git a/doc/buildfile b/doc/buildfile new file mode 100644 index 0000000..6aec5bb --- /dev/null +++ b/doc/buildfile @@ -0,0 +1,9 @@ +# file : doc/buildfile +# copyright : Copyright (c) 2013-2014 Code Synthesis Tools CC +# license : MIT; see accompanying LICENSE file + +define css: file +css{*}: extension = css +css{*}: install = doc/ + +./: doc{intro.xhtml} css{default} diff --git a/manifest b/manifest new file mode 100644 index 0000000..4879ec5 --- /dev/null +++ b/manifest @@ -0,0 +1,12 @@ +: 1 +name: libstudxml +version: 1.1.0-a4 +summary: Streaming XML pull parser/serializer for modern C++ +license: MIT +tags: c++, xml, parser, serializer, streaming, pull, conforming +description-file: README +changes-file: NEWS +url: http://www.codesynthesis.com/projects/libstudxml/ +email: studxml-users@codesynthesis.com; Mailing list +requires: c++11 +requires: build2 >= 0.4.0 diff --git a/xml/buildfile b/xml/buildfile new file mode 100644 index 0000000..c387f56 --- /dev/null +++ b/xml/buildfile @@ -0,0 +1,87 @@ +# file : xml/buildfile +# copyright : Copyright (c) 2013-2014 Code Synthesis Tools CC +# license : MIT; see accompanying LICENSE file + +lib{studxml}: \ + {hxx }{ content } \ + {hxx }{ exception } \ + {hxx }{ forward } \ + {hxx ixx txx cxx}{ parser } \ + {hxx cxx}{ qname } \ + {hxx ixx cxx}{ serializer } \ + {hxx txx cxx}{ value-traits } \ + {hxx }{ version } \ + details/{hxx }{ config.hxx } \ + details/{hxx }{ export.hxx } \ + details/{hxx }{ post.hxx } \ + details/{hxx }{ pre.hxx } \ +details/build2/{h }{ config } \ +details/build2/{h }{ config-vc } + +# Expat. Note that we treat a whole bunch of its sources as files since they +# are private and #include's (including .c file). +# +lib{studxml}: \ +details/expat/h{ expat } \ +details/expat/h{ expat_external } \ +details/expat/c{ xmlparse } \ +details/expat/c{ xmlrole } \ +details/expat/c{ xmltok } \ +details/expat/file{ ascii.h asciitab.h config.h iasciitab.h internal.h \ +latin1tab.h nametab.h utf8tab.h xmlrole.h xmltok.h xmltok_impl.c \ +xmltok_impl.h xmltok_ns.c} \ +details/expat/doc{LICENSE README} + +details/expat/doc{README}@./: install = false +details/expat/doc{LICENSE}@./: install = doc/EXPAT-LICENSE + +# Genx. +# +lib{studxml}: \ +details/genx/c{ char-props } \ +details/genx/c{ genx } \ +details/genx/h{ genx } \ +details/genx/doc{LICENSE README} + +details/genx/doc{README}@./: install = false +details/genx/doc{LICENSE}@./: install = doc/GENX-LICENSE + +# 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{studxml}: bin.lib.version = @-$version +else + lib{studxml}: bin.lib.version = @-$abi_major.$abi_minor + +# We are a mixed C/C++ library, though C is implementatio-only, kind of: we +# need headers but not symbols. +# +cc.poptions += -I$src_root -DLIBSTUDXML_BUILD2 +obja{*}: cc.poptions += -DLIBSTUDXML_STATIC_BUILD +objs{*}: cc.poptions += -DLIBSTUDXML_SHARED_BUILD + +lib{studxml}: cc.export.poptions = -I$src_root -DLIBSTUDXML_BUILD2 +liba{studxml}: cc.export.poptions += -DLIBSTUDXML_STATIC +libs{studxml}: cc.export.poptions += -DLIBSTUDXML_SHARED + +# Install into the xml/ subdirectory of, say, /usr/include/. Bold, I know. +# +install.include = $install.include/xml/ +install.include.subdirs = true # Recreate subdirectories. + +# We want these to be picked up even when LIBSTUDXML_BUILD2 is not defined. +# +details/build2/: +{ + if ($cxx.id == "msvc") + { + h{config}@./: install = false + h{config-vc}@./: install = $install.include/details/ + } + else + { + h{config}@./: install = $install.include/details/ + h{config-vc}@./: install = false + } +} diff --git a/xml/details/build2/config-vc.h b/xml/details/build2/config-vc.h new file mode 100644 index 0000000..4def1f0 --- /dev/null +++ b/xml/details/build2/config-vc.h @@ -0,0 +1,20 @@ +/* file : xml/details/build2/config-vc.h + * copyright : Copyright (c) 2013-2014 Code Synthesis Tools CC + * license : MIT; see accompanying LICENSE file + */ + +/* Configuration file for Windows/VC++ for the build2 build. */ + +#ifndef XML_DETAILS_CONFIG_VC_H +#define XML_DETAILS_CONFIG_VC_H + +/* Define LIBSTUDXML_BUILD2 for the installed case. */ +#ifndef LIBSTUDXML_BUILD2 +# define LIBSTUDXML_BUILD2 +#endif + +// Always little-endian, at least on i686 and x86_64. +// +#define LIBSTUDXML_BYTEORDER 1234 + +#endif /* XML_DETAILS_CONFIG_VC_H */ diff --git a/xml/details/build2/config.h b/xml/details/build2/config.h new file mode 100644 index 0000000..f03416c --- /dev/null +++ b/xml/details/build2/config.h @@ -0,0 +1,44 @@ +/* file : xml/details/build2/config.h + * copyright : Copyright (c) 2013-2014 Code Synthesis Tools CC + * license : MIT; see accompanying LICENSE file + */ + +/* Static configuration file for the build2 build. */ + +#ifndef XML_DETAILS_CONFIG_H +#define XML_DETAILS_CONFIG_H + +/* Define LIBSTUDXML_BUILD2 for the installed case. */ +#ifndef LIBSTUDXML_BUILD2 +# define LIBSTUDXML_BUILD2 +#endif + +#ifdef _WIN32 +# ifndef BYTE_ORDER +# define BIG_ENDIAN 4321 +# define LITTLE_ENDIAN 1234 +# define BYTE_ORDER LITTLE_ENDIAN +# endif +#else +# include /* BYTE_ORDER/__BYTE_ORDER, BSD */ +# ifdef BSD +# include /* BYTE_ORDER */ +# endif +# ifndef BYTE_ORDER +# ifdef __BYTE_ORDER +# define BYTE_ORDER __BYTE_ORDER +# define BIG_ENDIAN __BIG_ENDIAN +# define LITTLE_ENDIAN __LITTLE_ENDIAN +# else +# error no BYTE_ORDER/__BYTE_ORDER define +# endif +# endif +#endif + +#if BYTE_ORDER == BIG_ENDIAN +# define LIBSTUDXML_BYTEORDER 4321 +#else +# define LIBSTUDXML_BYTEORDER 1234 +#endif + +#endif /* XML_DETAILS_CONFIG_H */ diff --git a/xml/details/config.hxx b/xml/details/config.hxx index 5f4a19b..da76390 100644 --- a/xml/details/config.hxx +++ b/xml/details/config.hxx @@ -5,10 +5,20 @@ #ifndef XML_DETAILS_CONFIG_HXX #define XML_DETAILS_CONFIG_HXX -#ifdef _MSC_VER -# include +// Note: the same in expat/config.h +// +#ifdef LIBSTUDXML_BUILD2 +# ifdef _MSC_VER +# include +# else +# include +# endif #else -# include +# ifdef _MSC_VER +# include +# else +# include +# endif #endif #endif // XML_DETAILS_CONFIG_HXX diff --git a/xml/details/expat/config.h b/xml/details/expat/config.h index b301012..a335147 100644 --- a/xml/details/expat/config.h +++ b/xml/details/expat/config.h @@ -1,10 +1,18 @@ #ifndef EXPAT_CONFIG_H #define EXPAT_CONFIG_H -#ifdef _MSC_VER -# include +#ifdef LIBSTUDXML_BUILD2 +# ifdef _MSC_VER +# include +# else +# include +# endif #else -# include +# ifdef _MSC_VER +# include +# else +# include +# endif #endif #define BYTEORDER LIBSTUDXML_BYTEORDER diff --git a/xml/details/export.hxx b/xml/details/export.hxx index b4c4b58..b9a783d 100644 --- a/xml/details/export.hxx +++ b/xml/details/export.hxx @@ -7,6 +7,43 @@ #include +// 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. + +#ifdef LIBSTUDXML_BUILD2 + +#if defined(LIBSTUDXML_STATIC) // Using static. +# define LIBSTUDXML_EXPORT +#elif defined(LIBSTUDXML_STATIC_BUILD) // Building static. +# define LIBSTUDXML_EXPORT +#elif defined(LIBSTUDXML_SHARED) // Using shared. +# ifdef _WIN32 +# define LIBSTUDXML_EXPORT __declspec(dllimport) +# else +# define LIBSTUDXML_EXPORT +# endif +#elif defined(LIBSTUDXML_SHARED_BUILD) // Building shared. +# ifdef _WIN32 +# define LIBSTUDXML_EXPORT __declspec(dllexport) +# else +# define LIBSTUDXML_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 LIBSTUDXML_EXPORT // Using static or shared. +#endif + +#else // LIBSTUDXML_BUILD2 + #ifdef LIBSTUDXML_STATIC_LIB # define LIBSTUDXML_EXPORT #else @@ -33,4 +70,6 @@ # endif #endif +#endif // LIBSTUDXML_BUILD2 + #endif // XML_DETAILS_EXPORT_HXX diff --git a/xml/exception b/xml/exception index 1fe1eb2..03cd9bb 100644 --- a/xml/exception +++ b/xml/exception @@ -9,11 +9,9 @@ #include -#include - namespace xml { - struct LIBSTUDXML_EXPORT exception: std::exception {}; + class exception: public std::exception {}; } #include diff --git a/xml/forward b/xml/forward index ceefdbe..bfd2d3c 100644 --- a/xml/forward +++ b/xml/forward @@ -14,6 +14,7 @@ namespace xml class qname; class parser; class serializer; + class exception; } #include diff --git a/xml/parser b/xml/parser index a1b6250..d891c3e 100644 --- a/xml/parser +++ b/xml/parser @@ -36,10 +36,9 @@ namespace xml { - class parser; - - struct LIBSTUDXML_EXPORT parsing: exception + class LIBSTUDXML_EXPORT parsing: public exception { + public: virtual ~parsing () throw (); @@ -65,7 +64,7 @@ namespace xml virtual const char* what () const throw (); - private: + private: void init (); @@ -460,8 +459,7 @@ namespace xml pop_element (); }; - LIBSTUDXML_EXPORT - std::ostream& + LIBSTUDXML_EXPORT std::ostream& operator<< (std::ostream&, parser::event_type); } diff --git a/xml/qname b/xml/qname index 85d6424..95d402b 100644 --- a/xml/qname +++ b/xml/qname @@ -77,8 +77,7 @@ namespace xml // Print the string representation ([#]). // - LIBSTUDXML_EXPORT - std::ostream& + LIBSTUDXML_EXPORT std::ostream& operator<< (std::ostream&, const qname&); } diff --git a/xml/serializer b/xml/serializer index 6251392..8068176 100644 --- a/xml/serializer +++ b/xml/serializer @@ -21,10 +21,9 @@ namespace xml { - class serializer; - - struct LIBSTUDXML_EXPORT serialization: exception + class LIBSTUDXML_EXPORT serialization: public exception { + public: virtual ~serialization () throw (); diff --git a/xml/value-traits b/xml/value-traits index 0c79229..7d9f47b 100644 --- a/xml/value-traits +++ b/xml/value-traits @@ -40,7 +40,7 @@ namespace xml }; template <> - struct LIBSTUDXML_EXPORT default_value_traits + struct default_value_traits { static std::string parse (std::string s, const parser&) diff --git a/xml/version b/xml/version index f452319..e4362cc 100644 --- a/xml/version +++ b/xml/version @@ -20,6 +20,7 @@ // 2.2.0-a1 02019901 // 3.0.0-b2 02999952 // + #define LIBSTUDXML_VERSION 1009904 #define LIBSTUDXML_VERSION_STR "1.1.0-a4" -- cgit v1.1