diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2020-02-21 18:21:06 +0100 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2020-03-03 09:15:55 +0000 |
commit | 41d39eee1272a00d2bdbe525aff8d99ec2a4d7f8 (patch) | |
tree | 4cc16b7c7460153c49a8d3369f8ad51c3ca4ed3e /src | |
parent | 971cd8c44ffe1623d2129931ed88471432064b01 (diff) |
Artifact Scanning: Prefer scan results from product dependencies
If scanning finds an artifact in more than one product, we so far
randomly used one of them. We now prefer artifacts from product
dependencies, because the other ones might get lost during change
tracking, as we don't keep an "is scan result of" type of information in
our RescuableArtifactData.
This should fix the linked bug in the vast majority of actual projects.
It's also conceptually the right thing to do, because the artifact in
the product dependency is much more likely to be the one that was
intended to be found.
Task-number: QBS-1532
Change-Id: Idd8662bb00570bc57f5861ce83517f0adb845b49
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/corelib/buildgraph/inputartifactscanner.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/lib/corelib/buildgraph/inputartifactscanner.cpp b/src/lib/corelib/buildgraph/inputartifactscanner.cpp index 14f39bb2a..a341b2f6b 100644 --- a/src/lib/corelib/buildgraph/inputartifactscanner.cpp +++ b/src/lib/corelib/buildgraph/inputartifactscanner.cpp @@ -77,6 +77,7 @@ static void resolveDepencency(const RawScannedDependency &dependency, FileDependency *fileDependencyArtifact = nullptr; Artifact *dependencyInProduct = nullptr; Artifact *dependencyInOtherProduct = nullptr; + bool productOfDependencyIsDependency = false; const auto files = project->topLevelProject() ->buildData->lookupFiles(absDirPath, dependency.fileName()); for (FileResourceBase *lookupResult : files) { @@ -86,10 +87,13 @@ static void resolveDepencency(const RawScannedDependency &dependency, break; case FileResourceBase::FileTypeArtifact: { auto const foundArtifact = static_cast<Artifact *>(lookupResult); - if (foundArtifact->product == product) + if (foundArtifact->product == product) { dependencyInProduct = foundArtifact; - else + } else if (!productOfDependencyIsDependency) { dependencyInOtherProduct = foundArtifact; + productOfDependencyIsDependency + = contains(product->dependencies, dependencyInOtherProduct->product.lock()); + } break; } } @@ -102,6 +106,14 @@ static void resolveDepencency(const RawScannedDependency &dependency, || (result->file = dependencyInOtherProduct) || (result->file = fileDependencyArtifact)) { result->filePath = result->file->filePath(); + + if (result->file == dependencyInOtherProduct && !productOfDependencyIsDependency) { + qCDebug(lcDepScan) << "product" << dependencyInOtherProduct->product->fullDisplayName() + << "of scanned dependency" << result->filePath + << "is not a dependency of product" << product->fullDisplayName() + << ". The file dependency might get lost during change tracking."; + } + return; } |