From af50e2603fd0f877d0f96da1562b0deda0590b70 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 18 Feb 2019 13:01:12 +0200 Subject: Add support for building with build2 --- .gitignore | 18 +++++++- README-GIT | 4 ++ build/bootstrap.build | 11 +++++ build/export.build | 10 +++++ build/root.build | 18 ++++++++ buildfile | 10 +++++ manifest | 21 +++++++++ odb/qt/buildfile | 82 ++++++++++++++++++++++++++++++++++ odb/qt/details/build2/config-stub.h | 6 +++ odb/qt/details/build2/config-vc-stub.h | 6 +++ odb/qt/details/build2/config-vc.h | 16 +++++++ odb/qt/details/build2/config.h | 18 ++++++++ odb/qt/details/config-vc.h | 6 +++ odb/qt/details/config.hxx | 11 +++-- odb/qt/details/export.hxx | 39 ++++++++++++++++ odb/qt/makefile | 2 +- odb/qt/version-build2-stub.hxx | 5 +++ odb/qt/version-build2.hxx | 0 odb/qt/version-build2.hxx.in | 44 ++++++++++++++++++ odb/qt/version.hxx | 11 +++++ repositories.manifest | 6 +++ tests/basics/buildfile | 7 +++ tests/basics/driver.cxx | 23 ++++++++++ tests/build/bootstrap.build | 9 ++++ tests/build/root.build | 24 ++++++++++ tests/buildfile | 5 +++ 26 files changed, 406 insertions(+), 6 deletions(-) create mode 100644 README-GIT 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 manifest create mode 100644 odb/qt/buildfile create mode 100644 odb/qt/details/build2/config-stub.h create mode 100644 odb/qt/details/build2/config-vc-stub.h create mode 100644 odb/qt/details/build2/config-vc.h create mode 100644 odb/qt/details/build2/config.h create mode 100644 odb/qt/details/config-vc.h create mode 100644 odb/qt/version-build2-stub.hxx create mode 100644 odb/qt/version-build2.hxx create mode 100644 odb/qt/version-build2.hxx.in create mode 100644 repositories.manifest create mode 100644 tests/basics/buildfile create mode 100644 tests/basics/driver.cxx create mode 100644 tests/build/bootstrap.build create mode 100644 tests/build/root.build create mode 100644 tests/buildfile diff --git a/.gitignore b/.gitignore index 3b9998d..3004ad1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,25 @@ +.bdep/ + # Compiler/linker output. # +*.d +*.t +*.i +*.ii *.o -*.o.d +*.obj *.so +*.dll *.a +*.lib +*.exp +*.pdb +*.ilk +*.exe +*.exe.dlls/ +*.exe.manifest +*.pc + *.l *.l.cpp-options diff --git a/README-GIT b/README-GIT new file mode 100644 index 0000000..859c710 --- /dev/null +++ b/README-GIT @@ -0,0 +1,4 @@ +The checked out odb/qt/version-build2.hxx will be overwritten during the build +process but these changes should be ignored. To do this automatically, run: + +git update-index --assume-unchanged odb/qt/version-build2.hxx diff --git a/build/bootstrap.build b/build/bootstrap.build new file mode 100644 index 0000000..d377762 --- /dev/null +++ b/build/bootstrap.build @@ -0,0 +1,11 @@ +# file : build/bootstrap.build +# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +project = libodb-qt + +using version +using config +using dist +using test +using install diff --git a/build/export.build b/build/export.build new file mode 100644 index 0000000..eb488b2 --- /dev/null +++ b/build/export.build @@ -0,0 +1,10 @@ +# file : build/export.build +# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$out_root/ +{ + include odb/qt/ +} + +export $out_root/odb/qt/lib{odb-qt} diff --git a/build/root.build b/build/root.build new file mode 100644 index 0000000..697f33c --- /dev/null +++ b/build/root.build @@ -0,0 +1,18 @@ +# file : build/root.build +# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +cxx.std = 11 + +using cxx + +hxx{*}: extension = hxx +ixx{*}: extension = ixx +txx{*}: extension = txx +cxx{*}: extension = cxx + +if ($cxx.class == 'msvc') +{ + cxx.poptions += -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS + cxx.coptions += /wd4251 /wd4275 /wd4800 +} diff --git a/buildfile b/buildfile new file mode 100644 index 0000000..7a3f443 --- /dev/null +++ b/buildfile @@ -0,0 +1,10 @@ +# file : buildfile +# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +./: {*/ -build/ -m4/} doc{INSTALL LICENSE NEWS README} manifest + +# Don't install tests or the INSTALL file. +# +tests/: install = false +doc{INSTALL}@./: install = false diff --git a/manifest b/manifest new file mode 100644 index 0000000..e109233 --- /dev/null +++ b/manifest @@ -0,0 +1,21 @@ +: 1 +name: libodb-qt +version: 2.5.0-b.10.z +project: odb +summary: Qt ODB profile library +license: GPLv2 +license: proprietary +tags: qt, c++, orm, database, relational, object, persistence, sql +description-file: README +changes-file: NEWS +url: https://www.codesynthesis.com/products/odb/ +doc-url: https://www.codesynthesis.com/products/odb/doc/manual.xhtml +src-url: https://git.codesynthesis.com/cgit/odb/libodb-qt/ +email: odb-users@codesynthesis.com +build-email: odb-builds@codesynthesis.com +#builds: all +requires: c++11 +requires: libqt-core ; Requires not yet packaged libqt-core. +depends: * build2 >= 0.8.0- +depends: * bpkg >= 0.8.0- +depends: libodb [2.5.0-b.10.1 2.5.0-b.11) diff --git a/odb/qt/buildfile b/odb/qt/buildfile new file mode 100644 index 0000000..4092c51 --- /dev/null +++ b/odb/qt/buildfile @@ -0,0 +1,82 @@ +# file : odb/qt/buildfile +# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +../ +{ + define options: file + options{*}: extension = options + + # Install into the odb/qt/ subdirectory of, say, /usr/include/ recreating + # subdirectories. + # + {hxx ixx txx options}{*}: install = include/odb/ + {hxx ixx txx options}{*}: install.subdirs = true + + qt/ + { + import int_libs = libodb%lib{odb} + imp_libs = + + lib{odb-qt}: {hxx ixx txx cxx}{** -version-build2} {hxx}{version-build2} \ + details/build2/{h}{*} \ + options{**} ../options{qt} \ + $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-build2}: in{version-build2} $src_root/manifest + hxx{version-build2}: dist = true + hxx{version-build2}: clean = ($src_root != $out_root) + + # 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 $version.pre_release + lib{odb-qt}: bin.lib.version = @"-$version.project_id" + else + lib{odb-qt}: bin.lib.version = @"-$version.major.$version.minor" + + cxx.poptions =+ "-I$out_root" "-I$src_root" -DLIBODB_QT_BUILD2 + obja{*}: cxx.poptions += -DLIBODB_QT_STATIC_BUILD + objs{*}: cxx.poptions += -DLIBODB_QT_SHARED_BUILD + + lib{odb-qt}: cxx.export.poptions = "-I$out_root" "-I$src_root" \ + -DLIBODB_QT_BUILD2 + + liba{odb-qt}: cxx.export.poptions += -DLIBODB_QT_STATIC + libs{odb-qt}: cxx.export.poptions += -DLIBODB_QT_SHARED + + lib{odb-qt}: cxx.export.libs = $int_libs + + + # Installation tweaks. + # + install_include = [dir_path] include/odb/qt/ + + # We want these to be picked up whether LIBODB_QT_BUILD2 is defined or + # not. + # + hxx{version}@./: install = false + hxx{version-build2}: install = $install_include/version.hxx + hxx{version-build2-stub}@./: install = $install_include/version-build2.hxx + + details/build2/ + { + h{*}: install = false + + if ($cxx.class == 'msvc') + { + h{config-vc}@./: install = $install_include/details/ + h{config-vc-stub}@./: install = $install_include/details/build2/config-vc.h + } + else + { + h{config}@./: install = $install_include/details/ + h{config-stub}@./: install = $install_include/details/build2/config.h + } + } + } +} diff --git a/odb/qt/details/build2/config-stub.h b/odb/qt/details/build2/config-stub.h new file mode 100644 index 0000000..7d724a4 --- /dev/null +++ b/odb/qt/details/build2/config-stub.h @@ -0,0 +1,6 @@ +/* file : odb/qt/details/build2/config-stub.h + * copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC + * license : GNU GPL v2; see accompanying LICENSE file + */ + +#include diff --git a/odb/qt/details/build2/config-vc-stub.h b/odb/qt/details/build2/config-vc-stub.h new file mode 100644 index 0000000..c4051f8 --- /dev/null +++ b/odb/qt/details/build2/config-vc-stub.h @@ -0,0 +1,6 @@ +/* file : odb/qt/details/build2/config-vc-stub.h + * copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC + * license : GNU GPL v2; see accompanying LICENSE file + */ + +#include diff --git a/odb/qt/details/build2/config-vc.h b/odb/qt/details/build2/config-vc.h new file mode 100644 index 0000000..43f7d6a --- /dev/null +++ b/odb/qt/details/build2/config-vc.h @@ -0,0 +1,16 @@ +/* file : odb/qt/details/build2/config-vc.h + * copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC + * license : GNU GPL v2; see accompanying LICENSE file + */ + +/* Configuration file for Windows/VC++ for the build2 build. */ + +#ifndef ODB_QT_DETAILS_CONFIG_VC_H +#define ODB_QT_DETAILS_CONFIG_VC_H + +/* Define LIBODB_QT_BUILD2 for the installed case. */ +#ifndef LIBODB_QT_BUILD2 +# define LIBODB_QT_BUILD2 +#endif + +#endif /* ODB_QT_DETAILS_CONFIG_VC_H */ diff --git a/odb/qt/details/build2/config.h b/odb/qt/details/build2/config.h new file mode 100644 index 0000000..a864e08 --- /dev/null +++ b/odb/qt/details/build2/config.h @@ -0,0 +1,18 @@ +/* file : odb/qt/details/build2/config.h + * copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC + * license : GNU GPL v2; see accompanying LICENSE file + */ + +/* Static configuration file for the build2 build. The installed case + (when LIBODB_QT_BUILD2 is not necessarily defined) is the only + reason we have it. */ + +#ifndef ODB_QT_DETAILS_CONFIG_H +#define ODB_QT_DETAILS_CONFIG_H + +/* Define LIBODB_QT_BUILD2 for the installed case. */ +#ifndef LIBODB_QT_BUILD2 +# define LIBODB_QT_BUILD2 +#endif + +#endif /* ODB_QT_DETAILS_CONFIG_H */ diff --git a/odb/qt/details/config-vc.h b/odb/qt/details/config-vc.h new file mode 100644 index 0000000..db08247 --- /dev/null +++ b/odb/qt/details/config-vc.h @@ -0,0 +1,6 @@ +/* file : odb/qt/details/config-vc.h + * copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC + * license : GNU GPL v2; see accompanying LICENSE file + */ + +/* Dummy configuration file for Windows/VC++. */ diff --git a/odb/qt/details/config.hxx b/odb/qt/details/config.hxx index dbc4346..08030bd 100644 --- a/odb/qt/details/config.hxx +++ b/odb/qt/details/config.hxx @@ -7,8 +7,6 @@ // no pre -#ifdef _MSC_VER -#elif defined(ODB_COMPILER) // Qt5 may complain if we are building without -fPIC. Instead of asking the // user to pass one of these options to the ODB compiler (which can, BTW, be // done with -x -fPIC, for example, if one is not using the Qt profile), we @@ -20,6 +18,7 @@ // directly. This file appears to be present in all the versions starting with // Qt 4.0. // +#ifdef ODB_COMPILER # if defined(__ELF__) && !defined(__PIC__) # include // QT_REDUCE_RELOCATIONS # ifdef QT_REDUCE_RELOCATIONS @@ -27,8 +26,12 @@ # endif # endif # define LIBODB_QT_STATIC_LIB -#else -# include +#elif !defined(LIBODB_QT_BUILD2) +# ifdef _MSC_VER +# include +# else +# include +# endif #endif // no post diff --git a/odb/qt/details/export.hxx b/odb/qt/details/export.hxx index 51bf1f4..9b93df5 100644 --- a/odb/qt/details/export.hxx +++ b/odb/qt/details/export.hxx @@ -9,6 +9,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 LIBODB_QT_BUILD2 + +#if defined(LIBODB_QT_STATIC) // Using static. +# define LIBODB_QT_EXPORT +#elif defined(LIBODB_QT_STATIC_BUILD) // Building static. +# define LIBODB_QT_EXPORT +#elif defined(LIBODB_QT_SHARED) // Using shared. +# ifdef _WIN32 +# define LIBODB_QT_EXPORT __declspec(dllimport) +# else +# define LIBODB_QT_EXPORT +# endif +#elif defined(LIBODB_QT_SHARED_BUILD) // Building shared. +# ifdef _WIN32 +# define LIBODB_QT_EXPORT __declspec(dllexport) +# else +# define LIBODB_QT_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 LIBODB_QT_EXPORT // Using static or shared. +#endif + +#else // LIBODB_QT_BUILD2 + #ifdef LIBODB_QT_STATIC_LIB # define LIBODB_QT_EXPORT #else @@ -35,6 +72,8 @@ # endif #endif +#endif // LIBODB_QT_BUILD2 + #include #endif // ODB_QT_DETAILS_EXPORT_HXX diff --git a/odb/qt/makefile b/odb/qt/makefile index 9a99fee..64b06cd 100644 --- a/odb/qt/makefile +++ b/odb/qt/makefile @@ -75,7 +75,7 @@ $(dist): export interface_version = $(shell sed -e \ 's/^\([0-9]*\.[0-9]*\).*/\1/' $(src_root)/version) $(dist): - $(call dist-data,$(sources) $(headers) $(options) details/config.h.in) + $(call dist-data,$(sources) $(headers) $(options) details/config.h.in details/config-vc.h) $(call meta-vc8proj,$(src_base)/libodb-qt4-vc8.vcproj) $(call meta-vc9proj,$(src_base)/libodb-qt4-vc9.vcproj) $(call meta-vc9proj,$(src_base)/libodb-qt5-vc9.vcproj) diff --git a/odb/qt/version-build2-stub.hxx b/odb/qt/version-build2-stub.hxx new file mode 100644 index 0000000..bf1e6e7 --- /dev/null +++ b/odb/qt/version-build2-stub.hxx @@ -0,0 +1,5 @@ +// file : odb/qt/version-build2-stub.hxx +// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#include diff --git a/odb/qt/version-build2.hxx b/odb/qt/version-build2.hxx new file mode 100644 index 0000000..e69de29 diff --git a/odb/qt/version-build2.hxx.in b/odb/qt/version-build2.hxx.in new file mode 100644 index 0000000..332be97 --- /dev/null +++ b/odb/qt/version-build2.hxx.in @@ -0,0 +1,44 @@ +// file : odb/qt/version-build2.hxx.in +// copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef LIBODB_QT_VERSION // Note: using the version macro itself. + +// Note: using build2 standard versioning scheme. 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 LIBODB_QT_VERSION $libodb_qt.version.project_number$ULL +#define LIBODB_QT_VERSION_STR "$libodb_qt.version.project$" +#define LIBODB_QT_VERSION_ID "$libodb_qt.version.project_id$" + +#define LIBODB_QT_VERSION_MAJOR $libodb_qt.version.major$ +#define LIBODB_QT_VERSION_MINOR $libodb_qt.version.minor$ +#define LIBODB_QT_VERSION_PATCH $libodb_qt.version.patch$ + +#define LIBODB_QT_PRE_RELEASE $libodb_qt.version.pre_release$ + +#define LIBODB_QT_SNAPSHOT $libodb_qt.version.snapshot_sn$ULL +#define LIBODB_QT_SNAPSHOT_ID "$libodb_qt.version.snapshot_id$" + +#include + +$libodb.check(LIBODB_VERSION, LIBODB_SNAPSHOT)$ + +#endif // LIBODB_QT_VERSION diff --git a/odb/qt/version.hxx b/odb/qt/version.hxx index 5bea4c2..ba8c1b6 100644 --- a/odb/qt/version.hxx +++ b/odb/qt/version.hxx @@ -2,6 +2,16 @@ // copyright : Copyright (c) 2005-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file +#ifdef LIBODB_QT_BUILD2 +# include + +// @@ TODO: need to derive automatically (it is also hardcoded in *.options). +// +#define ODB_QT_VERSION 2046000 +#define ODB_QT_VERSION_STR "2.5.0-b.10" + +#else + #ifndef ODB_QT_VERSION_HXX #define ODB_QT_VERSION_HXX @@ -49,3 +59,4 @@ #include #endif // ODB_QT_VERSION_HXX +#endif // LIBODB_QT_BUILD2 diff --git a/repositories.manifest b/repositories.manifest new file mode 100644 index 0000000..595268d --- /dev/null +++ b/repositories.manifest @@ -0,0 +1,6 @@ +: 1 +summary: Qt ODB profile library repository + +: +role: prerequisite +location: ../libodb.git##HEAD diff --git a/tests/basics/buildfile b/tests/basics/buildfile new file mode 100644 index 0000000..870d7e8 --- /dev/null +++ b/tests/basics/buildfile @@ -0,0 +1,7 @@ +# file : tests/basics/buildfile +# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +import libs = libodb-qt%lib{odb-qt} + +exe{driver}: {hxx cxx}{*} $libs diff --git a/tests/basics/driver.cxx b/tests/basics/driver.cxx new file mode 100644 index 0000000..651095c --- /dev/null +++ b/tests/basics/driver.cxx @@ -0,0 +1,23 @@ +// file : tests/basics/driver.cxx +// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +// Basic test to make sure the library is usable. Functionality testing +// is done in the odb-tests package. + +#include +#include + +using namespace odb; + +int +main () +{ + try + { + throw qt::date_time::value_out_of_range (); + } + catch (const qt::exception&) + { + } +} diff --git a/tests/build/bootstrap.build b/tests/build/bootstrap.build new file mode 100644 index 0000000..c5c067b --- /dev/null +++ b/tests/build/bootstrap.build @@ -0,0 +1,9 @@ +# file : tests/build/bootstrap.build +# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +project = # Unnamed subproject. + +using config +using dist +using test diff --git a/tests/build/root.build b/tests/build/root.build new file mode 100644 index 0000000..ac9d361 --- /dev/null +++ b/tests/build/root.build @@ -0,0 +1,24 @@ +# file : tests/build/root.build +# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +cxx.std = 11 + +using cxx + +hxx{*}: extension = hxx +cxx{*}: extension = cxx + +if ($cxx.class == 'msvc') +{ + cxx.poptions += -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS + cxx.coptions += /wd4251 /wd4275 /wd4800 +} + +# Every exe{} in this subproject is by default a test. +# +exe{*}: test = true + +# Specify the test target for cross-testing. +# +test.target = $cxx.target diff --git a/tests/buildfile b/tests/buildfile new file mode 100644 index 0000000..3614001 --- /dev/null +++ b/tests/buildfile @@ -0,0 +1,5 @@ +# file : tests/buildfile +# copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +./: {*/ -build/} -- cgit v1.1