aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2018-05-11 10:13:39 +0200
committerChristian Kandeler <christian.kandeler@qt.io>2018-05-14 08:36:14 +0000
commit3512a8cd5a2be336f610ec2334185e525af46b65 (patch)
tree1b5c40f8d649376e27541867cc13115c99365f75
parent2bda52aa3d50deb56128f42395ae9f2686af2a99 (diff)
Properly handle Depends.profiles
... when adjusting dependencies for multiplexing. If the profiles property is set, it must override our heuristic about which variant of the dependency to use. Change-Id: I207dd6cdee91fb2715b5abcd634573f850f14404 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
-rw-r--r--src/lib/corelib/language/moduleloader.cpp42
-rw-r--r--tests/auto/blackbox/testdata/multiplexed-tool/multiplexed-tool.qbs58
-rw-r--r--tests/auto/blackbox/testdata/multiplexed-tool/tool.cpp8
-rw-r--r--tests/auto/blackbox/tst_blackbox.cpp7
-rw-r--r--tests/auto/blackbox/tst_blackbox.h1
5 files changed, 102 insertions, 14 deletions
diff --git a/src/lib/corelib/language/moduleloader.cpp b/src/lib/corelib/language/moduleloader.cpp
index a90f51536..5f455f3be 100644
--- a/src/lib/corelib/language/moduleloader.cpp
+++ b/src/lib/corelib/language/moduleloader.cpp
@@ -997,13 +997,18 @@ void ModuleLoader::adjustDependenciesForMultiplexing(const ProductContext &produ
QBS_CHECK(!productIsMultiplexed); // This product must be an aggregator.
return;
}
+
+ bool profilesPropertyIsSet;
+ const QStringList profiles = m_evaluator->stringListValue(dependsItem,
+ StringConstants::profilesProperty(), &profilesPropertyIsSet);
+
const auto productRange = m_productsByName.equal_range(name);
std::vector<const ProductContext *> dependencies;
bool hasNonMultiplexedDependency = false;
for (auto it = productRange.first; it != productRange.second; ++it) {
if (!it->second->multiplexConfigurationId.isEmpty()) {
dependencies.push_back(it->second);
- if (productIsMultiplexed)
+ if (productIsMultiplexed && !profilesPropertyIsSet)
break;
} else {
hasNonMultiplexedDependency = true;
@@ -1040,15 +1045,19 @@ void ModuleLoader::adjustDependenciesForMultiplexing(const ProductContext &produ
multiplexIds.clear();
break;
}
- if (productIsMultiplexed) { // (2)
+ if (productIsMultiplexed && !profilesPropertyIsSet) { // (2)
const ValuePtr &multiplexId = product.item->property(
StringConstants::multiplexConfigurationIdProperty());
dependsItem->setProperty(StringConstants::multiplexConfigurationIdsProperty(),
multiplexId);
break;
}
- // (3b)
- multiplexIds << depMultiplexId;
+
+ // (3b) (or (2) if Depends.profiles is set).
+ const bool profileMatch = !profilesPropertyIsSet || profiles.empty()
+ || profiles.contains(dependency->profileName);
+ if (profileMatch)
+ multiplexIds << depMultiplexId;
}
if (!multiplexIds.empty()) {
dependsItem->setProperty(StringConstants::multiplexConfigurationIdsProperty(),
@@ -3543,7 +3552,7 @@ void ModuleLoader::addProductModuleDependencies(ProductContext *productContext,
const Item::Module &module)
{
auto deps = productContext->productModuleDependencies.at(module.name.toString());
- QList<ModuleLoaderResult::ProductInfo::Dependency> additionalDependencies;
+ QList<ModuleLoaderResult::ProductInfo::Dependency> depsToAdd;
const bool productIsMultiplexed = !productContext->multiplexConfigurationId.isEmpty();
for (auto &dep : deps) {
const auto productRange = m_productsByName.equal_range(dep.name);
@@ -3552,7 +3561,7 @@ void ModuleLoader::addProductModuleDependencies(ProductContext *productContext,
for (auto it = productRange.first; it != productRange.second; ++it) {
if (!it->second->multiplexConfigurationId.isEmpty()) {
dependencies.push_back(it->second);
- if (productIsMultiplexed)
+ if (productIsMultiplexed && dep.profile.isEmpty())
break;
} else {
hasNonMultiplexedDependency = true;
@@ -3560,32 +3569,37 @@ void ModuleLoader::addProductModuleDependencies(ProductContext *productContext,
}
}
- if (!productIsMultiplexed && hasNonMultiplexedDependency)
+ if (hasNonMultiplexedDependency) {
+ depsToAdd.push_back(dep);
continue;
+ }
for (std::size_t i = 0; i < dependencies.size(); ++i) {
+ const bool profileMatch = dep.profile.isEmpty()
+ || dep.profile == StringConstants::star()
+ || dep.profile == dependencies.at(i)->profileName;
if (i == 0) {
- if (productIsMultiplexed) {
+ if (productIsMultiplexed && dep.profile.isEmpty()) {
const ValuePtr &multiplexConfigIdProp = productContext->item->property(
StringConstants::multiplexConfigurationIdProperty());
dep.multiplexConfigurationId = std::static_pointer_cast<VariantValue>(
multiplexConfigIdProp)->value().toString();
+ depsToAdd.push_back(dep);
break;
- } else {
+ } else if (profileMatch) {
dep.multiplexConfigurationId = dependencies.at(i)->multiplexConfigurationId;
+ depsToAdd.push_back(dep);
}
- } else {
+ } else if (profileMatch) {
ModuleLoaderResult::ProductInfo::Dependency newDependency = dep;
newDependency.multiplexConfigurationId
= dependencies.at(i)->multiplexConfigurationId;
- additionalDependencies << newDependency;
+ depsToAdd << newDependency;
}
}
}
productContext->info.usedProducts.insert(productContext->info.usedProducts.end(),
- deps.cbegin(), deps.cend());
- productContext->info.usedProducts.insert(productContext->info.usedProducts.end(),
- additionalDependencies.cbegin(), additionalDependencies.cend());
+ depsToAdd.cbegin(), depsToAdd.cend());
}
void ModuleLoader::addTransitiveDependencies(ProductContext *ctx)
diff --git a/tests/auto/blackbox/testdata/multiplexed-tool/multiplexed-tool.qbs b/tests/auto/blackbox/testdata/multiplexed-tool/multiplexed-tool.qbs
new file mode 100644
index 000000000..b36ea5be9
--- /dev/null
+++ b/tests/auto/blackbox/testdata/multiplexed-tool/multiplexed-tool.qbs
@@ -0,0 +1,58 @@
+import qbs
+
+Project {
+ CppApplication {
+ name: "tool"
+ consoleApplication: true
+ Profile {
+ name: "debugProfile"
+ qbs.buildVariant: "debug"
+ }
+ Profile {
+ name: "releaseProfile"
+ qbs.buildVariant: "release"
+ }
+ multiplexByQbsProperties: "profiles"
+ qbs.profiles: ["debugProfile", "releaseProfile"]
+ files: "tool.cpp"
+ Properties {
+ condition: qbs.buildVariant === "debug"
+ cpp.defines: "WRONG_VARIANT"
+ }
+ Export {
+ Rule {
+ multiplex: true
+ inputsFromDependencies: "application"
+ Artifact {
+ filePath: "tool.out"
+ fileTags: "tool.output"
+ }
+ prepare: {
+ var cmd = new Command(input.filePath, []);
+ cmd.description = "creating " + output.fileName;
+ return cmd;
+ }
+ }
+ }
+ }
+ Product {
+ name: "p"
+ type: "tool.output"
+ multiplexByQbsProperties: "buildVariants"
+ qbs.buildVariants: ["debug", "release"]
+ Depends { name: "tool"; profiles: "releaseProfile" }
+ }
+ Product {
+ name: "p2"
+ type: "tool.output"
+ multiplexByQbsProperties: "buildVariants"
+ qbs.buildVariants: ["debug", "release"]
+ Depends { name: "helper" }
+ }
+ Product {
+ name: "helper"
+ Export {
+ Depends { name: "tool"; profiles: "releaseProfile" }
+ }
+ }
+}
diff --git a/tests/auto/blackbox/testdata/multiplexed-tool/tool.cpp b/tests/auto/blackbox/testdata/multiplexed-tool/tool.cpp
new file mode 100644
index 000000000..ac2e22ed9
--- /dev/null
+++ b/tests/auto/blackbox/testdata/multiplexed-tool/tool.cpp
@@ -0,0 +1,8 @@
+#include <cstdlib>
+
+int main()
+{
+#ifdef WRONG_VARIANT
+ return EXIT_FAILURE;
+#endif
+}
diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp
index 6ef0acaba..826884f08 100644
--- a/tests/auto/blackbox/tst_blackbox.cpp
+++ b/tests/auto/blackbox/tst_blackbox.cpp
@@ -4138,6 +4138,13 @@ void TestBlackbox::multipleConfigurations()
QCOMPARE(m_qbsStdout.count("compiling main.cpp"), 3);
}
+void TestBlackbox::multiplexedTool()
+{
+ QDir::setCurrent(testDataDir + "/multiplexed-tool");
+ QCOMPARE(runQbs(), 0);
+ QCOMPARE(m_qbsStdout.count("creating tool.out"), 4);
+}
+
void TestBlackbox::nestedGroups()
{
QDir::setCurrent(testDataDir + "/nested-groups");
diff --git a/tests/auto/blackbox/tst_blackbox.h b/tests/auto/blackbox/tst_blackbox.h
index 91a177063..2646704f9 100644
--- a/tests/auto/blackbox/tst_blackbox.h
+++ b/tests/auto/blackbox/tst_blackbox.h
@@ -168,6 +168,7 @@ private slots:
void movedFileDependency();
void multipleChanges();
void multipleConfigurations();
+ void multiplexedTool();
void nestedGroups();
void nestedProperties();
void newOutputArtifact();