From 3bd41f2eb564d891c95e3ead5e72656b7daa3ff1 Mon Sep 17 00:00:00 2001 From: Nicolas Despres Date: Thu, 19 Apr 2012 16:47:48 +0200 Subject: [PATCH] Ninja: Add a convenient 'clean' target. It has been asked on the mailing list: http://public.kitware.com/pipermail/cmake-developers/2012-April/003805.html --- Source/cmGlobalNinjaGenerator.cxx | 21 +++++++++++++++++++++ Source/cmGlobalNinjaGenerator.h | 1 + 2 files changed, 22 insertions(+) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 9cbd50233..ee3842d0b 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -754,6 +754,7 @@ void cmGlobalNinjaGenerator::WriteBuiltinTargets(std::ostream& os) this->WriteTargetAll(os); this->WriteTargetRebuildManifest(os); + this->WriteTargetClean(os); } void cmGlobalNinjaGenerator::WriteTargetAll(std::ostream& os) @@ -820,3 +821,23 @@ void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream& os) implicitDeps, cmNinjaDeps()); } + +void cmGlobalNinjaGenerator::WriteTargetClean(std::ostream& os) +{ + WriteRule(*this->RulesFileStream, + "CLEAN", + "ninja -t clean", + "Cleaning all built files...", + "Rule for cleaning all built files.", + /*depfile=*/ "", + /*restat=*/ false, + /*generator=*/ false); + WriteBuild(os, + "Clean all the built files.", + "CLEAN", + /*outputs=*/ cmNinjaDeps(1, "clean"), + /*explicitDeps=*/ cmNinjaDeps(), + /*implicitDeps=*/ cmNinjaDeps(), + /*orderOnlyDeps=*/ cmNinjaDeps(), + /*variables=*/ cmNinjaVars()); +} diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 321758185..32edfaabc 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -273,6 +273,7 @@ private: void WriteBuiltinTargets(std::ostream& os); void WriteTargetAll(std::ostream& os); void WriteTargetRebuildManifest(std::ostream& os); + void WriteTargetClean(std::ostream& os); /// Called when we have seen the given custom command. Returns true /// if we has seen it before.