diff options
Diffstat (limited to 'odb')
-rw-r--r-- | odb/mysql/buildfile | 108 | ||||
-rw-r--r-- | odb/mysql/details/build2/config-stub.h | 6 | ||||
-rw-r--r-- | odb/mysql/details/build2/config-vc-stub.h | 6 | ||||
-rw-r--r-- | odb/mysql/details/build2/config-vc.h | 16 | ||||
-rw-r--r-- | odb/mysql/details/build2/config.h | 18 | ||||
-rw-r--r-- | odb/mysql/details/config-vc.h | 13 | ||||
-rw-r--r-- | odb/mysql/details/config.hxx | 25 | ||||
-rw-r--r-- | odb/mysql/details/export.hxx | 39 | ||||
-rw-r--r-- | odb/mysql/makefile | 2 | ||||
-rw-r--r-- | odb/mysql/mysql-types.hxx | 14 | ||||
-rw-r--r-- | odb/mysql/version-build2-stub.hxx | 5 | ||||
-rw-r--r-- | odb/mysql/version-build2.hxx | 0 | ||||
-rw-r--r-- | odb/mysql/version-build2.hxx.in | 64 | ||||
-rw-r--r-- | odb/mysql/version.hxx | 5 |
14 files changed, 310 insertions, 11 deletions
diff --git a/odb/mysql/buildfile b/odb/mysql/buildfile new file mode 100644 index 0000000..9fb2275 --- /dev/null +++ b/odb/mysql/buildfile @@ -0,0 +1,108 @@ +# file : odb/mysql/buildfile +# copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +client_lib = 'mysql' +#client_lib = 'mariadb' + +import int_libs = libodb%lib{odb} + +if ($client_lib == 'mysql') + import int_libs += libmysqlclient%lib{mysqlclient} +else + import int_libs += libmariadb%lib{mariadb} + +lib{odb-mysql}: {hxx ixx txx cxx}{* -version-build2} {hxx}{version-build2} \ + details/{hxx ixx txx cxx}{* -options} details/{hxx ixx cxx}{options} \ + details/build2/{h}{*} \ + $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/file{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-mysql}: bin.lib.version = @"-$version.project_id" +else + lib{odb-mysql}: bin.lib.version = @"-$version.major.$version.minor" + +cxx.poptions =+ "-I$out_root" "-I$src_root" -DLIBODB_MYSQL_BUILD2 + +if ($client_lib == 'mariadb') + cxx.poptions += -DLIBODB_MYSQL_MARIADB + +obja{*}: cxx.poptions += -DLIBODB_MYSQL_STATIC_BUILD +objs{*}: cxx.poptions += -DLIBODB_MYSQL_SHARED_BUILD + +lib{odb-mysql}: cxx.export.poptions = "-I$out_root" "-I$src_root" \ + -DLIBODB_MYSQL_BUILD2 + +if ($client_lib == 'mariadb') + lib{odb-mysql}: cxx.export.poptions += -DLIBODB_MYSQL_MARIADB + +liba{odb-mysql}: cxx.export.poptions += -DLIBODB_MYSQL_STATIC +libs{odb-mysql}: cxx.export.poptions += -DLIBODB_MYSQL_SHARED + +lib{odb-mysql}: cxx.export.libs = $int_libs + +details/: +{ + if $cli.configured + { + cli.cxx{options}: cli{options} + + cli.options += --include-with-brackets --include-prefix odb/mysql/details \ +--guard-prefix LIBODB_MYSQL_DETAILS --generate-file-scanner \ +--cli-namespace odb::mysql::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/mysql/ subdirectory of, say, /usr/include/ recreating +# subdirectories. +# +install_include = [dir_path] include/odb/mysql/ + +{hxx ixx txx}{*}: install = $install_include +{hxx ixx txx}{*}: install.subdirs = true + +# We want these to be picked up whether LIBODB_MYSQL_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.id == '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/mysql/details/build2/config-stub.h b/odb/mysql/details/build2/config-stub.h new file mode 100644 index 0000000..1ea3607 --- /dev/null +++ b/odb/mysql/details/build2/config-stub.h @@ -0,0 +1,6 @@ +/* file : odb/mysql/details/build2/config-stub.h + * copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC + * license : GNU GPL v2; see accompanying LICENSE file + */ + +#include <odb/mysql/details/config.h> diff --git a/odb/mysql/details/build2/config-vc-stub.h b/odb/mysql/details/build2/config-vc-stub.h new file mode 100644 index 0000000..f6f1e21 --- /dev/null +++ b/odb/mysql/details/build2/config-vc-stub.h @@ -0,0 +1,6 @@ +/* file : odb/mysql/details/build2/config-vc-stub.h + * copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC + * license : GNU GPL v2; see accompanying LICENSE file + */ + +#include <odb/mysql/details/config-vc.h> diff --git a/odb/mysql/details/build2/config-vc.h b/odb/mysql/details/build2/config-vc.h new file mode 100644 index 0000000..bf6f84e --- /dev/null +++ b/odb/mysql/details/build2/config-vc.h @@ -0,0 +1,16 @@ +/* file : odb/mysql/details/build2/config-vc.h + * copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC + * license : GNU GPL v2; see accompanying LICENSE file + */ + +/* Configuration file for Windows/VC++ for the build2 build. */ + +#ifndef ODB_MYSQL_DETAILS_CONFIG_VC_H +#define ODB_MYSQL_DETAILS_CONFIG_VC_H + +/* Define LIBODB_MYSQL_BUILD2 for the installed case. */ +#ifndef LIBODB_MYSQL_BUILD2 +# define LIBODB_MYSQL_BUILD2 +#endif + +#endif /* ODB_MYSQL_DETAILS_CONFIG_VC_H */ diff --git a/odb/mysql/details/build2/config.h b/odb/mysql/details/build2/config.h new file mode 100644 index 0000000..c88e476 --- /dev/null +++ b/odb/mysql/details/build2/config.h @@ -0,0 +1,18 @@ +/* file : odb/mysql/details/build2/config.h + * copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC + * license : GNU GPL v2; see accompanying LICENSE file + */ + +/* Static configuration file for the build2 build. The installed case + (when LIBODB_MYSQL_BUILD2 is not necessarily defined) is the only + reason we have it. */ + +#ifndef ODB_MYSQL_DETAILS_CONFIG_H +#define ODB_MYSQL_DETAILS_CONFIG_H + +/* Define LIBODB_MYSQL_BUILD2 for the installed case. */ +#ifndef LIBODB_MYSQL_BUILD2 +# define LIBODB_MYSQL_BUILD2 +#endif + +#endif /* ODB_MYSQL_DETAILS_CONFIG_H */ diff --git a/odb/mysql/details/config-vc.h b/odb/mysql/details/config-vc.h new file mode 100644 index 0000000..c480f67 --- /dev/null +++ b/odb/mysql/details/config-vc.h @@ -0,0 +1,13 @@ +/* file : odb/mysql/details/config-vc.h + * copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC + * license : GNU GPL v2; see accompanying LICENSE file + */ + +#ifndef ODB_MYSQL_DETAILS_CONFIG_VC_H +#define ODB_MYSQL_DETAILS_CONFIG_VC_H + +#if !defined(LIBODB_MYSQL_INCLUDE_SHORT) && !defined (LIBODB_MYSQL_INCLUDE_LONG) +# define LIBODB_MYSQL_INCLUDE_SHORT 1 +#endif + +#endif /* ODB_MYSQL_DETAILS_CONFIG_VC_H */ diff --git a/odb/mysql/details/config.hxx b/odb/mysql/details/config.hxx index d29e9a5..f05044c 100644 --- a/odb/mysql/details/config.hxx +++ b/odb/mysql/details/config.hxx @@ -7,14 +7,25 @@ // no pre -#ifdef _MSC_VER -# if !defined(LIBODB_MYSQL_INCLUDE_SHORT) && !defined (LIBODB_MYSQL_INCLUDE_LONG) -# define LIBODB_MYSQL_INCLUDE_SHORT 1 -# endif -#elif defined(ODB_COMPILER) +#ifdef ODB_COMPILER # error libodb-mysql header included in odb-compiled header -#else -# include <odb/mysql/details/config.h> +#elif !defined(LIBODB_MYSQL_BUILD2) +# ifdef _MSC_VER +# include <odb/mysql/details/config-vc.h> +# else +# include <odb/mysql/details/config.h> +# endif +#endif + +// LIBODB_MYSQL_BUILD2 macro can be defined either by the buildfile or by the +// included odb/mysql/details/config*.h (see above). +// +#ifdef LIBODB_MYSQL_BUILD2 +# ifdef LIBODB_MYSQL_INCLUDE_SHORT +# error mysql headers must be included with mysql/ prefix +# elif !defined(LIBODB_MYSQL_INCLUDE_LONG) +# define LIBODB_MYSQL_INCLUDE_LONG 1 +# endif #endif // no post diff --git a/odb/mysql/details/export.hxx b/odb/mysql/details/export.hxx index eeccf07..337ea99 100644 --- a/odb/mysql/details/export.hxx +++ b/odb/mysql/details/export.hxx @@ -9,6 +9,43 @@ #include <odb/mysql/details/config.hxx> +// 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_MYSQL_BUILD2 + +#if defined(LIBODB_MYSQL_STATIC) // Using static. +# define LIBODB_MYSQL_EXPORT +#elif defined(LIBODB_MYSQL_STATIC_BUILD) // Building static. +# define LIBODB_MYSQL_EXPORT +#elif defined(LIBODB_MYSQL_SHARED) // Using shared. +# ifdef _WIN32 +# define LIBODB_MYSQL_EXPORT __declspec(dllimport) +# else +# define LIBODB_MYSQL_EXPORT +# endif +#elif defined(LIBODB_MYSQL_SHARED_BUILD) // Building shared. +# ifdef _WIN32 +# define LIBODB_MYSQL_EXPORT __declspec(dllexport) +# else +# define LIBODB_MYSQL_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_MYSQL_EXPORT // Using static or shared. +#endif + +#else // LIBODB_MYSQL_BUILD2 + #ifdef LIBODB_MYSQL_STATIC_LIB # define LIBODB_MYSQL_EXPORT #else @@ -35,6 +72,8 @@ # endif #endif +#endif // LIBODB_MYSQL_BUILD2 + #include <odb/post.hxx> #endif // ODB_MYSQL_DETAILS_EXPORT_HXX diff --git a/odb/mysql/makefile b/odb/mysql/makefile index 0d274ef..60e76dc 100644 --- a/odb/mysql/makefile +++ b/odb/mysql/makefile @@ -106,7 +106,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-mysql-vc8.vcproj libodb-mysql-vc9.vcproj \ libodb-mysql-vc10.vcxproj libodb-mysql-vc10.vcxproj.filters \ diff --git a/odb/mysql/mysql-types.hxx b/odb/mysql/mysql-types.hxx index cd92d41..362d618 100644 --- a/odb/mysql/mysql-types.hxx +++ b/odb/mysql/mysql-types.hxx @@ -10,10 +10,18 @@ typedef char my_bool; typedef struct st_mysql_bind MYSQL_BIND; -#ifdef LIBODB_MYSQL_INCLUDE_SHORT -# include <mysql_time.h> +// MariaDB defines time types directly in mysql.h. Note that MariaDB is only +// supported by the build2 build so we include the header as <mysql/mysql.h> +// unconditionally. +// +#ifdef LIBODB_MYSQL_MARIADB +# include <mysql/mysql.h> #else -# include <mysql/mysql_time.h> +# ifdef LIBODB_MYSQL_INCLUDE_SHORT +# include <mysql_time.h> +# else +# include <mysql/mysql_time.h> +# endif #endif #endif // ODB_MYSQL_MYSQL_TYPES_HXX diff --git a/odb/mysql/version-build2-stub.hxx b/odb/mysql/version-build2-stub.hxx new file mode 100644 index 0000000..57ff4d9 --- /dev/null +++ b/odb/mysql/version-build2-stub.hxx @@ -0,0 +1,5 @@ +// file : odb/mysql/version-build2-stub.hxx +// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#include <odb/mysql/version.hxx> diff --git a/odb/mysql/version-build2.hxx b/odb/mysql/version-build2.hxx new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/odb/mysql/version-build2.hxx diff --git a/odb/mysql/version-build2.hxx.in b/odb/mysql/version-build2.hxx.in new file mode 100644 index 0000000..56aba98 --- /dev/null +++ b/odb/mysql/version-build2.hxx.in @@ -0,0 +1,64 @@ +// file : odb/mysql/version-build2.hxx.in +// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef LIBODB_MYSQL_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_MYSQL_VERSION $libodb-mysql.version.project_number$ULL +#define LIBODB_MYSQL_VERSION_STR "$libodb-mysql.version.project$" +#define LIBODB_MYSQL_VERSION_ID "$libodb-mysql.version.project_id$" + +#define LIBODB_MYSQL_VERSION_MAJOR $libodb-mysql.version.major$ +#define LIBODB_MYSQL_VERSION_MINOR $libodb-mysql.version.minor$ +#define LIBODB_MYSQL_VERSION_PATCH $libodb-mysql.version.patch$ + +#define LIBODB_MYSQL_PRE_RELEASE $libodb-mysql.version.pre_release$ + +#define LIBODB_MYSQL_SNAPSHOT $libodb-mysql.version.snapshot_sn$ULL +#define LIBODB_MYSQL_SNAPSHOT_ID "$libodb-mysql.version.snapshot_id$" + +#ifdef LIBODB_MYSQL_MARIADB +# include <mysql/mariadb_version.h> + +// We support MariaDB starting from 10.2.2 when the library started to be +// named as as mariadb, rather than mysqlclient. Before that we just don't +// distinguish it from the MySQL client library. +// +# if !defined(MYSQL_VERSION_ID) || MYSQL_VERSION_ID < 100202 +# error unexpected MariaDB version detected +# endif +#else +# include <mysql/mysql_version.h> + +// Check that we have a compatible MySQL version (5.0.3 or later). +// +# if !defined(MYSQL_VERSION_ID) || MYSQL_VERSION_ID < 50003 +# error incompatible MySQL version detected +# endif +#endif + +#include <odb/version.hxx> + +$libodb.check(LIBODB_VERSION, LIBODB_SNAPSHOT)$ + +#endif // LIBODB_MYSQL_VERSION diff --git a/odb/mysql/version.hxx b/odb/mysql/version.hxx index 70f760f..232c215 100644 --- a/odb/mysql/version.hxx +++ b/odb/mysql/version.hxx @@ -2,6 +2,10 @@ // copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file +#ifdef LIBODB_MYSQL_BUILD2 +# include <odb/mysql/version-build2.hxx> +#else + #ifndef ODB_MYSQL_VERSION_HXX #define ODB_MYSQL_VERSION_HXX @@ -55,3 +59,4 @@ #include <odb/post.hxx> #endif // ODB_MYSQL_VERSION_HXX +#endif // LIBODB_MYSQL_BUILD2 |