diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2025-01-07 09:58:18 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2025-01-07 09:58:18 +0200 |
commit | b21bb358e87405e64d8bc99cefdfc72ca3e91993 (patch) | |
tree | f08bc42f053ae51c3979e5926e2930cae15e80ea | |
parent | 525e3baf51104e2416071eafc6f3f7b5b41f27cd (diff) |
Add support for using external Expat library
-rw-r--r-- | build/root.build | 5 | ||||
-rw-r--r-- | libstudxml/buildfile | 74 | ||||
-rw-r--r-- | libstudxml/details/config-vc.h | 2 | ||||
-rw-r--r-- | libstudxml/details/config.hxx | 26 | ||||
-rw-r--r-- | libstudxml/parser.hxx | 7 | ||||
-rw-r--r-- | libstudxml/serializer.hxx | 6 | ||||
-rw-r--r-- | manifest | 16 | ||||
-rw-r--r-- | repositories.manifest | 7 |
8 files changed, 89 insertions, 54 deletions
diff --git a/build/root.build b/build/root.build index a72acce..5516ce5 100644 --- a/build/root.build +++ b/build/root.build @@ -1,6 +1,11 @@ # file : build/root.build # license : MIT; see accompanying LICENSE file +# Allow using the external Expat library as a dependency instead of the +# bundled version. +# +config [bool] config.libstudxml.external_expat ?= false + cxx.std = latest using cxx diff --git a/libstudxml/buildfile b/libstudxml/buildfile index 06b5c5c..e004fca 100644 --- a/libstudxml/buildfile +++ b/libstudxml/buildfile @@ -1,29 +1,37 @@ # file : libstudxml/buildfile # license : MIT; see accompanying LICENSE file +int_expat = (!$config.libstudxml.external_expat) + +intf_libs = # Interface dependencies. + +if! $int_expat + import intf_libs += libexpat%lib{expat} + lib{studxml}: {hxx ixx txx cxx}{** -version} {hxx}{version} \ details/{h}{config*} -# Expat. Note that we treat a whole bunch of its sources as files since they -# are private and #include's (including .c file). +# Expat. # -lib{studxml}: details/expat/{ \ - h{expat expat_external} \ - c{xmlparse xmlrole xmltok} \ -file{ascii.h asciitab.h config.h iasciitab.h internal.h latin1tab.h nametab.h \ - utf8tab.h xmlrole.h xmltok.h xmltok_impl.h xmltok_impl.c xmltok_ns.c} \ - doc{COPYING README} \ +# Note that we treat some of its source files as ad hoc since they are +# #include'd. +# +details/expat/ +{ + ../../lib{studxml}: h{*}: include = $int_expat + ../../lib{studxml}: c{xmlparse xmlrole xmltok}: include = $int_expat + ../../lib{studxml}: c{xmltok_impl xmltok_ns}: include = ($int_expat ? adhoc : false) + ../../lib{studxml}: doc{COPYING README} } -details/expat/doc{README}@details/expat/: install = false -details/expat/doc{COPYING}@details/expat/: install = doc/EXPAT-LICENSE - # Genx. # -lib{studxml}: details/genx/{h{*} c{*} doc{LICENSE README}} +details/genx/ +{ + ../../lib{studxml}: h{*} c{*} doc{LICENSE README} +} -details/genx/doc{README}@details/genx/: install = false -details/genx/doc{LICENSE}@details/genx/: install = doc/GENX-LICENSE +lib{studxml}: $intf_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 @@ -52,15 +60,25 @@ if ($c.class == 'gcc') # cc.poptions =+ "-I$out_root" "-I$src_root" +if! $int_expat + cc.poptions += -DLIBSTUDXML_EXTERNAL_EXPAT + obja{*}: cc.poptions += -DLIBSTUDXML_STATIC_BUILD objs{*}: cc.poptions += -DLIBSTUDXML_SHARED_BUILD # Export options. # -lib{studxml}: cc.export.poptions = "-I$out_root" "-I$src_root" +lib{studxml}: +{ + cxx.export.poptions = "-I$out_root" "-I$src_root" + cxx.export.libs = $intf_libs +} -liba{studxml}: cc.export.poptions += -DLIBSTUDXML_STATIC -libs{studxml}: cc.export.poptions += -DLIBSTUDXML_SHARED +if! $int_expat + lib{studxml}: cxx.export.poptions += -DLIBSTUDXML_EXTERNAL_EXPAT + +liba{studxml}: cxx.export.poptions += -DLIBSTUDXML_STATIC +libs{studxml}: cxx.export.poptions += -DLIBSTUDXML_SHARED # For pre-releases use the complete version to make sure they cannot be used # in place of another pre-release or the final version. See the version module @@ -79,3 +97,25 @@ else install = include/libstudxml/ install.subdirs = true } + +# Most of the Expat headers are private. +# +details/expat/ +{ + h{*}: install = false + + h{expat}@./ h{expat_external.h}@./: + { + install = ($int_expat ? include/libstudxml/details/expat/ : false) + install.subdirs = false + } + + doc{README}@./: install = false + doc{COPYING}@./: install = ($int_expat ? doc/EXPAT-LICENSE : false) +} + +details/genx/ +{ + doc{README}@./: install = false + doc{LICENSE}@./: install = doc/GENX-LICENSE +} diff --git a/libstudxml/details/config-vc.h b/libstudxml/details/config-vc.h index 5d8f79e..0ff1240 100644 --- a/libstudxml/details/config-vc.h +++ b/libstudxml/details/config-vc.h @@ -7,7 +7,7 @@ #ifndef LIBSTUDXML_DETAILS_CONFIG_VC_H #define LIBSTUDXML_DETAILS_CONFIG_VC_H -// Always little-endian, at least on i686 and x86_64. +// Always little-endian, at least on i686, x86_64, and ARM. // #define LIBSTUDXML_BYTEORDER 1234 diff --git a/libstudxml/details/config.hxx b/libstudxml/details/config.hxx index 6a466d6..437c275 100644 --- a/libstudxml/details/config.hxx +++ b/libstudxml/details/config.hxx @@ -4,30 +4,8 @@ #ifndef LIBSTUDXML_DETAILS_CONFIG_HXX #define LIBSTUDXML_DETAILS_CONFIG_HXX -// C++11 support. -// -#ifdef _MSC_VER -# if _MSC_VER >= 1900 -# define STUDXML_CXX11_NOEXCEPT -# endif -#else -# if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L -# ifdef __clang__ // Pretends to be a really old __GNUC__ on some platforms. -# define STUDXML_CXX11_NOEXCEPT -# elif defined(__GNUC__) -# if (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4 -# define STUDXML_CXX11_NOEXCEPT -# endif -# else -# define STUDXML_CXX11_NOEXCEPT -# endif -# endif -#endif - -#ifdef STUDXML_CXX11_NOEXCEPT -# define STUDXML_NOTHROW_NOEXCEPT noexcept -#else -# define STUDXML_NOTHROW_NOEXCEPT throw() +#if !defined(__cplusplus) || __cplusplus < 201103L +# error C++11 is required #endif #ifdef _MSC_VER diff --git a/libstudxml/parser.hxx b/libstudxml/parser.hxx index c67919a..c04eded 100644 --- a/libstudxml/parser.hxx +++ b/libstudxml/parser.hxx @@ -12,8 +12,7 @@ #include <iosfwd> #include <cstddef> // std::size_t -#include <libstudxml/details/config.hxx> // STUDXML_NOTHROW_NOEXCEPT, - // LIBSTUDXML_EXTERNAL_EXPAT +#include <libstudxml/details/config.hxx> #ifndef LIBSTUDXML_EXTERNAL_EXPAT # include <libstudxml/details/expat/expat.h> @@ -40,7 +39,7 @@ namespace xml { public: virtual - ~parsing () STUDXML_NOTHROW_NOEXCEPT {} + ~parsing () noexcept {} parsing (const std::string& name, unsigned long long line, @@ -62,7 +61,7 @@ namespace xml description () const {return description_;} virtual const char* - what () const STUDXML_NOTHROW_NOEXCEPT {return what_.c_str ();} + what () const noexcept {return what_.c_str ();} private: LIBSTUDXML_EXPORT void diff --git a/libstudxml/serializer.hxx b/libstudxml/serializer.hxx index 4913c25..ead52e9 100644 --- a/libstudxml/serializer.hxx +++ b/libstudxml/serializer.hxx @@ -16,7 +16,7 @@ #include <libstudxml/qname.hxx> #include <libstudxml/exception.hxx> -#include <libstudxml/details/config.hxx> // STUDXML_NOTHROW_NOEXCEPT +#include <libstudxml/details/config.hxx> #include <libstudxml/details/export.hxx> namespace xml @@ -25,7 +25,7 @@ namespace xml { public: virtual - ~serialization () STUDXML_NOTHROW_NOEXCEPT {} + ~serialization () noexcept {} serialization (const std::string& name, const std::string& description); serialization (const serializer& s, const std::string& description); @@ -37,7 +37,7 @@ namespace xml description () const {return description_;} virtual const char* - what () const STUDXML_NOTHROW_NOEXCEPT {return what_.c_str ();} + what () const noexcept {return what_.c_str ();} private: LIBSTUDXML_EXPORT void @@ -1,7 +1,7 @@ : 1 name: libstudxml version: 1.1.0-b.10.z -summary: Streaming XML pull parser/serializer for modern C++ +summary: Streaming XML pull parser/serializer for C++11 license: MIT topics: C++, XML, XML parser, XML serializer description-file: README @@ -10,8 +10,14 @@ url: https://www.codesynthesis.com/projects/libstudxml/ doc-url: https://www.codesynthesis.com/projects/libstudxml/doc/intro.xhtml src-url: https://git.codesynthesis.com/cgit/libstudxml/libstudxml/ email: studxml-users@codesynthesis.com ; Mailing list -build-warning-email: builds@codesynthesis.com -builds: all + requires: c++11 -depends: * build2 >= 0.13.0 -depends: * bpkg >= 0.13.0 + +depends: * build2 >= 0.17.0 +depends: * bpkg >= 0.17.0 + +depends: libexpat ^2.1.0 ? ($config.libstudxml.external_expat) + +builds: all + +external-expat-build-config: config.libstudxml.external_expat=true diff --git a/repositories.manifest b/repositories.manifest new file mode 100644 index 0000000..7944c28 --- /dev/null +++ b/repositories.manifest @@ -0,0 +1,7 @@ +: 1 +summary: libstudxml project repository + +: +role: prerequisite +location: https://pkg.cppget.org/1/stable +trust: 70:64:FE:E4:E0:F3:60:F1:B4:51:E1:FA:12:5C:E0:B3:DB:DF:96:33:39:B9:2E:E5:C2:68:63:4C:A6:47:39:43 |