ENH: Implemented VT100 terminal escape sequences. If CMAKE_COLOR_MAKEFILE is set then messages produced by makefiles will be in color if the native tool supports it. This addresses bug#3060.
This commit is contained in:
parent
5a2668b326
commit
eb31755eb2
@ -24,6 +24,7 @@ cmGlobalBorlandMakefileGenerator::cmGlobalBorlandMakefileGenerator()
|
|||||||
this->EmptyRuleHackDepends = "NUL";
|
this->EmptyRuleHackDepends = "NUL";
|
||||||
this->FindMakeProgramFile = "CMakeBorlandFindMake.cmake";
|
this->FindMakeProgramFile = "CMakeBorlandFindMake.cmake";
|
||||||
this->ForceUnixPaths = false;
|
this->ForceUnixPaths = false;
|
||||||
|
this->ToolSupportsColorVT100 = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,6 +33,9 @@ cmGlobalGenerator::cmGlobalGenerator()
|
|||||||
{
|
{
|
||||||
// by default use the native paths
|
// by default use the native paths
|
||||||
this->ForceUnixPaths = false;
|
this->ForceUnixPaths = false;
|
||||||
|
|
||||||
|
// By default do not try to support color.
|
||||||
|
this->ToolSupportsColorVT100 = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
cmGlobalGenerator::~cmGlobalGenerator()
|
cmGlobalGenerator::~cmGlobalGenerator()
|
||||||
|
@ -127,6 +127,7 @@ public:
|
|||||||
static int s_TryCompileTimeout;
|
static int s_TryCompileTimeout;
|
||||||
|
|
||||||
bool GetForceUnixPaths() {return this->ForceUnixPaths;}
|
bool GetForceUnixPaths() {return this->ForceUnixPaths;}
|
||||||
|
bool GetToolSupportsColorVT100() { return this->ToolSupportsColorVT100; }
|
||||||
///! return the language for the given extension
|
///! return the language for the given extension
|
||||||
const char* GetLanguageFromExtension(const char* ext);
|
const char* GetLanguageFromExtension(const char* ext);
|
||||||
///! is an extension to be ignored
|
///! is an extension to be ignored
|
||||||
@ -193,6 +194,7 @@ protected:
|
|||||||
virtual const char* GetRebuildCacheTargetName() { return 0; }
|
virtual const char* GetRebuildCacheTargetName() { return 0; }
|
||||||
|
|
||||||
bool ForceUnixPaths;
|
bool ForceUnixPaths;
|
||||||
|
bool ToolSupportsColorVT100;
|
||||||
cmStdString FindMakeProgramFile;
|
cmStdString FindMakeProgramFile;
|
||||||
cmStdString ConfiguredFilesPath;
|
cmStdString ConfiguredFilesPath;
|
||||||
cmake *CMakeInstance;
|
cmake *CMakeInstance;
|
||||||
|
@ -28,6 +28,7 @@ cmGlobalKdevelopGenerator::cmGlobalKdevelopGenerator()
|
|||||||
// This type of makefile always requires unix style paths
|
// This type of makefile always requires unix style paths
|
||||||
this->ForceUnixPaths = true;
|
this->ForceUnixPaths = true;
|
||||||
this->FindMakeProgramFile = "CMakeUnixFindMake.cmake";
|
this->FindMakeProgramFile = "CMakeUnixFindMake.cmake";
|
||||||
|
this->ToolSupportsColorVT100 = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
///! Create a local generator appropriate to this Global Generator
|
///! Create a local generator appropriate to this Global Generator
|
||||||
|
@ -23,6 +23,7 @@ cmGlobalMSYSMakefileGenerator::cmGlobalMSYSMakefileGenerator()
|
|||||||
{
|
{
|
||||||
this->FindMakeProgramFile = "CMakeMSYSFindMake.cmake";
|
this->FindMakeProgramFile = "CMakeMSYSFindMake.cmake";
|
||||||
this->ForceUnixPaths = true;
|
this->ForceUnixPaths = true;
|
||||||
|
this->ToolSupportsColorVT100 = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
|
@ -22,7 +22,7 @@ cmGlobalMinGWMakefileGenerator::cmGlobalMinGWMakefileGenerator()
|
|||||||
{
|
{
|
||||||
this->FindMakeProgramFile = "CMakeMinGWFindMake.cmake";
|
this->FindMakeProgramFile = "CMakeMinGWFindMake.cmake";
|
||||||
this->ForceUnixPaths = true;
|
this->ForceUnixPaths = true;
|
||||||
|
this->ToolSupportsColorVT100 = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmGlobalMinGWMakefileGenerator::EnableLanguage(std::vector<std::string>const& l,
|
void cmGlobalMinGWMakefileGenerator::EnableLanguage(std::vector<std::string>const& l,
|
||||||
|
@ -22,6 +22,7 @@ cmGlobalNMakeMakefileGenerator::cmGlobalNMakeMakefileGenerator()
|
|||||||
{
|
{
|
||||||
this->FindMakeProgramFile = "CMakeNMakeFindMake.cmake";
|
this->FindMakeProgramFile = "CMakeNMakeFindMake.cmake";
|
||||||
this->ForceUnixPaths = false;
|
this->ForceUnixPaths = false;
|
||||||
|
this->ToolSupportsColorVT100 = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmGlobalNMakeMakefileGenerator::EnableLanguage(std::vector<std::string>const& l,
|
void cmGlobalNMakeMakefileGenerator::EnableLanguage(std::vector<std::string>const& l,
|
||||||
|
@ -26,6 +26,7 @@ cmGlobalUnixMakefileGenerator3::cmGlobalUnixMakefileGenerator3()
|
|||||||
// This type of makefile always requires unix style paths
|
// This type of makefile always requires unix style paths
|
||||||
this->ForceUnixPaths = true;
|
this->ForceUnixPaths = true;
|
||||||
this->FindMakeProgramFile = "CMakeUnixFindMake.cmake";
|
this->FindMakeProgramFile = "CMakeUnixFindMake.cmake";
|
||||||
|
this->ToolSupportsColorVT100 = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmGlobalUnixMakefileGenerator3
|
void cmGlobalUnixMakefileGenerator3
|
||||||
|
@ -22,6 +22,7 @@ cmGlobalWatcomWMakeGenerator::cmGlobalWatcomWMakeGenerator()
|
|||||||
{
|
{
|
||||||
this->FindMakeProgramFile = "CMakeFindWMake.cmake";
|
this->FindMakeProgramFile = "CMakeFindWMake.cmake";
|
||||||
this->ForceUnixPaths = false;
|
this->ForceUnixPaths = false;
|
||||||
|
this->ToolSupportsColorVT100 = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmGlobalWatcomWMakeGenerator::EnableLanguage(std::vector<std::string>const& l,
|
void cmGlobalWatcomWMakeGenerator::EnableLanguage(std::vector<std::string>const& l,
|
||||||
|
@ -35,6 +35,28 @@
|
|||||||
#include <memory> // auto_ptr
|
#include <memory> // auto_ptr
|
||||||
#include <queue>
|
#include <queue>
|
||||||
|
|
||||||
|
#define CMAKE_VT100_NORMAL "\33[0m"
|
||||||
|
#define CMAKE_VT100_BOLD "\33[1m"
|
||||||
|
#define CMAKE_VT100_UNDERLINE "\33[4m"
|
||||||
|
#define CMAKE_VT100_BLINK "\33[5m"
|
||||||
|
#define CMAKE_VT100_INVERSE "\33[7m"
|
||||||
|
#define CMAKE_VT100_FRONT_BLACK "\33[30m"
|
||||||
|
#define CMAKE_VT100_FRONT_RED "\33[31m"
|
||||||
|
#define CMAKE_VT100_FRONT_GREEN "\33[32m"
|
||||||
|
#define CMAKE_VT100_FRONT_YELLOW "\33[33m"
|
||||||
|
#define CMAKE_VT100_FRONT_BLUE "\33[34m"
|
||||||
|
#define CMAKE_VT100_FRONT_MAGENTA "\33[35m"
|
||||||
|
#define CMAKE_VT100_FRONT_CYAN "\33[36m"
|
||||||
|
#define CMAKE_VT100_FRONT_WHITE "\33[37m"
|
||||||
|
#define CMAKE_VT100_BACK_BLACK "\33[40m"
|
||||||
|
#define CMAKE_VT100_BACK_RED "\33[41m"
|
||||||
|
#define CMAKE_VT100_BACK_GREEN "\33[42m"
|
||||||
|
#define CMAKE_VT100_BACK_YELLOW "\33[43m"
|
||||||
|
#define CMAKE_VT100_BACK_BLUE "\33[44m"
|
||||||
|
#define CMAKE_VT100_BACK_MAGENTA "\33[45m"
|
||||||
|
#define CMAKE_VT100_BACK_CYAN "\33[46m"
|
||||||
|
#define CMAKE_VT100_BACK_WHITE "\33[47m"
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
cmLocalUnixMakefileGenerator3::cmLocalUnixMakefileGenerator3()
|
cmLocalUnixMakefileGenerator3::cmLocalUnixMakefileGenerator3()
|
||||||
{
|
{
|
||||||
@ -851,8 +873,37 @@ cmLocalUnixMakefileGenerator3
|
|||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void
|
void
|
||||||
cmLocalUnixMakefileGenerator3::AppendEcho(std::vector<std::string>& commands,
|
cmLocalUnixMakefileGenerator3::AppendEcho(std::vector<std::string>& commands,
|
||||||
const char* text)
|
const char* text,
|
||||||
|
EchoColor color)
|
||||||
{
|
{
|
||||||
|
// Choose the color for the text.
|
||||||
|
const char* prefix = 0;
|
||||||
|
if(this->GlobalGenerator->GetToolSupportsColorVT100() &&
|
||||||
|
this->Makefile->IsOn("CMAKE_COLOR_MAKEFILE"))
|
||||||
|
{
|
||||||
|
switch(color)
|
||||||
|
{
|
||||||
|
case EchoNormal:
|
||||||
|
break;
|
||||||
|
case EchoDepend:
|
||||||
|
prefix = CMAKE_VT100_FRONT_MAGENTA CMAKE_VT100_BOLD;
|
||||||
|
break;
|
||||||
|
case EchoBuild:
|
||||||
|
prefix = CMAKE_VT100_FRONT_GREEN CMAKE_VT100_BOLD;
|
||||||
|
break;
|
||||||
|
case EchoLink:
|
||||||
|
prefix = CMAKE_VT100_FRONT_YELLOW CMAKE_VT100_BOLD;
|
||||||
|
break;
|
||||||
|
case EchoGenerate:
|
||||||
|
prefix = CMAKE_VT100_FRONT_BLUE CMAKE_VT100_BOLD;
|
||||||
|
break;
|
||||||
|
case EchoGlobal:
|
||||||
|
prefix = CMAKE_VT100_FRONT_CYAN CMAKE_VT100_BOLD;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const char* suffix = prefix? CMAKE_VT100_NORMAL : 0;
|
||||||
|
|
||||||
// Echo one line at a time.
|
// Echo one line at a time.
|
||||||
std::string line;
|
std::string line;
|
||||||
for(const char* c = text;; ++c)
|
for(const char* c = text;; ++c)
|
||||||
@ -868,7 +919,15 @@ cmLocalUnixMakefileGenerator3::AppendEcho(std::vector<std::string>& commands,
|
|||||||
{
|
{
|
||||||
cmd += "\"";
|
cmd += "\"";
|
||||||
}
|
}
|
||||||
|
if(prefix)
|
||||||
|
{
|
||||||
|
cmd += prefix;
|
||||||
|
}
|
||||||
cmd += line;
|
cmd += line;
|
||||||
|
if(suffix)
|
||||||
|
{
|
||||||
|
cmd += suffix;
|
||||||
|
}
|
||||||
if(this->EchoNeedsQuote)
|
if(this->EchoNeedsQuote)
|
||||||
{
|
{
|
||||||
cmd += "\"";
|
cmd += "\"";
|
||||||
@ -1320,7 +1379,8 @@ void cmLocalUnixMakefileGenerator3
|
|||||||
{
|
{
|
||||||
depends.push_back(dit->c_str());
|
depends.push_back(dit->c_str());
|
||||||
}
|
}
|
||||||
this->AppendEcho(commands, text);
|
this->AppendEcho(commands, text,
|
||||||
|
cmLocalUnixMakefileGenerator3::EchoGlobal);
|
||||||
|
|
||||||
// Utility targets store their rules in pre- and post-build commands.
|
// Utility targets store their rules in pre- and post-build commands.
|
||||||
this->AppendCustomDepends(depends,
|
this->AppendCustomDepends(depends,
|
||||||
|
@ -152,7 +152,10 @@ public:
|
|||||||
std::string GetRecursiveMakeCall(const char *makefile, const char* tgt);
|
std::string GetRecursiveMakeCall(const char *makefile, const char* tgt);
|
||||||
|
|
||||||
// append an echo command
|
// append an echo command
|
||||||
void AppendEcho(std::vector<std::string>& commands, const char* text);
|
enum EchoColor { EchoNormal, EchoDepend, EchoBuild, EchoLink,
|
||||||
|
EchoGenerate, EchoGlobal };
|
||||||
|
void AppendEcho(std::vector<std::string>& commands, const char* text,
|
||||||
|
EchoColor color = EchoNormal);
|
||||||
|
|
||||||
static std::string GetTargetDirectory(cmTarget& target);
|
static std::string GetTargetDirectory(cmTarget& target);
|
||||||
|
|
||||||
|
@ -196,7 +196,8 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
|
|||||||
buildEcho += linkLanguage;
|
buildEcho += linkLanguage;
|
||||||
buildEcho += " executable ";
|
buildEcho += " executable ";
|
||||||
buildEcho += targetOutPath;
|
buildEcho += targetOutPath;
|
||||||
this->LocalGenerator->AppendEcho(commands, buildEcho.c_str());
|
this->LocalGenerator->AppendEcho(commands, buildEcho.c_str(),
|
||||||
|
cmLocalUnixMakefileGenerator3::EchoLink);
|
||||||
|
|
||||||
// Build a list of compiler flags and linker flags.
|
// Build a list of compiler flags and linker flags.
|
||||||
std::string flags;
|
std::string flags;
|
||||||
|
@ -265,7 +265,8 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
buildEcho += targetOutPath.c_str();
|
buildEcho += targetOutPath.c_str();
|
||||||
this->LocalGenerator->AppendEcho(commands, buildEcho.c_str());
|
this->LocalGenerator->AppendEcho(commands, buildEcho.c_str(),
|
||||||
|
cmLocalUnixMakefileGenerator3::EchoLink);
|
||||||
|
|
||||||
// Construct a list of files associated with this library that may
|
// Construct a list of files associated with this library that may
|
||||||
// need to be cleaned.
|
// need to be cleaned.
|
||||||
|
@ -374,7 +374,8 @@ cmMakefileTargetGenerator
|
|||||||
buildEcho += lang;
|
buildEcho += lang;
|
||||||
buildEcho += " object ";
|
buildEcho += " object ";
|
||||||
buildEcho += relativeObj;
|
buildEcho += relativeObj;
|
||||||
this->LocalGenerator->AppendEcho(commands, buildEcho.c_str());
|
this->LocalGenerator->AppendEcho(commands, buildEcho.c_str(),
|
||||||
|
cmLocalUnixMakefileGenerator3::EchoBuild);
|
||||||
|
|
||||||
// Construct the compile rules.
|
// Construct the compile rules.
|
||||||
std::string compileRuleVar = "CMAKE_";
|
std::string compileRuleVar = "CMAKE_";
|
||||||
@ -540,7 +541,8 @@ void cmMakefileTargetGenerator::WriteTargetDependRules()
|
|||||||
// Write the dependency generation rule.
|
// Write the dependency generation rule.
|
||||||
std::string depEcho = "Scanning dependencies of target ";
|
std::string depEcho = "Scanning dependencies of target ";
|
||||||
depEcho += this->Target->GetName();
|
depEcho += this->Target->GetName();
|
||||||
this->LocalGenerator->AppendEcho(commands, depEcho.c_str());
|
this->LocalGenerator->AppendEcho(commands, depEcho.c_str(),
|
||||||
|
cmLocalUnixMakefileGenerator3::EchoDepend);
|
||||||
|
|
||||||
// Add a command to call CMake to scan dependencies. CMake will
|
// Add a command to call CMake to scan dependencies. CMake will
|
||||||
// touch the corresponding depends file after scanning dependencies.
|
// touch the corresponding depends file after scanning dependencies.
|
||||||
@ -627,7 +629,9 @@ void cmMakefileTargetGenerator
|
|||||||
std::vector<std::string> commands;
|
std::vector<std::string> commands;
|
||||||
std::string preEcho = "Generating ";
|
std::string preEcho = "Generating ";
|
||||||
preEcho += output;
|
preEcho += output;
|
||||||
this->LocalGenerator->AppendEcho(commands, preEcho.c_str());
|
this->LocalGenerator
|
||||||
|
->AppendEcho(commands, preEcho.c_str(),
|
||||||
|
cmLocalUnixMakefileGenerator3::EchoGenerate);
|
||||||
this->LocalGenerator->AppendCustomCommand(commands, cc);
|
this->LocalGenerator->AppendCustomCommand(commands, cc);
|
||||||
|
|
||||||
// Collect the dependencies.
|
// Collect the dependencies.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user