From bb67f32b2d92a5a7daea1d170ada978941948b66 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Sat, 9 Jun 2018 18:17:47 +0300 Subject: Add support for build2 build --- odb/mssql/buildfile | 104 ++++++++++++++++++++++++++++++ odb/mssql/details/.gitignore | 1 + odb/mssql/details/build2/config-stub.h | 6 ++ odb/mssql/details/build2/config-vc-stub.h | 6 ++ odb/mssql/details/build2/config-vc.h | 16 +++++ odb/mssql/details/build2/config.h | 18 ++++++ odb/mssql/details/config-vc.h | 6 ++ odb/mssql/details/config.hxx | 11 ++-- odb/mssql/details/export.hxx | 39 +++++++++++ odb/mssql/makefile | 2 +- odb/mssql/version-build2-stub.hxx | 5 ++ odb/mssql/version-build2.hxx | 0 odb/mssql/version-build2.hxx.in | 44 +++++++++++++ odb/mssql/version.hxx | 7 +- 14 files changed, 259 insertions(+), 6 deletions(-) create mode 100644 odb/mssql/buildfile create mode 100644 odb/mssql/details/.gitignore create mode 100644 odb/mssql/details/build2/config-stub.h create mode 100644 odb/mssql/details/build2/config-vc-stub.h create mode 100644 odb/mssql/details/build2/config-vc.h create mode 100644 odb/mssql/details/build2/config.h create mode 100644 odb/mssql/details/config-vc.h create mode 100644 odb/mssql/version-build2-stub.hxx create mode 100644 odb/mssql/version-build2.hxx create mode 100644 odb/mssql/version-build2.hxx.in (limited to 'odb') diff --git a/odb/mssql/buildfile b/odb/mssql/buildfile new file mode 100644 index 0000000..809e38e --- /dev/null +++ b/odb/mssql/buildfile @@ -0,0 +1,104 @@ +# file : odb/mssql/buildfile +# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +# license : ODB NCUEL; see accompanying LICENSE file + +import int_libs = libodb%lib{odb} + +# On Windows ODBC is a pre-installed system library so we pass it to the +# linker directly +# +imp_libs = + +if ($cc.target.class != 'windows') + import imp_libs = libunixodbc%lib{odbc} + +lib{odb-mssql}: {hxx ixx txx cxx}{* -version-build2} {hxx}{version-build2} \ + details/{hxx ixx txx cxx}{* -options} details/{hxx ixx cxx}{options} \ + details/build2/{h}{*} \ + $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-mssql}: bin.lib.version = @"-$version.project_id" +else + lib{odb-mssql}: bin.lib.version = @"-$version.major.$version.minor" + +cxx.poptions =+ "-I$out_root" "-I$src_root" -DLIBODB_MSSQL_BUILD2 +obja{*}: cxx.poptions += -DLIBODB_MSSQL_STATIC_BUILD +objs{*}: cxx.poptions += -DLIBODB_MSSQL_SHARED_BUILD + +if ($cc.target.class == 'windows') + cxx.libs += ($cxx.target.system == "mingw32" ? -lodbc32 : odbc32.lib) + +lib{odb-mssql}: cxx.export.poptions = "-I$out_root" "-I$src_root" \ + -DLIBODB_MSSQL_BUILD2 + +liba{odb-mssql}: cxx.export.poptions += -DLIBODB_MSSQL_STATIC +libs{odb-mssql}: cxx.export.poptions += -DLIBODB_MSSQL_SHARED + +lib{odb-mssql}: cxx.export.libs = $int_libs + +details/ +{ + if $cli.configured + { + cli.cxx{options}: cli{options} + + cli.options += --include-with-brackets --include-prefix odb/mssql/details \ +--guard-prefix LIBODB_MSSQL_DETAILS --generate-file-scanner \ +--cli-namespace odb::mssql::details::cli --long-usage --generate-specifier + + # Include generated cli files into the distribution and don't remove them + # when cleaning in src (so that clean results in a state identical to + # distributed). But don't install their headers since they are only used + # internally in the database implementation. + # + cli.cxx{*}: dist = true + cli.cxx{*}: clean = ($src_root != $out_root) + cli.cxx{*}: install = false + } + else + # No install for the pre-generated case. + # + hxx{options}@./ ixx{options}@./: install = false +} + +# Install into the odb/mssql/ subdirectory of, say, /usr/include/ recreating +# subdirectories. +# +install_include = [dir_path] include/odb/mssql/ + +{hxx ixx txx}{*}: install = $install_include +{hxx ixx txx}{*}: install.subdirs = true + +# We want these to be picked up whether LIBODB_MSSQL_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/mssql/details/.gitignore b/odb/mssql/details/.gitignore new file mode 100644 index 0000000..c6e608b --- /dev/null +++ b/odb/mssql/details/.gitignore @@ -0,0 +1 @@ +options.?xx diff --git a/odb/mssql/details/build2/config-stub.h b/odb/mssql/details/build2/config-stub.h new file mode 100644 index 0000000..c1421d9 --- /dev/null +++ b/odb/mssql/details/build2/config-stub.h @@ -0,0 +1,6 @@ +/* file : odb/mssql/details/build2/config-stub.h + * copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC + * license : ODB NCUEL; see accompanying LICENSE file + */ + +#include diff --git a/odb/mssql/details/build2/config-vc-stub.h b/odb/mssql/details/build2/config-vc-stub.h new file mode 100644 index 0000000..c5e7fd2 --- /dev/null +++ b/odb/mssql/details/build2/config-vc-stub.h @@ -0,0 +1,6 @@ +/* file : odb/mssql/details/build2/config-vc-stub.h + * copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC + * license : ODB NCUEL; see accompanying LICENSE file + */ + +#include diff --git a/odb/mssql/details/build2/config-vc.h b/odb/mssql/details/build2/config-vc.h new file mode 100644 index 0000000..6bb48cd --- /dev/null +++ b/odb/mssql/details/build2/config-vc.h @@ -0,0 +1,16 @@ +/* file : odb/mssql/details/build2/config-vc.h + * copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC + * license : ODB NCUEL; see accompanying LICENSE file + */ + +/* Configuration file for Windows/VC++ for the build2 build. */ + +#ifndef ODB_MSSQL_DETAILS_CONFIG_VC_H +#define ODB_MSSQL_DETAILS_CONFIG_VC_H + +/* Define LIBODB_MSSQL_BUILD2 for the installed case. */ +#ifndef LIBODB_MSSQL_BUILD2 +# define LIBODB_MSSQL_BUILD2 +#endif + +#endif /* ODB_MSSQL_DETAILS_CONFIG_VC_H */ diff --git a/odb/mssql/details/build2/config.h b/odb/mssql/details/build2/config.h new file mode 100644 index 0000000..631017e --- /dev/null +++ b/odb/mssql/details/build2/config.h @@ -0,0 +1,18 @@ +/* file : odb/mssql/details/build2/config.h + * copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC + * license : ODB NCUEL; see accompanying LICENSE file + */ + +/* Static configuration file for the build2 build. The installed case + (when LIBODB_MSSQL_BUILD2 is not necessarily defined) is the only + reason we have it. */ + +#ifndef ODB_MSSQL_DETAILS_CONFIG_H +#define ODB_MSSQL_DETAILS_CONFIG_H + +/* Define LIBODB_MSSQL_BUILD2 for the installed case. */ +#ifndef LIBODB_MSSQL_BUILD2 +# define LIBODB_MSSQL_BUILD2 +#endif + +#endif /* ODB_MSSQL_DETAILS_CONFIG_H */ diff --git a/odb/mssql/details/config-vc.h b/odb/mssql/details/config-vc.h new file mode 100644 index 0000000..79d5820 --- /dev/null +++ b/odb/mssql/details/config-vc.h @@ -0,0 +1,6 @@ +/* file : odb/mssql/details/config-vc.h + * copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC + * license : ODB NCUEL; see accompanying LICENSE file + */ + +/* Dummy configuration file for Windows/VC++. */ diff --git a/odb/mssql/details/config.hxx b/odb/mssql/details/config.hxx index 65b9652..b3ab3db 100644 --- a/odb/mssql/details/config.hxx +++ b/odb/mssql/details/config.hxx @@ -7,11 +7,14 @@ // no pre -#ifdef _MSC_VER -#elif defined(ODB_COMPILER) +#ifdef ODB_COMPILER # error libodb-mssql header included in odb-compiled header -#else -# include +#elif !defined(LIBODB_MSSQL_BUILD2) +# ifdef _MSC_VER +# include +# else +# include +# endif #endif // no post diff --git a/odb/mssql/details/export.hxx b/odb/mssql/details/export.hxx index 694ceb4..98d2057 100644 --- a/odb/mssql/details/export.hxx +++ b/odb/mssql/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_MSSQL_BUILD2 + +#if defined(LIBODB_MSSQL_STATIC) // Using static. +# define LIBODB_MSSQL_EXPORT +#elif defined(LIBODB_MSSQL_STATIC_BUILD) // Building static. +# define LIBODB_MSSQL_EXPORT +#elif defined(LIBODB_MSSQL_SHARED) // Using shared. +# ifdef _WIN32 +# define LIBODB_MSSQL_EXPORT __declspec(dllimport) +# else +# define LIBODB_MSSQL_EXPORT +# endif +#elif defined(LIBODB_MSSQL_SHARED_BUILD) // Building shared. +# ifdef _WIN32 +# define LIBODB_MSSQL_EXPORT __declspec(dllexport) +# else +# define LIBODB_MSSQL_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_MSSQL_EXPORT // Using static or shared. +#endif + +#else // LIBODB_MSSQL_BUILD2 + #ifdef LIBODB_MSSQL_STATIC_LIB # define LIBODB_MSSQL_EXPORT #else @@ -35,6 +72,8 @@ # endif #endif +#endif // LIBODB_MSSQL_BUILD2 + #include #endif // ODB_MSSQL_DETAILS_EXPORT_HXX diff --git a/odb/mssql/makefile b/odb/mssql/makefile index e3f0df0..4ed1f85 100644 --- a/odb/mssql/makefile +++ b/odb/mssql/makefile @@ -102,7 +102,7 @@ $(dist): headers_dist = $(subst $(src_base)/,,$(shell find $(src_base) \ $(dist): gen_headers := $(cli_tun:.cli=.hxx) $(cli_tun:.cli=.ixx) $(dist): export headers = $(sort $(headers_dist) $(gen_headers)) $(dist): gen_dist := $(gen) -$(dist): data_dist := $(cli_tun) details/config.h.in +$(dist): data_dist := $(cli_tun) details/config.h.in details/config-vc.h $(dist): export extra_dist := $(data_dist) \ libodb-mssql-vc8.vcproj libodb-mssql-vc9.vcproj \ libodb-mssql-vc10.vcxproj libodb-mssql-vc10.vcxproj.filters \ diff --git a/odb/mssql/version-build2-stub.hxx b/odb/mssql/version-build2-stub.hxx new file mode 100644 index 0000000..7102793 --- /dev/null +++ b/odb/mssql/version-build2-stub.hxx @@ -0,0 +1,5 @@ +// file : odb/mssql/version-build2-stub.hxx +// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC +// license : ODB NCUEL; see accompanying LICENSE file + +#include diff --git a/odb/mssql/version-build2.hxx b/odb/mssql/version-build2.hxx new file mode 100644 index 0000000..e69de29 diff --git a/odb/mssql/version-build2.hxx.in b/odb/mssql/version-build2.hxx.in new file mode 100644 index 0000000..e71a6d2 --- /dev/null +++ b/odb/mssql/version-build2.hxx.in @@ -0,0 +1,44 @@ +// file : odb/mssql/version-build2.hxx.in +// copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC +// license : ODB NCUEL; see accompanying LICENSE file + +#ifndef LIBODB_MSSQL_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_MSSQL_VERSION $libodb-mssql.version.project_number$ULL +#define LIBODB_MSSQL_VERSION_STR "$libodb-mssql.version.project$" +#define LIBODB_MSSQL_VERSION_ID "$libodb-mssql.version.project_id$" + +#define LIBODB_MSSQL_VERSION_MAJOR $libodb-mssql.version.major$ +#define LIBODB_MSSQL_VERSION_MINOR $libodb-mssql.version.minor$ +#define LIBODB_MSSQL_VERSION_PATCH $libodb-mssql.version.patch$ + +#define LIBODB_MSSQL_PRE_RELEASE $libodb-mssql.version.pre_release$ + +#define LIBODB_MSSQL_SNAPSHOT $libodb-mssql.version.snapshot_sn$ULL +#define LIBODB_MSSQL_SNAPSHOT_ID "$libodb-mssql.version.snapshot_id$" + +#include + +$libodb.check(LIBODB_VERSION, LIBODB_SNAPSHOT)$ + +#endif // LIBODB_MSSQL_VERSION diff --git a/odb/mssql/version.hxx b/odb/mssql/version.hxx index 6af0ace..391cef2 100644 --- a/odb/mssql/version.hxx +++ b/odb/mssql/version.hxx @@ -2,13 +2,17 @@ // copyright : Copyright (c) 2005-2018 Code Synthesis Tools CC // license : ODB NCUEL; see accompanying LICENSE file +#ifdef LIBODB_MSSQL_BUILD2 +# include +#else + #ifndef ODB_MSSQL_VERSION_HXX #define ODB_MSSQL_VERSION_HXX #include -#include #include +#include // Version format is AABBCCDD where // @@ -42,3 +46,4 @@ #include #endif // ODB_MSSQL_VERSION_HXX +#endif // LIBODB_MSSQL_BUILD2 -- cgit v1.1