Fix -t clean to remove all outputs of multi-output edges#2751
Open
philwo wants to merge 1 commit intoninja-build:masterfrom
Open
Fix -t clean to remove all outputs of multi-output edges#2751philwo wants to merge 1 commit intoninja-build:masterfrom
philwo wants to merge 1 commit intoninja-build:masterfrom
Conversation
When cleaning a specific target with `ninja -t clean <target>`, DoCleanTarget only removed the named target file. For multi-output edges (e.g. `build a.txt | b.txt: gen in.txt`), the other outputs were left behind even though they are produced by the same command and cannot be rebuilt independently. Fix by iterating over all edge outputs in DoCleanTarget, consistent with how CleanAll already handles multi-output edges.
There was a problem hiding this comment.
Pull request overview
Fixes ninja -t clean <target> so that cleaning a single target from a multi-output edge removes all outputs produced by that edge, aligning behavior with the documented “recursively all files built for them” semantics.
Changes:
- Update
Cleaner::DoCleanTargetto remove every output in the producing edge (not only the named target). - Add a unit test verifying multi-output edge cleanup behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/clean.cc |
Ensures CleanTarget removes all outputs of the target’s generating edge before recursing. |
src/clean_test.cc |
Adds coverage for cleaning a target that is one of multiple outputs from the same edge. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When cleaning a specific target with
ninja -t clean <target>, DoCleanTarget only removed the named target file. For multi-output edges (e.g.build a.txt | b.txt: gen in.txt), the other outputs were left behind even though they are produced by the same command and cannot be rebuilt independently. The docs say "additional arguments are targets, which removes the given targets and recursively all files built for them", so I think this is a bug.Fix by iterating over all edge outputs in DoCleanTarget, consistent with how CleanAll already handles multi-output edges.