aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@theqtcompany.com>2015-08-24 15:16:15 +0200
committerChristian Kandeler <christian.kandeler@theqtcompany.com>2015-09-01 11:36:01 +0000
commit319a81ac369e66744cd4e391af877588bbc60efc (patch)
treeb3ae4ffc550547dde80d4c6918dbc950b3d20b08
parent4540a7f4eddd20d870607f1e8f2a64959d2e25b2 (diff)
Add Group items in Modules as child items to the respective product.
Mainly to make binding to module properties work. This should also reduce the potential for other suprising behavior, as now all following code sees the Group items where they always were. Also tighten the autotest. Task-number: QBS-848 Change-Id: Iebce3f6534a4faace5c9c8bcf4447b938b9a651b Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
-rw-r--r--share/qbs/modules/typescript/TypeScriptModule.qbs2
-rw-r--r--src/lib/corelib/language/moduleloader.cpp25
-rw-r--r--src/lib/corelib/language/moduleloader.h2
-rw-r--r--src/lib/corelib/language/projectresolver.cpp2
-rw-r--r--tests/auto/blackbox/testdata/groups-in-modules/groups-in-modules.qbs26
-rw-r--r--tests/auto/blackbox/testdata/groups-in-modules/modules/helper/helper.qbs1
-rw-r--r--tests/auto/blackbox/testdata/groups-in-modules/modules/helper2/helper2.c1
-rw-r--r--tests/auto/blackbox/testdata/groups-in-modules/modules/helper2/helper2.qbs11
-rw-r--r--tests/auto/blackbox/testdata/groups-in-modules/modules/helper3/helper3.c1
-rw-r--r--tests/auto/blackbox/testdata/groups-in-modules/modules/helper3/helper3.qbs13
-rw-r--r--tests/auto/blackbox/testdata/groups-in-modules/modules/helper4/helper4.c1
-rw-r--r--tests/auto/blackbox/testdata/groups-in-modules/modules/helper4/helper4.qbs12
-rw-r--r--tests/auto/blackbox/testdata/groups-in-modules/modules/helper5/helper5.c5
-rw-r--r--tests/auto/blackbox/testdata/groups-in-modules/modules/helper5/helper5.qbs16
-rw-r--r--tests/auto/blackbox/testdata/groups-in-modules/modules/helper6/helper6.c1
-rw-r--r--tests/auto/blackbox/testdata/groups-in-modules/modules/helper6/helper6.qbs13
-rw-r--r--tests/auto/blackbox/tst_blackbox.cpp5
17 files changed, 129 insertions, 8 deletions
diff --git a/share/qbs/modules/typescript/TypeScriptModule.qbs b/share/qbs/modules/typescript/TypeScriptModule.qbs
index e92ce4b15..84ba21243 100644
--- a/share/qbs/modules/typescript/TypeScriptModule.qbs
+++ b/share/qbs/modules/typescript/TypeScriptModule.qbs
@@ -156,7 +156,7 @@ Module {
name: "io.qt.qbs.internal.typescript-helper"
files: [
FileInfo.joinPaths(path, "qbs-tsc-scan", "qbs-tsc-scan.ts"),
- FileInfo.joinPaths(product.typescript.toolchainInstallPath, "typescript.d.ts")
+ FileInfo.joinPaths(typescript.toolchainInstallPath, "typescript.d.ts")
]
fileTags: ["typescript.typescript-internal"]
}
diff --git a/src/lib/corelib/language/moduleloader.cpp b/src/lib/corelib/language/moduleloader.cpp
index 914f78b5e..c0f980e0c 100644
--- a/src/lib/corelib/language/moduleloader.cpp
+++ b/src/lib/corelib/language/moduleloader.cpp
@@ -518,6 +518,7 @@ void ModuleLoader::handleProduct(ProductContext *productContext)
dependsContext.productDependencies = &productContext->info.usedProducts;
resolveDependencies(&dependsContext, item);
addTransitiveDependencies(productContext, productContext->item);
+ copyGroupsFromModulesToProduct(productContext->item);
checkItemCondition(item);
foreach (Item *child, item->children()) {
@@ -1651,6 +1652,30 @@ Item *ModuleLoader::createNonPresentModule(const QString &name, const QString &r
return module;
}
+void ModuleLoader::copyGroupsFromModuleToProduct(Item *productItem, const Item *modulePrototype)
+{
+ for (int i = 0; i < modulePrototype->children().count(); ++i) {
+ Item * const child = modulePrototype->children().at(i);
+ if (child->typeName() == QLatin1String("Group"))
+ Item::addChild(productItem, child->clone());
+ }
+}
+
+void ModuleLoader::copyGroupsFromModulesToProduct(Item *productItem)
+{
+ foreach (const Item::Module &module, productItem->modules()) {
+ Item *prototype = module.item;
+ bool modulePassedValidation;
+ while ((modulePassedValidation = prototype->isPresentModule()
+ && !prototype->delayedError().hasError())
+ && prototype->prototype()) {
+ prototype = prototype->prototype();
+ }
+ if (modulePassedValidation)
+ copyGroupsFromModuleToProduct(productItem, prototype);
+ }
+}
+
QString ModuleLoaderResult::ProductInfo::Dependency::uniqueName() const
{
return ResolvedProduct::uniqueName(name, profile);
diff --git a/src/lib/corelib/language/moduleloader.h b/src/lib/corelib/language/moduleloader.h
index 6adbc978f..66338f136 100644
--- a/src/lib/corelib/language/moduleloader.h
+++ b/src/lib/corelib/language/moduleloader.h
@@ -230,6 +230,8 @@ private:
const QVariantMap &buildConfig);
void addTransitiveDependencies(ProductContext *ctx, Item *item);
Item *createNonPresentModule(const QString &name, const QString &reason, Item *module);
+ void copyGroupsFromModuleToProduct(Item *productItem, const Item *modulePrototype);
+ void copyGroupsFromModulesToProduct(Item *productItem);
ScriptEngine *m_engine;
ItemPool *m_pool;
diff --git a/src/lib/corelib/language/projectresolver.cpp b/src/lib/corelib/language/projectresolver.cpp
index 8df3c68b6..694f582e5 100644
--- a/src/lib/corelib/language/projectresolver.cpp
+++ b/src/lib/corelib/language/projectresolver.cpp
@@ -451,7 +451,7 @@ void ProjectResolver::resolveModule(const QualifiedId &moduleName, Item *item, b
m_productContext->product->modules += module;
ItemFuncMap mapping;
- mapping["Group"] = &ProjectResolver::resolveGroup;
+ mapping["Group"] = &ProjectResolver::ignoreItem;
mapping["Rule"] = &ProjectResolver::resolveRule;
mapping["FileTagger"] = &ProjectResolver::resolveFileTagger;
mapping["Transformer"] = &ProjectResolver::resolveTransformer;
diff --git a/tests/auto/blackbox/testdata/groups-in-modules/groups-in-modules.qbs b/tests/auto/blackbox/testdata/groups-in-modules/groups-in-modules.qbs
index 55f27c4f5..5fa09c4d0 100644
--- a/tests/auto/blackbox/testdata/groups-in-modules/groups-in-modules.qbs
+++ b/tests/auto/blackbox/testdata/groups-in-modules/groups-in-modules.qbs
@@ -1,10 +1,24 @@
import qbs
-Product {
- Depends { name: "helper" }
- type: ["diamond"]
+Project {
+ Product {
+ Depends { name: "dep" }
+ Depends { name: "helper" }
+ Depends {
+ name: "helper3"
+ required: false
+ }
+ type: ["diamond"]
- files: [
- "rock.coal"
- ]
+ files: [
+ "rock.coal"
+ ]
+ }
+
+ Product {
+ name: "dep"
+ Export {
+ Depends { name: "helper4" }
+ }
+ }
}
diff --git a/tests/auto/blackbox/testdata/groups-in-modules/modules/helper/helper.qbs b/tests/auto/blackbox/testdata/groups-in-modules/modules/helper/helper.qbs
index 3f3e5805e..d8e47ee35 100644
--- a/tests/auto/blackbox/testdata/groups-in-modules/modules/helper/helper.qbs
+++ b/tests/auto/blackbox/testdata/groups-in-modules/modules/helper/helper.qbs
@@ -3,6 +3,7 @@ import qbs.FileInfo
Module {
Depends { name: "cpp" }
+ Depends { name: "helper2" }
additionalProductTypes: ["diamond"]
diff --git a/tests/auto/blackbox/testdata/groups-in-modules/modules/helper2/helper2.c b/tests/auto/blackbox/testdata/groups-in-modules/modules/helper2/helper2.c
new file mode 100644
index 000000000..a8035d360
--- /dev/null
+++ b/tests/auto/blackbox/testdata/groups-in-modules/modules/helper2/helper2.c
@@ -0,0 +1 @@
+void helper2() {}
diff --git a/tests/auto/blackbox/testdata/groups-in-modules/modules/helper2/helper2.qbs b/tests/auto/blackbox/testdata/groups-in-modules/modules/helper2/helper2.qbs
new file mode 100644
index 000000000..795f4a433
--- /dev/null
+++ b/tests/auto/blackbox/testdata/groups-in-modules/modules/helper2/helper2.qbs
@@ -0,0 +1,11 @@
+import qbs
+
+Module {
+ Depends { name: "cpp" }
+
+ Group {
+ name: "Helper2 Sources"
+ prefix: path + "/"
+ files: ["helper2.c"]
+ }
+}
diff --git a/tests/auto/blackbox/testdata/groups-in-modules/modules/helper3/helper3.c b/tests/auto/blackbox/testdata/groups-in-modules/modules/helper3/helper3.c
new file mode 100644
index 000000000..e76e3cb25
--- /dev/null
+++ b/tests/auto/blackbox/testdata/groups-in-modules/modules/helper3/helper3.c
@@ -0,0 +1 @@
+void helper3() {}
diff --git a/tests/auto/blackbox/testdata/groups-in-modules/modules/helper3/helper3.qbs b/tests/auto/blackbox/testdata/groups-in-modules/modules/helper3/helper3.qbs
new file mode 100644
index 000000000..c92120091
--- /dev/null
+++ b/tests/auto/blackbox/testdata/groups-in-modules/modules/helper3/helper3.qbs
@@ -0,0 +1,13 @@
+import qbs
+
+Module {
+ Depends { name: "cpp" }
+
+ Group {
+ name: "Helper3 Sources"
+ prefix: path + "/"
+ files: ["helper3.c"]
+ }
+
+ validate: { throw "Nope."; }
+}
diff --git a/tests/auto/blackbox/testdata/groups-in-modules/modules/helper4/helper4.c b/tests/auto/blackbox/testdata/groups-in-modules/modules/helper4/helper4.c
new file mode 100644
index 000000000..8c966ab60
--- /dev/null
+++ b/tests/auto/blackbox/testdata/groups-in-modules/modules/helper4/helper4.c
@@ -0,0 +1 @@
+void helper4() {}
diff --git a/tests/auto/blackbox/testdata/groups-in-modules/modules/helper4/helper4.qbs b/tests/auto/blackbox/testdata/groups-in-modules/modules/helper4/helper4.qbs
new file mode 100644
index 000000000..568ccb5fb
--- /dev/null
+++ b/tests/auto/blackbox/testdata/groups-in-modules/modules/helper4/helper4.qbs
@@ -0,0 +1,12 @@
+import qbs
+
+Module {
+ Depends { name: "cpp" }
+ Depends { name: "helper5" }
+
+ Group {
+ name: "Helper4 Sources"
+ prefix: path + "/"
+ files: ["helper4.c"]
+ }
+}
diff --git a/tests/auto/blackbox/testdata/groups-in-modules/modules/helper5/helper5.c b/tests/auto/blackbox/testdata/groups-in-modules/modules/helper5/helper5.c
new file mode 100644
index 000000000..edfe28443
--- /dev/null
+++ b/tests/auto/blackbox/testdata/groups-in-modules/modules/helper5/helper5.c
@@ -0,0 +1,5 @@
+void helper5() {
+#ifndef COMPILE_FIX
+ nothatcantwork
+#endif
+}
diff --git a/tests/auto/blackbox/testdata/groups-in-modules/modules/helper5/helper5.qbs b/tests/auto/blackbox/testdata/groups-in-modules/modules/helper5/helper5.qbs
new file mode 100644
index 000000000..d74f98902
--- /dev/null
+++ b/tests/auto/blackbox/testdata/groups-in-modules/modules/helper5/helper5.qbs
@@ -0,0 +1,16 @@
+import qbs
+
+Module {
+ Depends { name: "cpp" }
+ Depends {
+ name: "helper6"
+ required: false
+ }
+
+ Group {
+ name: "Helper5 Sources"
+ prefix: path + "/"
+ files: ["helper5.c"]
+ cpp.defines: ["COMPILE_FIX"]
+ }
+}
diff --git a/tests/auto/blackbox/testdata/groups-in-modules/modules/helper6/helper6.c b/tests/auto/blackbox/testdata/groups-in-modules/modules/helper6/helper6.c
new file mode 100644
index 000000000..a32aa12a6
--- /dev/null
+++ b/tests/auto/blackbox/testdata/groups-in-modules/modules/helper6/helper6.c
@@ -0,0 +1 @@
+void helper6() {}
diff --git a/tests/auto/blackbox/testdata/groups-in-modules/modules/helper6/helper6.qbs b/tests/auto/blackbox/testdata/groups-in-modules/modules/helper6/helper6.qbs
new file mode 100644
index 000000000..6c72ab793
--- /dev/null
+++ b/tests/auto/blackbox/testdata/groups-in-modules/modules/helper6/helper6.qbs
@@ -0,0 +1,13 @@
+import qbs
+
+Module {
+ Depends { name: "cpp" }
+
+ Group {
+ name: "Helper6 Sources"
+ prefix: path + "/"
+ files: ["helper6.c"]
+ }
+
+ validate: { throw "Go away."; }
+}
diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp
index a9012ec52..228e152e0 100644
--- a/tests/auto/blackbox/tst_blackbox.cpp
+++ b/tests/auto/blackbox/tst_blackbox.cpp
@@ -2812,6 +2812,11 @@ void TestBlackbox::groupsInModules()
QCOMPARE(runQbs(params), 0);
QVERIFY(m_qbsStdout.contains("compile rock.coal => rock.diamond"));
QVERIFY(m_qbsStdout.contains("compile chunk.coal => chunk.diamond"));
+ QVERIFY(m_qbsStdout.contains("compiling helper2.c"));
+ QVERIFY(!m_qbsStdout.contains("compiling helper3.c"));
+ QVERIFY(m_qbsStdout.contains("compiling helper4.c"));
+ QVERIFY(m_qbsStdout.contains("compiling helper5.c"));
+ QVERIFY(!m_qbsStdout.contains("compiling helper6.c"));
QCOMPARE(runQbs(params), 0);
QVERIFY(!m_qbsStdout.contains("compile rock.coal => rock.diamond"));