Pārlūkot izejas kodu

BUG: Hack to make echo command work properly in mingw32-make.

Brad King 19 gadi atpakaļ
vecāks
revīzija
7e92f0b4e4

+ 16 - 0
Source/cmGlobalMinGWMakefileGenerator.cxx

@@ -61,6 +61,22 @@ cmLocalGenerator *cmGlobalMinGWMakefileGenerator::CreateLocalGenerator()
   lg->SetIgnoreLibPrefix(true);
   lg->SetPassMakeflags(false);
   lg->SetUnixCD(true);
+
+  // mingw32-make has trouble running code like
+  //
+  //  @echo message with spaces
+  //
+  // If quotes are added
+  //
+  //  @echo "message with spaces"
+  //
+  // it runs but the quotes are displayed.  Instead we can separate
+  // with a semicolon
+  //
+  //  @echo;message with spaces
+  //
+  // to hack around the problem.
+  lg->SetNativeEchoCommand("@echo;");
   return lg;
 }
 

+ 2 - 1
Source/cmLocalUnixMakefileGenerator3.cxx

@@ -50,6 +50,7 @@ cmLocalUnixMakefileGenerator3::cmLocalUnixMakefileGenerator3()
   this->ColorMakefile = false;
   this->SkipPreprocessedSourceRules = false;
   this->SkipAssemblySourceRules = false;
+  this->NativeEchoCommand = "@echo ";
 }
 
 //----------------------------------------------------------------------------
@@ -1044,7 +1045,7 @@ cmLocalUnixMakefileGenerator3::AppendEcho(std::vector<std::string>& commands,
         if(color_name.empty())
           {
           // Use the native echo command.
-          cmd = "@echo ";
+          cmd = this->NativeEchoCommand;
           cmd += this->EscapeForShell(line.c_str(), false, true);
           }
         else

+ 9 - 0
Source/cmLocalUnixMakefileGenerator3.h

@@ -130,6 +130,14 @@ public:
    */
   void SetSilentNoColon(bool v)  {this->SilentNoColon = v;}
 
+  /**
+   * Set the command to use for native make shell echo.  The value
+   * should include all parts of the command up to the beginning of
+   * the message (including a whitespace separator).
+   */
+  void SetNativeEchoCommand(const char* cmd)
+    { this->NativeEchoCommand = cmd; }
+
   /**
    * Set the string used to include one makefile into another default
    * is include.
@@ -332,6 +340,7 @@ private:
   std::string ExecutableOutputPath;
   std::string LibraryOutputPath;
   std::string ConfigurationName;
+  std::string NativeEchoCommand;
   bool DefineWindowsNULL;
   bool UnixCD;
   bool PassMakeflags;