Skip to content

Ninja: Provide a way to clean a specific target

I made a change to the sources of an example but couldn't see any changes when running it after building, so I figured I'd try to rebuild the example (object files, executable, etc.) completely. I searched for "clean target ninja" and found this comment:

https://github.com/ninja-build/ninja/issues/317#issuecomment-5948119

Not knowing any better, I tried it out:

C:\dev\qt-dev-debug\qtdeclarative>ninja -t clean quick_shadereffects
Cleaning... 2958 files.

Turns out this actually removes not only the build files for the specific target, but also all of its dependencies.

I asked around a bit internally and was told that I could do the following:

ninja -t clean -r CXX_COMPILER__quick_shadereffects_Debug
ninja -t clean -r CXX_STATIC_LIBRARY_LINKER__quick_shadereffects_Debug

Apparently this cleans files specific to a rule and target, but I don't really understand how it works and doubt I would remember what to type. I was recommended to do the following instead:

rm -fr path\to\build\dir
cmake .
ninja

It would be nice if there was a convenient way to rebuild a specific target, or at least clean the artifact object files and link artifact.

Edited by Brad King
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information