From 134b4d4a13c661dc2adcfb43295b883b7fa593ea Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 29 Apr 2024 09:22:23 +0200 Subject: Redo version.hxx as version.hxx.in in ODB compiler --- README.md | 8 ++++---- odb/odb/buildfile | 14 +++++++++++++- odb/odb/generator.cxx | 5 +++-- odb/odb/odb.cxx | 13 +++++++++---- odb/odb/version.hxx | 37 ------------------------------------- odb/odb/version.hxx.in | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 79 insertions(+), 48 deletions(-) create mode 100644 odb/odb/version.hxx.in diff --git a/README.md b/README.md index f15e58c..d424a12 100644 --- a/README.md +++ b/README.md @@ -96,10 +96,10 @@ b install: ../odb-install/odb/ ``` Note that if building manually (that is, without `bdep`) and in-source, then -the checked out `libodb/odb/version.hxx` and `libodb-*/odb/*/version.hxx` -files will be overwritten during the build but these changes should be -ignored. To do this automatically, run: +the checked out `odb/odb/version.hxx`, `libodb/odb/version.hxx`, and +`libodb-*/odb/*/version.hxx` files will be overwritten during the build but +these changes should be ignored. To do this automatically, run: ``` -git update-index --assume-unchanged libodb/odb/version.hxx libodb-*/odb/*/version.hxx +git update-index --assume-unchanged odb/odb/version.hxx libodb/odb/version.hxx libodb-*/odb/*/version.hxx ``` diff --git a/odb/odb/buildfile b/odb/odb/buildfile index 34a6329..ccfb49b 100644 --- a/odb/odb/buildfile +++ b/odb/odb/buildfile @@ -78,7 +78,19 @@ switch $cxx.target.system plugin{odb}: cxx.loptions += -undefined dynamic_lookup } -libus{odb}: {hxx ixx txx cxx}{** -odb -options -pregenerated/**} $libs +libus{odb}: {hxx ixx txx cxx}{** -odb -version -options -pregenerated/**} \ + hxx{version} $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}: in{version} $src_root/manifest +hxx{version}: +{ + dist = true + clean = ($src_root != $out_root) +} # Build options. # diff --git a/odb/odb/generator.cxx b/odb/odb/generator.cxx index ec0fefe..dfdd3bf 100644 --- a/odb/odb/generator.cxx +++ b/odb/odb/generator.cxx @@ -520,11 +520,12 @@ generate (options const& ops, "// Begin prologue.\n//", "//\n// End prologue."); - // Version check. + // Version check (see similar check in odb.cxx for background). // hxx << "#include " << endl << endl - << "#if (ODB_VERSION != " << ODB_VERSION << "UL)" << endl + << "#if LIBODB_VERSION_FULL != " << ODB_COMPILER_VERSION << "ULL || \\" << endl + << " LIBODB_SNAPSHOT != " << ODB_COMPILER_SNAPSHOT << "ULL" << endl << "#error ODB runtime version mismatch" << endl << "#endif" << endl << endl; diff --git a/odb/odb/odb.cxx b/odb/odb/odb.cxx index 39079ea..fd32678 100644 --- a/odb/odb/odb.cxx +++ b/odb/odb/odb.cxx @@ -622,8 +622,8 @@ main (int argc, char* argv[]) o << "# build2 buildfile odb" << endl << "export.metadata = 1 odb" << endl << "odb.name = [string] odb" << endl - << "odb.version = [string] '" << ODB_COMPILER_VERSION_STR << '\'' << endl - << "odb.checksum = [string] '" << ODB_COMPILER_VERSION_STR << '\'' << endl + << "odb.version = [string] '" << ODB_COMPILER_VERSION_FULL << '\'' << endl + << "odb.checksum = [string] '" << ODB_COMPILER_VERSION_FULL << '\'' << endl << "odb.environment = [strings] CPATH CPLUS_INCLUDE_PATH GCC_EXEC_PREFIX COMPILER_PATH" << endl; return 0; @@ -742,7 +742,7 @@ main (int argc, char* argv[]) { ostringstream ostr; - ostr << ODB_COMPILER_VERSION; + ostr << ODB_COMPILER_VERSION_OLD; args.push_back ("-DODB_COMPILER_VERSION=" + ostr.str ()); } @@ -957,9 +957,14 @@ main (int argc, char* argv[]) // Make sure ODB compiler and libodb versions are compatible. // + // Note that the snapshot comparision is only necessary of the + // version is a pre-release but having it always won't hurt (it + // will be 0 for final versions). + // os << "#include " << endl << endl - << "#if ODB_VERSION != " << ODB_VERSION << endl + << "#if LIBODB_VERSION_FULL != " << ODB_COMPILER_VERSION << "ULL" + " || LIBODB_SNAPSHOT != " << ODB_COMPILER_SNAPSHOT << "ULL" << endl << "# error incompatible ODB compiler and runtime " << "versions" << endl << "#endif" << endl diff --git a/odb/odb/version.hxx b/odb/odb/version.hxx index 4ad389a..e69de29 100644 --- a/odb/odb/version.hxx +++ b/odb/odb/version.hxx @@ -1,37 +0,0 @@ -// file : odb/version.hxx -// license : GNU GPL v3; see accompanying LICENSE file - -#ifndef ODB_VERSION_HXX -#define ODB_VERSION_HXX - -// Version format is AABBCCDD where -// -// AA - major version number -// BB - minor version number -// CC - bugfix version number -// DD - alpha / beta (DD + 50) version number -// -// When DD is not 00, 1 is subtracted from AABBCC. For example: -// -// Version AABBCCDD -// 2.0.0 02000000 -// 2.1.0 02010000 -// 2.1.1 02010100 -// 2.2.0.a1 02019901 -// 3.0.0.b2 02999952 -// - -// ODB interface version: minor, major, and alpha/beta versions. -// -#define ODB_VERSION 20476 -#define ODB_VERSION_STR "2.5-b.26" - -// ODB compiler version: interface version plus the bugfix version. -// -// NOTE: remember to update metadata to full version when switching to -// version.hxx.in. -// -#define ODB_COMPILER_VERSION 2049976 -#define ODB_COMPILER_VERSION_STR "2.5.0-b.26" - -#endif // ODB_VERSION_HXX diff --git a/odb/odb/version.hxx.in b/odb/odb/version.hxx.in new file mode 100644 index 0000000..a131c03 --- /dev/null +++ b/odb/odb/version.hxx.in @@ -0,0 +1,50 @@ +// file : odb/version.hxx.in +// license : GNU GPL v3; see accompanying LICENSE file + +#ifndef ODB_COMPILER_VERSION // Note: using the version macro itself. + +// New numeric version format is AAAAABBBBBCCCCCDDDE where: +// +// AAAAA - major version number +// BBBBB - minor version number +// CCCCC - bugfix version number +// DDD - alpha / beta (DDD + 500) version number +// E - final (0) / snapshot (1) +// +// When DDDE is not 0, 1 is subtracted from AAAAABBBBBCCCCC. For example: +// +// Version AAAAABBBBBCCCCCDDDE +// +// 0.1.0 0000000001000000000 +// 0.1.2 0000000001000020000 +// 1.2.3 0000100002000030000 +// 2.2.0-a.1 0000200001999990010 +// 3.0.0-b.2 0000299999999995020 +// 2.2.0-a.1.z 0000200001999990011 +// +#define ODB_COMPILER_VERSION $odb.version.project_number$ULL +#define ODB_COMPILER_VERSION_STR "$odb.version.project$" +#define ODB_COMPILER_VERSION_ID "$odb.version.project_id$" +#define ODB_COMPILER_VERSION_FULL "$odb.version$" + +#define ODB_COMPILER_SNAPSHOT $odb.version.snapshot_sn$ULL + +// Old/deprecated numeric version format is AABBCCDD where: +// +// AA - major version number +// BB - minor version number +// CC - bugfix version number +// DD - alpha / beta (DD + 50) version number +// +// When DD is not 00, 1 is subtracted from AABBCC. For example: +// +// Version AABBCCDD +// 2.0.0 02000000 +// 2.1.0 02010000 +// 2.1.1 02010100 +// 2.2.0.a1 02019901 +// 3.0.0.b2 02999952 +// +#define ODB_COMPILER_VERSION_OLD 2049976 + +#endif // ODB_COMPILER_VERSION -- cgit v1.1