aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Weickelt <richard@weickelt.de>2019-08-22 20:58:35 +0200
committerRichard Weickelt <richard@weickelt.de>2019-08-23 13:34:53 +0000
commitda8ca2d55251de8d3d8d180409f57ffb85e9b1ad (patch)
tree1ab87954be1a17e50e2bb2b940fa8daa60cc0991
parent0d52ce22a9bf1d19a4c5590dd17f7f80abb3b6aa (diff)
Clean up version treatment in cpp module
The handling of version numbers in the cpp module was overly complicated and too restrictive. Version numbers that are valid according to SemVer (for instance 1.2.3-beta+47) were not accepted although being valid. This patch allows the usage of any version number as long as it starts with x[.y[.z]]. It also simplifies version number handling in the cpp module. Task-number: QBS-1486 Change-Id: I2790f8a80bd78bf549f5d46c0748f88c788addec Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
-rw-r--r--share/qbs/modules/cpp/GenericGCC.qbs23
-rw-r--r--share/qbs/modules/cpp/gcc.js9
2 files changed, 11 insertions, 21 deletions
diff --git a/share/qbs/modules/cpp/GenericGCC.qbs b/share/qbs/modules/cpp/GenericGCC.qbs
index 3b775c9fa..5ededc512 100644
--- a/share/qbs/modules/cpp/GenericGCC.qbs
+++ b/share/qbs/modules/cpp/GenericGCC.qbs
@@ -227,18 +227,12 @@ CppModule {
if (product.version === undefined)
return undefined;
- if (!Gcc.isNumericProductVersion(product.version)) {
- // Dynamic library version numbers like "A" or "B" are common on Apple platforms, so
- // don't restrict the product version to a componentized version number here.
- if (cpp.imageFormat === "macho")
- return product.version;
-
- throw("product.version must be a string in the format x[.y[.z[.w]] "
- + "where each component is an integer");
- }
+ var coreVersion = product.version.match("^([0-9]+\.){0,3}[0-9]+");
+ if (!coreVersion)
+ return undefined;
var maxVersionParts = 3;
- var versionParts = product.version.split('.').slice(0, maxVersionParts);
+ var versionParts = coreVersion[0].split('.').slice(0, maxVersionParts);
// pad if necessary
for (var i = versionParts.length; i < maxVersionParts; ++i)
@@ -246,11 +240,12 @@ CppModule {
return versionParts.join('.');
}
+
property string soVersion: {
- var v = internalVersion;
- if (!Gcc.isNumericProductVersion(v))
+ if (!internalVersion)
return "";
- return v.split('.')[0];
+
+ return internalVersion.split('.')[0];
}
property var buildEnv: {
@@ -447,7 +442,7 @@ CppModule {
}
if (product.cpp.shouldCreateSymlinks && (!product.bundle || !product.bundle.isBundle)) {
- var maxVersionParts = Gcc.isNumericProductVersion(product.version) ? 3 : 1;
+ var maxVersionParts = product.cpp.internalVersion ? 3 : 1;
for (var i = 0; i < maxVersionParts; ++i) {
var symlink = {
filePath: product.destinationDirectory + "/"
diff --git a/share/qbs/modules/cpp/gcc.js b/share/qbs/modules/cpp/gcc.js
index f1cee8231..0913b27d0 100644
--- a/share/qbs/modules/cpp/gcc.js
+++ b/share/qbs/modules/cpp/gcc.js
@@ -278,9 +278,8 @@ function linkerFlags(project, product, inputs, outputs, primaryOutput, linkerPat
}
if (isDarwin) {
- var internalVersion = product.cpp.internalVersion;
- if (internalVersion && isNumericProductVersion(internalVersion))
- args.push("-current_version", internalVersion);
+ if (product.cpp.internalVersion)
+ args.push("-current_version", product.cpp.internalVersion);
escapableLinkerFlags.push("-install_name", UnixUtils.soname(product,
primaryOutput.fileName));
} else if (product.cpp.imageFormat === "elf") {
@@ -1434,10 +1433,6 @@ function debugInfoArtifacts(product, variants, debugInfoTagSuffix) {
return artifacts;
}
-function isNumericProductVersion(version) {
- return version && version.match(/^([0-9]+\.){0,3}[0-9]+$/);
-}
-
function dumpMacros(env, compilerFilePath, args, nullDevice, tag) {
var p = new Process();
try {