diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2018-06-09 18:17:47 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2018-06-18 14:50:25 +0300 |
commit | bb67f32b2d92a5a7daea1d170ada978941948b66 (patch) | |
tree | 7794ab51a1842cd1485437624cfe2205594899c2 | |
parent | ac98675021881fc82489f7490b2b38036c5ca50a (diff) |
Add support for build2 build
30 files changed, 433 insertions, 7 deletions
@@ -1,9 +1,19 @@ # Compiler/linker output. # +*.d +*.ii *.o -*.o.d +*.obj *.so +*.dll *.a +*.lib +*.exp +*.exe +*.exe.dlls/ +*.exe.manifest +*.pc + *.l *.l.cpp-options diff --git a/README-GIT b/README-GIT new file mode 100644 index 0000000..173c041 --- /dev/null +++ b/README-GIT @@ -0,0 +1,5 @@ +The checked out odb/mssql/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/mssql/version-build2.hxx 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..3b9d452 --- /dev/null +++ b/build/bootstrap.build @@ -0,0 +1,11 @@ +# file : build/bootstrap.build +# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +# license : ODB NCUEL; see accompanying LICENSE file + +project = libodb-mssql + +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..12d640c --- /dev/null +++ b/build/export.build @@ -0,0 +1,10 @@ +# file : build/export.build +# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +# license : ODB NCUEL; see accompanying LICENSE file + +$out_root/ +{ + include odb/mssql/ +} + +export $out_root/odb/mssql/lib{odb-mssql} diff --git a/build/root.build b/build/root.build new file mode 100644 index 0000000..34b68db --- /dev/null +++ b/build/root.build @@ -0,0 +1,20 @@ +# file : build/root.build +# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +# license : ODB NCUEL; see accompanying LICENSE file + +cxx.std = 11 + +using cxx + +hxx{*}: extension = hxx +ixx{*}: extension = ixx +txx{*}: extension = txx +cxx{*}: extension = cxx + +# Load the cli module but only if it's available. This way a distribution +# that includes pre-generated files can be built without installing cli. +# This is also the reason why we need to explicitly spell out individual +# source file prerequisites instead of using the cli.cxx{} group (it won't +# be there unless the module is configured). +# +using? cli diff --git a/buildfile b/buildfile new file mode 100644 index 0000000..ca52402 --- /dev/null +++ b/buildfile @@ -0,0 +1,10 @@ +# file : buildfile +# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +# license : ODB NCUEL; see accompanying LICENSE file + +./: {*/ -build/ -m4/} doc{NCUEL 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..e3fff4d --- /dev/null +++ b/manifest @@ -0,0 +1,21 @@ +: 1 +name: libodb-mssql +version: 2.5.0-b.8.z +summary: Microsoft SQL Server ODB runtime library +license: ODB NCUEL; Non-Commercial Use and Evaluation License +license: proprietary +tags: c++, orm, mssql, database, relational, object, persistence, sql, microsoft +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-mssql/ +email: odb-users@codesynthesis.com +build-email: odb-builds@codesynthesis.com +build-include: windows* +build-exclude: * ; Requires not yet packaged libunixodbc (unixODBC) +requires: c++11 +requires: ? libunixodbc; Only on UNIX +depends: * build2 >= 0.7.0- +depends: * bpkg >= 0.7.0- +depends: libodb [2.5.0-b.8.1 2.5.0-b.9) 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 <odb/mssql/details/config.h> 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 <odb/mssql/details/config-vc.h> 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 <odb/mssql/details/config.h> +#elif !defined(LIBODB_MSSQL_BUILD2) +# ifdef _MSC_VER +# include <odb/mssql/details/config-vc.h> +# else +# include <odb/mssql/details/config.h> +# 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 <odb/mssql/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_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 <odb/post.hxx> #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 <odb/mssql/version.hxx> diff --git a/odb/mssql/version-build2.hxx b/odb/mssql/version-build2.hxx new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/odb/mssql/version-build2.hxx 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 <odb/version.hxx> + +$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 <odb/mssql/version-build2.hxx> +#else + #ifndef ODB_MSSQL_VERSION_HXX #define ODB_MSSQL_VERSION_HXX #include <odb/pre.hxx> -#include <odb/version.hxx> #include <odb/mssql/details/config.hxx> +#include <odb/version.hxx> // Version format is AABBCCDD where // @@ -42,3 +46,4 @@ #include <odb/post.hxx> #endif // ODB_MSSQL_VERSION_HXX +#endif // LIBODB_MSSQL_BUILD2 diff --git a/repositories.manifest b/repositories.manifest new file mode 100644 index 0000000..67cb445 --- /dev/null +++ b/repositories.manifest @@ -0,0 +1,6 @@ +: 1 +summary: Microsoft SQL Server ODB runtime library repository + +: +role: prerequisite +location: ../libodb.git##HEAD diff --git a/tests/.gitignore b/tests/.gitignore new file mode 100644 index 0000000..e54525b --- /dev/null +++ b/tests/.gitignore @@ -0,0 +1 @@ +driver diff --git a/tests/basics/buildfile b/tests/basics/buildfile new file mode 100644 index 0000000..3ab62da --- /dev/null +++ b/tests/basics/buildfile @@ -0,0 +1,7 @@ +# file : tests/basics/buildfile +# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +# license : ODB NCUEL; see accompanying LICENSE file + +import libs = libodb-mssql%lib{odb-mssql} + +exe{driver}: {hxx cxx}{*} $libs diff --git a/tests/basics/driver.cxx b/tests/basics/driver.cxx new file mode 100644 index 0000000..725203a --- /dev/null +++ b/tests/basics/driver.cxx @@ -0,0 +1,38 @@ +// file : tests/basics/driver.cxx +// copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +// license : ODB NCUEL; see accompanying LICENSE file + +// Basic test to make sure the library is usable. Functionality testing +// is done in the odb-tests package. + +#include <cassert> +#include <sstream> + +#include <odb/mssql/database.hxx> +#include <odb/mssql/exceptions.hxx> +#include <odb/mssql/transaction.hxx> + +using namespace odb::mssql; + +int +main () +{ + { + std::ostringstream os; + database::print_usage (os); + assert (!os.str ().empty ()); + } + + // We can't really do much here since that would require a database. We can + // create a fake database object as long as we don't expect to get a valid + // connection. + // + database db ("john", "secret", "dummy whammy"); + + try + { + transaction t (db.begin ()); + assert (false); + } + catch (const database_exception&) {} +} diff --git a/tests/build/.gitignore b/tests/build/.gitignore new file mode 100644 index 0000000..225c27f --- /dev/null +++ b/tests/build/.gitignore @@ -0,0 +1 @@ +config.build diff --git a/tests/build/bootstrap.build b/tests/build/bootstrap.build new file mode 100644 index 0000000..cc1f8f2 --- /dev/null +++ b/tests/build/bootstrap.build @@ -0,0 +1,9 @@ +# file : tests/build/bootstrap.build +# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +# license : ODB NCUEL; 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..a55d412 --- /dev/null +++ b/tests/build/root.build @@ -0,0 +1,18 @@ +# file : tests/build/root.build +# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +# license : ODB NCUEL; see accompanying LICENSE file + +cxx.std = 11 + +using cxx + +hxx{*}: extension = hxx +cxx{*}: extension = cxx + +# 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..6bf7425 --- /dev/null +++ b/tests/buildfile @@ -0,0 +1,5 @@ +# file : tests/buildfile +# copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC +# license : ODB NCUEL; see accompanying LICENSE file + +./: {*/ -build/} |