From 7e92f0b4e449057bff26579596ccd11ee8c3c7e3 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 5 Oct 2006 14:51:20 -0400 Subject: BUG: Hack to make echo command work properly in mingw32-make. --- Source/cmGlobalMinGWMakefileGenerator.cxx | 16 ++++++++++++++++ Source/cmLocalUnixMakefileGenerator3.cxx | 3 ++- Source/cmLocalUnixMakefileGenerator3.h | 9 +++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/Source/cmGlobalMinGWMakefileGenerator.cxx b/Source/cmGlobalMinGWMakefileGenerator.cxx index f66134c..c024f6f 100644 --- a/Source/cmGlobalMinGWMakefileGenerator.cxx +++ b/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; } diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index c39b898..db5d011 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/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& commands, if(color_name.empty()) { // Use the native echo command. - cmd = "@echo "; + cmd = this->NativeEchoCommand; cmd += this->EscapeForShell(line.c_str(), false, true); } else diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h index 260f2aa..e79065d 100644 --- a/Source/cmLocalUnixMakefileGenerator3.h +++ b/Source/cmLocalUnixMakefileGenerator3.h @@ -131,6 +131,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; -- cgit v0.12 c4f82eaab73e6dbf5db59f7f74'>plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/*============================================================================
  CMake - Cross Platform Makefile Generator
  Copyright 2000-2009 Kitware, Inc., Insight Software Consortium

  Distributed under the OSI-approved BSD License (the "License");
  see accompanying file Copyright.txt for details.

  This software is distributed WITHOUT ANY WARRANTY; without even the
  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  See the License for more information.
============================================================================*/
#include "cmProcessTools.h"

#include <cmsys/Process.h>

//----------------------------------------------------------------------------
void cmProcessTools::RunProcess(struct cmsysProcess_s* cp,
                                OutputParser* out, OutputParser* err)
{
  cmsysProcess_Execute(cp);
  char* data = 0;
  int length = 0;
  int p;
  while((out||err) && (p=cmsysProcess_WaitForData(cp, &data, &length, 0), p))
    {
    if(out && p == cmsysProcess_Pipe_STDOUT)
      {
      if(!out->Process(data, length))
        {
        out = 0;
        }
      }
    else if(err && p == cmsysProcess_Pipe_STDERR)
      {
      if(!err->Process(data, length))
        {
        err = 0;
        }
      }
    }
  cmsysProcess_WaitForExit(cp, 0);
}


//----------------------------------------------------------------------------
cmProcessTools::LineParser::LineParser(char sep, bool ignoreCR):
   Log(0), Prefix(0), Separator(sep), LineEnd('\0'), IgnoreCR(ignoreCR)
{
}

//----------------------------------------------------------------------------
void cmProcessTools::LineParser::SetLog(std::ostream* log, const char* prefix)
{
  this->Log = log;
  this->Prefix = prefix? prefix : "";
}

//----------------------------------------------------------------------------
bool cmProcessTools::LineParser::ProcessChunk(const char* first, int length)
{
  const char* last = first + length;
  for(const char* c = first; c != last; ++c)
    {
    if(*c == this->Separator || *c == '\0')
      {
      this->LineEnd = *c;

      // Log this line.
      if(this->Log && this->Prefix)
        {
        *this->Log << this->Prefix << this->Line << "\n";
        }

      // Hand this line to the subclass implementation.
      if(!this->ProcessLine())
        {
        this->Line = "";
        return false;
        }

      this->Line = "";
      }
    else if(*c != '\r' || !this->IgnoreCR)
      {
      // Append this character to the line under construction.
      this->Line.append(1, *c);
      }
    }
  return true;
}