summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2024-04-29 09:22:23 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2024-04-29 10:43:54 +0200
commit134b4d4a13c661dc2adcfb43295b883b7fa593ea (patch)
tree53fc0e19d3bd1cab1b3df11b0bad5692c578e606
parent22dfcdb3f14eb69556a578ab1e2862d5ad0c0801 (diff)
Redo version.hxx as version.hxx.in in ODB compiler
-rw-r--r--README.md8
-rw-r--r--odb/odb/buildfile14
-rw-r--r--odb/odb/generator.cxx5
-rw-r--r--odb/odb/odb.cxx13
-rw-r--r--odb/odb/version.hxx37
-rw-r--r--odb/odb/version.hxx.in50
6 files changed, 79 insertions, 48 deletions
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 <odb/version.hxx>" << 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 <odb/version.hxx>" << 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