ENH: Enabled color printing of "Scanning dependencies of target ..." message.
This commit is contained in:
parent
f0824c7a19
commit
73704ede42
|
@ -163,7 +163,8 @@ public:
|
||||||
|
|
||||||
/** Called from command-line hook to update dependencies. */
|
/** Called from command-line hook to update dependencies. */
|
||||||
virtual bool UpdateDependencies(const char* /* tgtInfo */,
|
virtual bool UpdateDependencies(const char* /* tgtInfo */,
|
||||||
bool /*verbose*/)
|
bool /*verbose*/,
|
||||||
|
bool /*color*/)
|
||||||
{ return true; }
|
{ return true; }
|
||||||
|
|
||||||
/** Compute the list of link libraries and directories for the given
|
/** Compute the list of link libraries and directories for the given
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#ifdef CMAKE_BUILD_WITH_CMAKE
|
#ifdef CMAKE_BUILD_WITH_CMAKE
|
||||||
# include "cmDependsFortran.h"
|
# include "cmDependsFortran.h"
|
||||||
# include "cmDependsJava.h"
|
# include "cmDependsJava.h"
|
||||||
|
# include <cmsys/Terminal.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <memory> // auto_ptr
|
#include <memory> // auto_ptr
|
||||||
|
@ -1225,7 +1226,8 @@ cmLocalUnixMakefileGenerator3
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
bool cmLocalUnixMakefileGenerator3::UpdateDependencies(const char* tgtInfo,
|
bool cmLocalUnixMakefileGenerator3::UpdateDependencies(const char* tgtInfo,
|
||||||
bool verbose)
|
bool verbose,
|
||||||
|
bool color)
|
||||||
{
|
{
|
||||||
std::string dir = cmSystemTools::GetFilenamePath(tgtInfo);
|
std::string dir = cmSystemTools::GetFilenamePath(tgtInfo);
|
||||||
std::string internalDependFile = dir + "/depend.internal";
|
std::string internalDependFile = dir + "/depend.internal";
|
||||||
|
@ -1242,11 +1244,18 @@ bool cmLocalUnixMakefileGenerator3::UpdateDependencies(const char* tgtInfo,
|
||||||
if(!checker.Check(dependFile.c_str(), internalDependFile.c_str()))
|
if(!checker.Check(dependFile.c_str(), internalDependFile.c_str()))
|
||||||
{
|
{
|
||||||
// The dependencies must be regenerated.
|
// The dependencies must be regenerated.
|
||||||
|
|
||||||
// TODO: Make this like cmLocalUnixMakefileGenerator3::EchoDepend
|
|
||||||
std::string targetName = cmSystemTools::GetFilenameName(dir);
|
std::string targetName = cmSystemTools::GetFilenameName(dir);
|
||||||
targetName = targetName.substr(0, targetName.length()-4);
|
targetName = targetName.substr(0, targetName.length()-4);
|
||||||
fprintf(stdout, "Scanning dependencies of target %s\n", targetName.c_str());
|
std::string message = "Scanning dependencies of target ";
|
||||||
|
message += targetName;
|
||||||
|
#ifdef CMAKE_BUILD_WITH_CMAKE
|
||||||
|
cmSystemTools::MakefileColorEcho(
|
||||||
|
cmsysTerminal_Color_ForegroundMagenta |
|
||||||
|
cmsysTerminal_Color_ForegroundBold,
|
||||||
|
message.c_str(), true, color);
|
||||||
|
#else
|
||||||
|
fprintf(stdout, "%s\n", message.c_str());
|
||||||
|
#endif
|
||||||
|
|
||||||
return this->ScanDependencies(tgtInfo);
|
return this->ScanDependencies(tgtInfo);
|
||||||
}
|
}
|
||||||
|
|
|
@ -200,7 +200,8 @@ public:
|
||||||
|
|
||||||
/** Called from command-line hook to bring dependencies up to date
|
/** Called from command-line hook to bring dependencies up to date
|
||||||
for a target. */
|
for a target. */
|
||||||
virtual bool UpdateDependencies(const char* tgtInfo, bool verbose);
|
virtual bool UpdateDependencies(const char* tgtInfo,
|
||||||
|
bool verbose, bool color);
|
||||||
|
|
||||||
/** Called from command-line hook to scan dependencies. */
|
/** Called from command-line hook to scan dependencies. */
|
||||||
bool ScanDependencies(const char* tgtInfo);
|
bool ScanDependencies(const char* tgtInfo);
|
||||||
|
|
|
@ -805,7 +805,7 @@ void cmMakefileTargetGenerator::WriteTargetDependRules()
|
||||||
// cmake -E cmake_depends <generator>
|
// cmake -E cmake_depends <generator>
|
||||||
// <home-src-dir> <start-src-dir>
|
// <home-src-dir> <start-src-dir>
|
||||||
// <home-out-dir> <start-out-dir>
|
// <home-out-dir> <start-out-dir>
|
||||||
// <dep-info>
|
// <dep-info> --color=$(COLOR)
|
||||||
//
|
//
|
||||||
// This gives the dependency scanner enough information to recreate
|
// This gives the dependency scanner enough information to recreate
|
||||||
// the state of our local generator sufficiently for its needs.
|
// the state of our local generator sufficiently for its needs.
|
||||||
|
@ -824,7 +824,8 @@ void cmMakefileTargetGenerator::WriteTargetDependRules()
|
||||||
cmLocalGenerator::FULL, cmLocalGenerator::SHELL)
|
cmLocalGenerator::FULL, cmLocalGenerator::SHELL)
|
||||||
<< " "
|
<< " "
|
||||||
<< this->Convert(this->InfoFileNameFull.c_str(),
|
<< this->Convert(this->InfoFileNameFull.c_str(),
|
||||||
cmLocalGenerator::FULL, cmLocalGenerator::SHELL);
|
cmLocalGenerator::FULL, cmLocalGenerator::SHELL)
|
||||||
|
<< " --color=$(COLOR)";
|
||||||
commands.push_back(depCmd.str());
|
commands.push_back(depCmd.str());
|
||||||
|
|
||||||
// Make sure all custom command outputs in this target are built.
|
// Make sure all custom command outputs in this target are built.
|
||||||
|
|
|
@ -23,6 +23,9 @@
|
||||||
#include <cmsys/RegularExpression.hxx>
|
#include <cmsys/RegularExpression.hxx>
|
||||||
#include <cmsys/Directory.hxx>
|
#include <cmsys/Directory.hxx>
|
||||||
#include <cmsys/System.h>
|
#include <cmsys/System.h>
|
||||||
|
#if defined(CMAKE_BUILD_WITH_CMAKE)
|
||||||
|
# include <cmsys/Terminal.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
# include <windows.h>
|
# include <windows.h>
|
||||||
|
@ -2087,3 +2090,36 @@ const char* cmSystemTools::GetExecutableDirectory()
|
||||||
{
|
{
|
||||||
return cmSystemToolsExecutableDirectory.c_str();
|
return cmSystemToolsExecutableDirectory.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
#if defined(CMAKE_BUILD_WITH_CMAKE)
|
||||||
|
void cmSystemTools::MakefileColorEcho(int color, const char* message,
|
||||||
|
bool newline, bool enabled)
|
||||||
|
{
|
||||||
|
// On some platforms (an MSYS prompt) cmsysTerminal may not be able
|
||||||
|
// to determine whether the stream is displayed on a tty. In this
|
||||||
|
// case it assumes no unless we tell it otherwise. Since we want
|
||||||
|
// color messages to be displayed for users we will assume yes.
|
||||||
|
// However, we can test for some situations when the answer is most
|
||||||
|
// likely no.
|
||||||
|
int assumeTTY = cmsysTerminal_Color_AssumeTTY;
|
||||||
|
if(cmSystemTools::GetEnv("DART_TEST_FROM_DART") ||
|
||||||
|
cmSystemTools::GetEnv("DASHBOARD_TEST_FROM_CTEST") ||
|
||||||
|
cmSystemTools::GetEnv("CTEST_INTERACTIVE_DEBUG_MODE"))
|
||||||
|
{
|
||||||
|
// Avoid printing color escapes during dashboard builds.
|
||||||
|
assumeTTY = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(enabled)
|
||||||
|
{
|
||||||
|
cmsysTerminal_cfprintf(color | assumeTTY, stdout, "%s%s",
|
||||||
|
message, newline? "\n" : "");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Color is disabled. Print without color.
|
||||||
|
fprintf(stdout, "%s%s", message, newline? "\n" : "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
|
@ -358,6 +358,12 @@ public:
|
||||||
/** Get the directory containing the currently running executable. */
|
/** Get the directory containing the currently running executable. */
|
||||||
static const char* GetExecutableDirectory();
|
static const char* GetExecutableDirectory();
|
||||||
|
|
||||||
|
#if defined(CMAKE_BUILD_WITH_CMAKE)
|
||||||
|
/** Echo a message in color using KWSys's Terminal cprintf. */
|
||||||
|
static void MakefileColorEcho(int color, const char* message,
|
||||||
|
bool newline, bool enabled);
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static bool s_ForceUnixPaths;
|
static bool s_ForceUnixPaths;
|
||||||
static bool s_RunCommandHideConsole;
|
static bool s_RunCommandHideConsole;
|
||||||
|
|
|
@ -1365,6 +1365,7 @@ int cmake::ExecuteCMakeCommand(std::vector<std::string>& args)
|
||||||
std::string homeOutDir;
|
std::string homeOutDir;
|
||||||
std::string startOutDir;
|
std::string startOutDir;
|
||||||
std::string depInfo;
|
std::string depInfo;
|
||||||
|
bool color = true;
|
||||||
if(args.size() >= 8)
|
if(args.size() >= 8)
|
||||||
{
|
{
|
||||||
// Full signature:
|
// Full signature:
|
||||||
|
@ -1372,7 +1373,7 @@ int cmake::ExecuteCMakeCommand(std::vector<std::string>& args)
|
||||||
// -E cmake_depends <generator>
|
// -E cmake_depends <generator>
|
||||||
// <home-src-dir> <start-src-dir>
|
// <home-src-dir> <start-src-dir>
|
||||||
// <home-out-dir> <start-out-dir>
|
// <home-out-dir> <start-out-dir>
|
||||||
// <dep-info>
|
// <dep-info> [--color=$(COLOR)]
|
||||||
//
|
//
|
||||||
// All paths are provided.
|
// All paths are provided.
|
||||||
gen = args[2];
|
gen = args[2];
|
||||||
|
@ -1381,6 +1382,13 @@ int cmake::ExecuteCMakeCommand(std::vector<std::string>& args)
|
||||||
homeOutDir = args[5];
|
homeOutDir = args[5];
|
||||||
startOutDir = args[6];
|
startOutDir = args[6];
|
||||||
depInfo = args[7];
|
depInfo = args[7];
|
||||||
|
if(args.size() >= 9 &&
|
||||||
|
args[8].length() > 8 &&
|
||||||
|
args[8].substr(0, 8) == "--color=")
|
||||||
|
{
|
||||||
|
// Enable or disable color based on the switch value.
|
||||||
|
color = cmSystemTools::IsOn(args[8].substr(8).c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1420,7 +1428,8 @@ int cmake::ExecuteCMakeCommand(std::vector<std::string>& args)
|
||||||
lgd->GetMakefile()->MakeStartDirectoriesCurrent();
|
lgd->GetMakefile()->MakeStartDirectoriesCurrent();
|
||||||
|
|
||||||
// Actually scan dependencies.
|
// Actually scan dependencies.
|
||||||
return lgd->UpdateDependencies(depInfo.c_str(), verbose)? 0 : 2;
|
return lgd->UpdateDependencies(depInfo.c_str(),
|
||||||
|
verbose, color)? 0 : 2;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -3020,21 +3029,6 @@ int cmake::ExecuteEchoColor(std::vector<std::string>& args)
|
||||||
// argv[0] == <cmake-executable>
|
// argv[0] == <cmake-executable>
|
||||||
// argv[1] == cmake_echo_color
|
// argv[1] == cmake_echo_color
|
||||||
|
|
||||||
// On some platforms (an MSYS prompt) cmsysTerminal may not be able
|
|
||||||
// to determine whether the stream is displayed on a tty. In this
|
|
||||||
// case it assumes no unless we tell it otherwise. Since we want
|
|
||||||
// color messages to be displayed for users we will assume yes.
|
|
||||||
// However, we can test for some situations when the answer is most
|
|
||||||
// likely no.
|
|
||||||
int assumeTTY = cmsysTerminal_Color_AssumeTTY;
|
|
||||||
if(cmSystemTools::GetEnv("DART_TEST_FROM_DART") ||
|
|
||||||
cmSystemTools::GetEnv("DASHBOARD_TEST_FROM_CTEST") ||
|
|
||||||
cmSystemTools::GetEnv("CTEST_INTERACTIVE_DEBUG_MODE"))
|
|
||||||
{
|
|
||||||
// Avoid printing color escapes during dashboard builds.
|
|
||||||
assumeTTY = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool enabled = true;
|
bool enabled = true;
|
||||||
int color = cmsysTerminal_Color_Normal;
|
int color = cmsysTerminal_Color_Normal;
|
||||||
bool newline = true;
|
bool newline = true;
|
||||||
|
@ -3104,16 +3098,11 @@ int cmake::ExecuteEchoColor(std::vector<std::string>& args)
|
||||||
{
|
{
|
||||||
newline = true;
|
newline = true;
|
||||||
}
|
}
|
||||||
else if(enabled)
|
|
||||||
{
|
|
||||||
// Color is enabled. Print with the current color.
|
|
||||||
cmsysTerminal_cfprintf(color | assumeTTY, stdout, "%s%s",
|
|
||||||
args[i].c_str(), newline? "\n" : "");
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Color is disabled. Print without color.
|
// Color is enabled. Print with the current color.
|
||||||
fprintf(stdout, "%s%s", args[i].c_str(), newline? "\n" : "");
|
cmSystemTools::MakefileColorEcho(color, args[i].c_str(),
|
||||||
|
newline, enabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue