Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Order clean by path length to ensure directories can be deleted #2252

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mjansson
Copy link

@mjansson mjansson commented Feb 2, 2023

My ninja build generator is setup to create intermediate build directories and keep track of these as build outputs in order to properly clean up the intermediate directory structure with the clean ninja target.

It is cumbersome to have to track the directory hierarchy as implicit dependencies, but not doing so results in the clean target not being able to correctly order the deletion, causing directory deletions to fail due to still having files (which will be deleted later by the clean target).

A simple solution is to defer all deletions, sort by path length and perform all deletions starting with the deepest path. That guarantees that any directory is deleted after all the files in that directory.

@jhasse
Copy link
Collaborator

jhasse commented Feb 7, 2023

Needs a test, besides that LGTM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants