diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2018-09-04 13:21:04 +0200 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2018-09-04 13:21:04 +0200 |
commit | 5ecb6ad29ab2e75bf329f369c821179898dfad1f (patch) | |
tree | 60df57c4c74d9cddb5717960a59b96bb6a743b80 | |
parent | 909128d2647498b66f4dc6c1e948af6b47d0c42a (diff) | |
parent | 4661759492c8dfc2830248f5d696a63365fc9e07 (diff) | |
download | qbs-5ecb6ad29ab2e75bf329f369c821179898dfad1f.tar.gz |
Merge 1.12 into master
Change-Id: Ia115255ae46772a83c1196fbe291ff295927ee92
-rw-r--r-- | changelogs/changes-1.12.1.md | 1 | ||||
-rw-r--r-- | src/lib/corelib/buildgraph/artifactsscriptvalue.cpp | 12 | ||||
-rw-r--r-- | src/lib/corelib/buildgraph/buildgraph.cpp | 14 | ||||
-rw-r--r-- | src/lib/corelib/buildgraph/executor.cpp | 2 | ||||
-rw-r--r-- | src/lib/corelib/buildgraph/requestedartifacts.cpp | 9 | ||||
-rw-r--r-- | src/lib/corelib/buildgraph/requestedartifacts.h | 2 | ||||
-rw-r--r-- | src/lib/corelib/language/moduleloader.cpp | 4 | ||||
-rw-r--r-- | src/lib/corelib/language/scriptengine.h | 4 | ||||
-rw-r--r-- | tests/auto/blackbox/testdata/not-always-updated/not-always-updated.qbs | 31 | ||||
-rw-r--r-- | tests/auto/blackbox/tst_blackbox.cpp | 7 | ||||
-rw-r--r-- | tests/auto/blackbox/tst_blackbox.h | 1 |
11 files changed, 66 insertions, 21 deletions
diff --git a/changelogs/changes-1.12.1.md b/changelogs/changes-1.12.1.md index e4edeb136..d9f105941 100644 --- a/changelogs/changes-1.12.1.md +++ b/changelogs/changes-1.12.1.md @@ -5,3 +5,4 @@ * Fixed possible crash when scanning qrc files (QBS-1375). * Fixed spurious re-building of .pc and .qbs module files. * Fixed possible crash on storing a build graph after re-resolving. +* Fixed possible assertion on input artifacts with alwaysUpdated == false. diff --git a/src/lib/corelib/buildgraph/artifactsscriptvalue.cpp b/src/lib/corelib/buildgraph/artifactsscriptvalue.cpp index c32e95b2a..2adb77d47 100644 --- a/src/lib/corelib/buildgraph/artifactsscriptvalue.cpp +++ b/src/lib/corelib/buildgraph/artifactsscriptvalue.cpp @@ -139,11 +139,11 @@ static bool checkAndSetArtifactsMapUpToDateFlag(const ResolvedProduct *p) } static bool checkAndSetArtifactsMapUpToDateFlag(const ResolvedModule *) { return true; } -static void registerArtifactsMapAccess(const ResolvedProduct *p, ScriptEngine *e) +static void registerArtifactsMapAccess(const ResolvedProduct *p, ScriptEngine *e, bool forceUpdate) { - e->setArtifactsMapRequested(p); + e->setArtifactsMapRequested(p, forceUpdate); } -static void registerArtifactsMapAccess(const ResolvedModule *, ScriptEngine *) {} +static void registerArtifactsMapAccess(const ResolvedModule *, ScriptEngine *, bool) {} static void registerArtifactsSetAccess(const ResolvedProduct *p, const FileTag &t, ScriptEngine *e) { e->setArtifactSetRequestedForTag(p, t); @@ -174,10 +174,12 @@ template<class ProductOrModule> static QScriptValue js_artifactsForFileTag( template<class ProductOrModule> static QScriptValue js_artifacts( QScriptContext *ctx, ScriptEngine *engine, const ProductOrModule *productOrModule) { - registerArtifactsMapAccess(productOrModule, engine); QScriptValue artifactsObj = ctx->callee().property(CachedValueKey); - if (artifactsObj.isObject() && checkAndSetArtifactsMapUpToDateFlag(productOrModule)) + if (artifactsObj.isObject() && checkAndSetArtifactsMapUpToDateFlag(productOrModule)) { + registerArtifactsMapAccess(productOrModule, engine, false); return artifactsObj; + } + registerArtifactsMapAccess(productOrModule, engine, true); artifactsObj = createArtifactsObject(productOrModule, engine); ctx->callee().setProperty(CachedValueKey, artifactsObj); const auto &map = artifactsMap(productOrModule); diff --git a/src/lib/corelib/buildgraph/buildgraph.cpp b/src/lib/corelib/buildgraph/buildgraph.cpp index 42091ec56..e6d49f3d5 100644 --- a/src/lib/corelib/buildgraph/buildgraph.cpp +++ b/src/lib/corelib/buildgraph/buildgraph.cpp @@ -802,12 +802,16 @@ static void doSanityChecksForProduct(const ResolvedProductConstPtr &product, for (const Artifact * const output : qAsConst(transformer->outputs)) { QBS_CHECK(output->transformer == transformer); transformerOutputChildren.unite(ArtifactSet::filtered(output->children)); - Set<QString> childFilePaths; for (const Artifact *a : filterByType<Artifact>(output->children)) { - if (!childFilePaths.insert(a->filePath()).second) { - throw ErrorInfo(QString::fromLatin1("There is more than one artifact for " - "file '%1' in the child list for output '%2'.") - .arg(a->filePath(), output->filePath()), CodeLocation(), true); + for (const Artifact *other : filterByType<Artifact>(output->children)) { + if (other != a && other->filePath() == a->filePath() + && (other->artifactType != Artifact::SourceFile + || a->artifactType != Artifact::SourceFile + || other->product == a->product)) { + throw ErrorInfo(QString::fromLatin1("There is more than one artifact for " + "file '%1' in the child list for output '%2'.") + .arg(a->filePath(), output->filePath()), CodeLocation(), true); + } } } } diff --git a/src/lib/corelib/buildgraph/executor.cpp b/src/lib/corelib/buildgraph/executor.cpp index 1fd6aa986..7b1e92f18 100644 --- a/src/lib/corelib/buildgraph/executor.cpp +++ b/src/lib/corelib/buildgraph/executor.cpp @@ -446,7 +446,7 @@ bool Executor::isUpToDate(Artifact *artifact) const } for (Artifact *childArtifact : filterByType<Artifact>(artifact->children)) { - QBS_CHECK(childArtifact->timestamp().isValid()); + QBS_CHECK(!childArtifact->alwaysUpdated || childArtifact->timestamp().isValid()); qCDebug(lcUpToDateCheck) << "child timestamp" << childArtifact->timestamp().toString() << childArtifact->filePath(); diff --git a/src/lib/corelib/buildgraph/requestedartifacts.cpp b/src/lib/corelib/buildgraph/requestedartifacts.cpp index 200f226ce..7fbaf65f1 100644 --- a/src/lib/corelib/buildgraph/requestedartifacts.cpp +++ b/src/lib/corelib/buildgraph/requestedartifacts.cpp @@ -73,13 +73,12 @@ bool RequestedArtifacts::isUpToDate(const TopLevelProject *project) const return true; } -void RequestedArtifacts::setAllArtifactTags(const ResolvedProduct *product) +void RequestedArtifacts::setAllArtifactTags(const ResolvedProduct *product, bool forceUpdate) { - if (m_requestedArtifactsPerProduct.find(product->uniqueName()) - != m_requestedArtifactsPerProduct.cend()) { - return; - } RequestedArtifactsPerProduct &ra = m_requestedArtifactsPerProduct[product->uniqueName()]; + if (!ra.allTags.empty() && !forceUpdate) + return; + ra.allTags.clear(); const ArtifactSetByFileTag artifactsMap = product->buildData->artifactsByFileTag(); for (auto it = artifactsMap.begin(); it != artifactsMap.end(); ++it) ra.allTags.insert(it.key().toString()); diff --git a/src/lib/corelib/buildgraph/requestedartifacts.h b/src/lib/corelib/buildgraph/requestedartifacts.h index 82c393803..d3804ca14 100644 --- a/src/lib/corelib/buildgraph/requestedartifacts.h +++ b/src/lib/corelib/buildgraph/requestedartifacts.h @@ -59,7 +59,7 @@ public: bool isUpToDate(const TopLevelProject *project) const; void clear() { m_requestedArtifactsPerProduct.clear(); } - void setAllArtifactTags(const ResolvedProduct *product); + void setAllArtifactTags(const ResolvedProduct *product, bool forceUpdate); void setArtifactsForTag(const ResolvedProduct *product, const FileTag &tag); void setNonExistingTagRequested(const ResolvedProduct *product, const QString &tag); void setArtifactsEnumerated(const ResolvedProduct *product); diff --git a/src/lib/corelib/language/moduleloader.cpp b/src/lib/corelib/language/moduleloader.cpp index 9646013f6..ff5fd2f84 100644 --- a/src/lib/corelib/language/moduleloader.cpp +++ b/src/lib/corelib/language/moduleloader.cpp @@ -597,7 +597,7 @@ void ModuleLoader::handleProject(ModuleLoaderResult *loadResult, TopLevelProjectContext *topLevelProjectContext, Item *projectItem, const Set<QString> &referencedFilePaths) { - auto p = new ProjectContext; + QScopedPointer<ProjectContext> p(new ProjectContext); auto &projectContext = *p; projectContext.topLevelProject = topLevelProjectContext; projectContext.result = loadResult; @@ -623,9 +623,9 @@ void ModuleLoader::handleProject(ModuleLoaderResult *loadResult, m_parameters.overriddenValuesTree()); if (!checkItemCondition(projectItem)) { m_disabledProjects.insert(projectContext.name); - delete p; return; } + p.take(); topLevelProjectContext->projects.push_back(&projectContext); m_reader->pushExtraSearchPaths(readExtraSearchPaths(projectItem) << projectItem->file()->dirPath()); diff --git a/src/lib/corelib/language/scriptengine.h b/src/lib/corelib/language/scriptengine.h index e27df7701..226cf16a9 100644 --- a/src/lib/corelib/language/scriptengine.h +++ b/src/lib/corelib/language/scriptengine.h @@ -120,9 +120,9 @@ public: { m_productsWithRequestedDependencies.insert(p); } - void setArtifactsMapRequested(const ResolvedProduct *product) + void setArtifactsMapRequested(const ResolvedProduct *product, bool forceUpdate) { - m_requestedArtifacts.setAllArtifactTags(product); + m_requestedArtifacts.setAllArtifactTags(product, forceUpdate); } void setArtifactSetRequestedForTag(const ResolvedProduct *product, const FileTag &tag) { diff --git a/tests/auto/blackbox/testdata/not-always-updated/not-always-updated.qbs b/tests/auto/blackbox/testdata/not-always-updated/not-always-updated.qbs new file mode 100644 index 000000000..8d6c1f5da --- /dev/null +++ b/tests/auto/blackbox/testdata/not-always-updated/not-always-updated.qbs @@ -0,0 +1,31 @@ +import qbs.TextFile + +Product { + type: "p" + Rule { + multiplex: true + Artifact { filePath: "dummy.txt"; fileTags: "t1"; alwaysUpdated: false } + prepare: { + var cmd = new JavaScriptCommand(); + cmd.description = "creating dummy"; + cmd.sourceCode = function() {}; + return cmd; + } + } + Rule { + inputs: "t1" + Artifact { filePath: "o.txt"; fileTags: "p" } + prepare: { + var cmd = new JavaScriptCommand; + cmd.description = "creating final"; + cmd.sourceCode = function() { + var f = new TextFile(output.filePath, TextFile.WriteOnly); + f.close(); + }; + return cmd; + } + } +} + + + diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp index 800ad5870..ea8b9bd52 100644 --- a/tests/auto/blackbox/tst_blackbox.cpp +++ b/tests/auto/blackbox/tst_blackbox.cpp @@ -4563,6 +4563,13 @@ void TestBlackbox::nonDefaultProduct() QVERIFY2(QFile::exists(nonDefaultAppExe), qPrintable(nonDefaultAppExe)); } +void TestBlackbox::notAlwaysUpdated() +{ + QDir::setCurrent(testDataDir + "/not-always-updated"); + QCOMPARE(runQbs(), 0); + QCOMPARE(runQbs(), 0); +} + static void switchProfileContents(qbs::Profile &p, qbs::Settings *s, bool on) { const QString scalarKey = "leaf.scalarProp"; diff --git a/tests/auto/blackbox/tst_blackbox.h b/tests/auto/blackbox/tst_blackbox.h index 33aba02eb..92ba338ab 100644 --- a/tests/auto/blackbox/tst_blackbox.h +++ b/tests/auto/blackbox/tst_blackbox.h @@ -193,6 +193,7 @@ private slots: void nodejs(); void nonBrokenFilesInBrokenProduct(); void nonDefaultProduct(); + void notAlwaysUpdated(); void nsis(); void nsisDependencies(); void outOfDateMarking(); |