aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2018-12-17 16:04:43 +0100
committerChristian Kandeler <christian.kandeler@qt.io>2018-12-17 16:04:43 +0100
commit52a35195f083dae9f42059a6047daf7983b86e3b (patch)
treecda17332015cbad120fab6d751cc2c4df19c8666
parent7520f6f795986dbf06b465296fa37f7f791834f0 (diff)
parent7b5349d182bcb4c9d7a3d1501768b91c9fa93fe9 (diff)
Merge 1.12 into master
-rw-r--r--doc/man/qbs.16
-rw-r--r--src/lib/corelib/language/projectresolver.cpp6
-rw-r--r--src/lib/corelib/language/projectresolver.h3
-rw-r--r--tests/auto/language/testdata/file-in-product-and-module.qbs9
-rw-r--r--tests/auto/language/testdata/modules/module_with_file/module-with-file.qbs14
-rw-r--r--tests/auto/language/tst_language.cpp48
-rw-r--r--tests/auto/language/tst_language.h2
7 files changed, 81 insertions, 7 deletions
diff --git a/doc/man/qbs.1 b/doc/man/qbs.1
index b3d0a6022..b11beeeff 100644
--- a/doc/man/qbs.1
+++ b/doc/man/qbs.1
@@ -1,12 +1,12 @@
-.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.6.
-.TH QBS "1" "July 2018" "qbs 1.12.1" "User Commands"
+.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.7.
+.TH QBS "1" "December 2018" "qbs 1.12.3" "User Commands"
.SH NAME
qbs \- the Qbs build tool
.SH SYNOPSIS
.B qbs
[\fI\,command\/\fR] [\fI\,command parameters\/\fR]
.SH DESCRIPTION
-Qbs 1.12.1, a cross\-platform build tool.
+Qbs 1.12.3, a cross\-platform build tool.
.SS "Built-in commands:"
.TP
build
diff --git a/src/lib/corelib/language/projectresolver.cpp b/src/lib/corelib/language/projectresolver.cpp
index 4f871c17f..7deb964b3 100644
--- a/src/lib/corelib/language/projectresolver.cpp
+++ b/src/lib/corelib/language/projectresolver.cpp
@@ -101,7 +101,7 @@ struct ProjectResolver::ProductContext
Item *item;
typedef std::pair<ArtifactPropertiesPtr, std::vector<CodeLocation>> ArtifactPropertiesInfo;
QHash<QStringList, ArtifactPropertiesInfo> artifactPropertiesPerFilter;
- QHash<QString, CodeLocation> sourceArtifactLocations;
+ ProjectResolver::FileLocations sourceArtifactLocations;
GroupConstPtr currentGroup;
};
@@ -602,7 +602,7 @@ void ProjectResolver::gatherProductTypes(ResolvedProduct *product, Item *item)
SourceArtifactPtr ProjectResolver::createSourceArtifact(const ResolvedProductPtr &rproduct,
const QString &fileName, const GroupPtr &group, bool wildcard,
- const CodeLocation &filesLocation, QHash<QString, CodeLocation> *fileLocations,
+ const CodeLocation &filesLocation, FileLocations *fileLocations,
ErrorInfo *errorInfo)
{
const QString &baseDir = FileInfo::path(group->location.filePath());
@@ -614,7 +614,7 @@ SourceArtifactPtr ProjectResolver::createSourceArtifact(const ResolvedProductPtr
return SourceArtifactPtr();
}
if (group->enabled && fileLocations) {
- CodeLocation &loc = (*fileLocations)[absFilePath];
+ CodeLocation &loc = (*fileLocations)[std::make_pair(group->targetOfModule, absFilePath)];
if (loc.isValid()) {
if (errorInfo) {
errorInfo->append(Tr::tr("Duplicate source file '%1'.").arg(absFilePath));
diff --git a/src/lib/corelib/language/projectresolver.h b/src/lib/corelib/language/projectresolver.h
index 54e80fb01..777451fa6 100644
--- a/src/lib/corelib/language/projectresolver.h
+++ b/src/lib/corelib/language/projectresolver.h
@@ -77,10 +77,11 @@ public:
static void applyFileTaggers(const SourceArtifactPtr &artifact,
const ResolvedProductConstPtr &product);
+ using FileLocations = QHash<std::pair<QString, QString>, CodeLocation>;
static SourceArtifactPtr createSourceArtifact(const ResolvedProductPtr &rproduct,
const QString &fileName, const GroupPtr &group, bool wildcard,
const CodeLocation &filesLocation = CodeLocation(),
- QHash<QString, CodeLocation> *fileLocations = nullptr, ErrorInfo *errorInfo = nullptr);
+ FileLocations *fileLocations = nullptr, ErrorInfo *errorInfo = nullptr);
private:
struct ProjectContext;
diff --git a/tests/auto/language/testdata/file-in-product-and-module.qbs b/tests/auto/language/testdata/file-in-product-and-module.qbs
new file mode 100644
index 000000000..1cb2fa866
--- /dev/null
+++ b/tests/auto/language/testdata/file-in-product-and-module.qbs
@@ -0,0 +1,9 @@
+Product {
+ name: "p"
+ Depends { name: "module_with_file" }
+ property bool addFileToProduct
+ Group {
+ files: "zort"
+ condition: addFileToProduct
+ }
+}
diff --git a/tests/auto/language/testdata/modules/module_with_file/module-with-file.qbs b/tests/auto/language/testdata/modules/module_with_file/module-with-file.qbs
new file mode 100644
index 000000000..ded81e046
--- /dev/null
+++ b/tests/auto/language/testdata/modules/module_with_file/module-with-file.qbs
@@ -0,0 +1,14 @@
+Module {
+ property bool file1IsTarget
+ property bool file2IsTarget
+ Group {
+ prefix: product.sourceDirectory + '/'
+ files: "zort"
+ filesAreTargets: product.module_with_file.file1IsTarget
+ }
+ Group {
+ prefix: product.sourceDirectory + '/'
+ files: "zort"
+ filesAreTargets: product.module_with_file.file2IsTarget
+ }
+}
diff --git a/tests/auto/language/tst_language.cpp b/tests/auto/language/tst_language.cpp
index edcd4200d..2bd5b5de8 100644
--- a/tests/auto/language/tst_language.cpp
+++ b/tests/auto/language/tst_language.cpp
@@ -1103,6 +1103,54 @@ void TestLanguage::fileContextProperties()
QCOMPARE(exceptionCaught, false);
}
+void TestLanguage::fileInProductAndModule_data()
+{
+ QTest::addColumn<bool>("file1IsTarget");
+ QTest::addColumn<bool>("file2IsTarget");
+ QTest::addColumn<bool>("addFileToProduct");
+ QTest::addColumn<bool>("successExpected");
+ QTest::newRow("file occurs twice in module as non-target") << false << false << false << false;
+ QTest::newRow("file occurs twice in module as non-target, and in product as well")
+ << false << false << true << false;
+ QTest::newRow("file occurs in module as non-target and target")
+ << false << true << false << true;
+ QTest::newRow("file occurs in module as non-target and target, and in product as well")
+ << false << true << true << false;
+ QTest::newRow("file occurs in module as target and non-target")
+ << true << false << false << true;
+ QTest::newRow("file occurs in module as target and non-target, and in product as well")
+ << true << false << true << false;
+ QTest::newRow("file occurs twice in module as target") << true << true << false << false;
+ QTest::newRow("file occurs twice in module as target, and in product as well")
+ << true << true << true << false;
+}
+
+void TestLanguage::fileInProductAndModule()
+{
+ bool exceptionCaught = false;
+ QFETCH(bool, file1IsTarget);
+ QFETCH(bool, file2IsTarget);
+ QFETCH(bool, addFileToProduct);
+ QFETCH(bool, successExpected);
+ try {
+ SetupProjectParameters params = defaultParameters;
+ params.setProjectFilePath(testProject("file-in-product-and-module.qbs"));
+ params.setOverriddenValues(QVariantMap{
+ std::make_pair("modules.module_with_file.file1IsTarget", file1IsTarget),
+ std::make_pair("modules.module_with_file.file2IsTarget", file2IsTarget),
+ std::make_pair("products.p.addFileToProduct", addFileToProduct),
+ });
+ project = loader->loadProject(params);
+ QVERIFY(!!project);
+ QHash<QString, ResolvedProductPtr> products = productsFromProject(project);
+ QCOMPARE(products.size(), 1);
+ } catch (const ErrorInfo &e) {
+ exceptionCaught = true;
+ QVERIFY2(e.toString().contains("Duplicate"), qPrintable(e.toString()));
+ }
+ QCOMPARE(exceptionCaught, !successExpected);
+}
+
void TestLanguage::getNativeSetting()
{
bool exceptionCaught = false;
diff --git a/tests/auto/language/tst_language.h b/tests/auto/language/tst_language.h
index 660c1b9b6..b2d242bfb 100644
--- a/tests/auto/language/tst_language.h
+++ b/tests/auto/language/tst_language.h
@@ -103,6 +103,8 @@ private slots:
void erroneousFiles();
void exports();
void fileContextProperties();
+ void fileInProductAndModule_data();
+ void fileInProductAndModule();
void fileTags_data();
void fileTags();
void groupConditions_data();