aboutsummaryrefslogtreecommitdiffstats
path: root/share
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2018-03-14 10:07:30 +0100
committerChristian Kandeler <christian.kandeler@qt.io>2018-03-14 14:01:15 +0000
commit4514282237f36319b70ed03669a42c7e88371b89 (patch)
tree4c5ee81765a6424cc5bd4c4c2248751a35c2a6d0 /share
parent2acaba8ea211e1ba00c2e2844aa00ca16c7a04f4 (diff)
Exporter.qbs: Properly support variant values
The right-hand side of variant properties potentially needs to be parenthesized. Change-Id: I7ea9d94b3aea379259fb9e73372791ef3ea71e15 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'share')
-rw-r--r--share/qbs/modules/Exporter/qbs/qbsexporter.js18
1 files changed, 11 insertions, 7 deletions
diff --git a/share/qbs/modules/Exporter/qbs/qbsexporter.js b/share/qbs/modules/Exporter/qbs/qbsexporter.js
index e71622607..45324bb4e 100644
--- a/share/qbs/modules/Exporter/qbs/qbsexporter.js
+++ b/share/qbs/modules/Exporter/qbs/qbsexporter.js
@@ -111,24 +111,28 @@ function checkValuePrefix(name, value, forbiddenPrefix, prefixDescription)
}
}
-function stringifyValue(project, product, moduleInstallDir, name, value)
+function stringifyValue(project, product, moduleInstallDir, prop, value)
{
if (Array.isArray(value)) {
var repr = "[";
for (var i = 0; i < value.length; ++i) {
- repr += stringifyValue(project, product, moduleInstallDir, name, value[i]) + ", ";
+ repr += stringifyValue(project, product, moduleInstallDir, prop, value[i]) + ", ";
}
repr += "]";
return repr;
}
- if (typeof(value) !== "string")
- return JSON.stringify(value);
+ if (typeof(value) !== "string") {
+ var value = JSON.stringify(value);
+ if (prop.type === "variant")
+ value = '(' + value + ')';
+ return value;
+ }
// Catch user oversights: Paths that point into the project source or build directories
// make no sense in the module.
if (!value.startsWith(product.qbs.installRoot)) {
- checkValuePrefix(name, value, project.buildDirectory, "project build directory");
- checkValuePrefix(name, value, project.sourceDirectory, "project source directory");
+ checkValuePrefix(prop.name, value, project.buildDirectory, "project build directory");
+ checkValuePrefix(prop.name, value, project.sourceDirectory, "project source directory");
}
// Adapt file paths pointing into the install dir, that is, make them relative to the
@@ -183,7 +187,7 @@ function writeProperty(project, product, moduleInstallDir, prop, indentation, co
} else {
value = product.exports[prop.name];
}
- line += stringifyValue(project, product, moduleInstallDir, prop.name, value);
+ line += stringifyValue(project, product, moduleInstallDir, prop, value);
} else {
line += prop.sourceCode.replace(/importingProduct\./g, "product.");
}