Преглед изворни кода

Merge topic 'makefile-DELETE_ON_ERROR'

44990732 Help: Add notes for topic 'makefile-DELETE_ON_ERROR'
4adf1dad Makefile: Tell GNU make to delete rule outputs on error (#15474)
Brad King пре 10 година
родитељ
комит
aa508a5299

+ 7 - 0
Help/release/dev/makefile-DELETE_ON_ERROR.rst

@@ -0,0 +1,7 @@
+makefile-DELETE_ON_ERROR
+------------------------
+
+* The Makefile generators now add ``.DELETE_ON_ERROR`` to the
+  makefiles that contain the actual build rules for files on disk.
+  This tells GNU make to remove rule outputs when their recipe
+  modifies an output but fails.

+ 1 - 0
Source/cmGlobalBorlandMakefileGenerator.h

@@ -46,6 +46,7 @@ public:
                               cmMakefile *, bool optional);
 
   virtual bool AllowNotParallel() const { return false; }
+  virtual bool AllowDeleteOnError() const { return false; }
 };
 
 #endif

+ 3 - 0
Source/cmGlobalUnixMakefileGenerator3.h

@@ -128,6 +128,9 @@ public:
   /** Does the make tool tolerate .NOTPARALLEL? */
   virtual bool AllowNotParallel() const { return true; }
 
+  /** Does the make tool tolerate .DELETE_ON_ERROR? */
+  virtual bool AllowDeleteOnError() const { return true; }
+
   virtual void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const;
 protected:
   void WriteMainMakefile2();

+ 1 - 0
Source/cmGlobalWatcomWMakeGenerator.h

@@ -45,6 +45,7 @@ public:
                               cmMakefile *, bool optional);
 
   virtual bool AllowNotParallel() const { return false; }
+  virtual bool AllowDeleteOnError() const { return false; }
 };
 
 #endif

+ 8 - 0
Source/cmMakefileTargetGenerator.cxx

@@ -122,6 +122,14 @@ void cmMakefileTargetGenerator::CreateRuleFile()
     return;
     }
   this->LocalGenerator->WriteDisclaimer(*this->BuildFileStream);
+  if (this->GlobalGenerator->AllowDeleteOnError())
+    {
+    std::vector<std::string> no_depends;
+    std::vector<std::string> no_commands;
+    this->LocalGenerator->WriteMakeRule(
+      *this->BuildFileStream, "Delete rule output on recipe failure.",
+      ".DELETE_ON_ERROR", no_depends, no_commands, false);
+    }
   this->LocalGenerator->WriteSpecialTargetsTop(*this->BuildFileStream);
 }