diff options
author | Christian Kandeler <christian.kandeler@digia.com> | 2014-06-23 12:11:12 +0200 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@digia.com> | 2014-07-02 13:26:31 +0200 |
commit | c58cb5910281cfcaed015cca8723776c5003826d (patch) | |
tree | a93833874340cb9791ff094817fa29e29ea46cde /src/lib/corelib/api | |
parent | 4767c3ee950e4e08d897ccd7c350ab0b3c45412e (diff) |
Make sure to remove empty parent directories when removing artifacts.
We create these directories when we create the artifacts, so we have to
remove them when the artifacts are removed.
For safety, we do not do that for artifacts located outside of the build
directory.
Task-number: QBS-630
Change-Id: I4da91a2b940ddea6837cb881bf3dc777b71fe702
Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
Diffstat (limited to 'src/lib/corelib/api')
-rw-r--r-- | src/lib/corelib/api/project.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/lib/corelib/api/project.cpp b/src/lib/corelib/api/project.cpp index 6919a1b94..b77ee138d 100644 --- a/src/lib/corelib/api/project.cpp +++ b/src/lib/corelib/api/project.cpp @@ -37,6 +37,7 @@ #include "runenvironment.h" #include <buildgraph/artifact.h> #include <buildgraph/buildgraph.h> +#include <buildgraph/emptydirectoriesremover.h> #include <buildgraph/productbuilddata.h> #include <buildgraph/productinstaller.h> #include <buildgraph/projectbuilddata.h> @@ -508,12 +509,19 @@ void ProjectPrivate::removeFilesFromBuildGraph(const ResolvedProductConstPtr &pr if (!product->enabled) return; QBS_CHECK(internalProject->buildData); + ArtifactSet allRemovedArtifacts; foreach (const SourceArtifactPtr &sa, files) { + ArtifactSet removedArtifacts; Artifact * const artifact = lookupArtifact(product, sa->absoluteFilePath); - if (artifact) // Can be null if the executor has not yet applied the respective rule. - internalProject->buildData->removeArtifactAndExclusiveDependents(artifact, logger); - delete artifact; + if (artifact) { // Can be null if the executor has not yet applied the respective rule. + internalProject->buildData->removeArtifactAndExclusiveDependents(artifact, logger, + true, &removedArtifacts); + } + allRemovedArtifacts.unite(removedArtifacts); } + EmptyDirectoriesRemover(product->topLevelProject(), logger) + .removeEmptyParentDirectories(allRemovedArtifacts); + qDeleteAll(allRemovedArtifacts); } static void updateLocationIfNecessary(CodeLocation &location, const CodeLocation &changeLocation, |