[cmake-commits] king committed cmLocalGenerator.h 1.89 1.90 cmLocalUnixMakefileGenerator3.cxx 1.222 1.223 cmLocalUnixMakefileGenerator3.h 1.77 1.78 cmMakefileTargetGenerator.cxx 1.75 1.76 cmSystemTools.cxx 1.356 1.357 cmSystemTools.h 1.143 1.144 cmake.cxx 1.344 1.345

cmake-commits at cmake.org cmake-commits at cmake.org
Wed Dec 19 17:15:43 EST 2007


Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv7265/Source

Modified Files:
	cmLocalGenerator.h cmLocalUnixMakefileGenerator3.cxx 
	cmLocalUnixMakefileGenerator3.h cmMakefileTargetGenerator.cxx 
	cmSystemTools.cxx cmSystemTools.h cmake.cxx 
Log Message:
ENH: Enabled color printing of "Scanning dependencies of target ..." message.


Index: cmLocalUnixMakefileGenerator3.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalUnixMakefileGenerator3.h,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -d -r1.77 -r1.78
--- cmLocalUnixMakefileGenerator3.h	19 Dec 2007 21:36:29 -0000	1.77
+++ cmLocalUnixMakefileGenerator3.h	19 Dec 2007 22:15:41 -0000	1.78
@@ -200,7 +200,8 @@
 
   /** Called from command-line hook to bring dependencies up to date
       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.  */
   bool ScanDependencies(const char* tgtInfo);

Index: cmSystemTools.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmSystemTools.h,v
retrieving revision 1.143
retrieving revision 1.144
diff -u -d -r1.143 -r1.144
--- cmSystemTools.h	13 Dec 2007 22:56:49 -0000	1.143
+++ cmSystemTools.h	19 Dec 2007 22:15:41 -0000	1.144
@@ -358,6 +358,12 @@
   /** Get the directory containing the currently running executable.  */
   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:
   static bool s_ForceUnixPaths;
   static bool s_RunCommandHideConsole;

Index: cmLocalGenerator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalGenerator.h,v
retrieving revision 1.89
retrieving revision 1.90
diff -u -d -r1.89 -r1.90
--- cmLocalGenerator.h	19 Dec 2007 21:36:29 -0000	1.89
+++ cmLocalGenerator.h	19 Dec 2007 22:15:41 -0000	1.90
@@ -163,7 +163,8 @@
   
   /** Called from command-line hook to update dependencies.  */
   virtual bool UpdateDependencies(const char* /* tgtInfo */,
-                                  bool /*verbose*/)
+                                  bool /*verbose*/,
+                                  bool /*color*/)
     { return true; }
 
   /** Compute the list of link libraries and directories for the given

Index: cmSystemTools.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmSystemTools.cxx,v
retrieving revision 1.356
retrieving revision 1.357
diff -u -d -r1.356 -r1.357
--- cmSystemTools.cxx	13 Dec 2007 22:56:49 -0000	1.356
+++ cmSystemTools.cxx	19 Dec 2007 22:15:41 -0000	1.357
@@ -23,6 +23,9 @@
 #include <cmsys/RegularExpression.hxx>
 #include <cmsys/Directory.hxx>
 #include <cmsys/System.h>
+#if defined(CMAKE_BUILD_WITH_CMAKE)
+# include <cmsys/Terminal.h>
+#endif
 
 #if defined(_WIN32)
 # include <windows.h>
@@ -2087,3 +2090,36 @@
 {
   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

Index: cmake.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmake.cxx,v
retrieving revision 1.344
retrieving revision 1.345
diff -u -d -r1.344 -r1.345
--- cmake.cxx	19 Dec 2007 21:36:30 -0000	1.344
+++ cmake.cxx	19 Dec 2007 22:15:41 -0000	1.345
@@ -1365,6 +1365,7 @@
       std::string homeOutDir;
       std::string startOutDir;
       std::string depInfo;
+      bool color = true;
       if(args.size() >= 8)
         {
         // Full signature:
@@ -1372,7 +1373,7 @@
         //   -E cmake_depends <generator>
         //                    <home-src-dir> <start-src-dir>
         //                    <home-out-dir> <start-out-dir>
-        //                    <dep-info>
+        //                    <dep-info> [--color=$(COLOR)]
         //
         // All paths are provided.
         gen = args[2];
@@ -1381,6 +1382,13 @@
         homeOutDir = args[5];
         startOutDir = args[6];
         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
         {
@@ -1420,7 +1428,8 @@
         lgd->GetMakefile()->MakeStartDirectoriesCurrent();
 
         // Actually scan dependencies.
-        return lgd->UpdateDependencies(depInfo.c_str(), verbose)? 0 : 2;
+        return lgd->UpdateDependencies(depInfo.c_str(),
+                                       verbose, color)? 0 : 2;
         }
       return 1;
       }
@@ -3020,21 +3029,6 @@
   //   argv[0] == <cmake-executable>
   //   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;
   int color = cmsysTerminal_Color_Normal;
   bool newline = true;
@@ -3104,16 +3098,11 @@
       {
       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
       {
-      // Color is disabled.  Print without color.
-      fprintf(stdout, "%s%s", args[i].c_str(), newline? "\n" : "");
+      // Color is enabled.  Print with the current color.
+      cmSystemTools::MakefileColorEcho(color, args[i].c_str(),
+                                       newline, enabled);
       }
     }
 

Index: cmLocalUnixMakefileGenerator3.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalUnixMakefileGenerator3.cxx,v
retrieving revision 1.222
retrieving revision 1.223
diff -u -d -r1.222 -r1.223
--- cmLocalUnixMakefileGenerator3.cxx	19 Dec 2007 21:36:29 -0000	1.222
+++ cmLocalUnixMakefileGenerator3.cxx	19 Dec 2007 22:15:41 -0000	1.223
@@ -31,6 +31,7 @@
 #ifdef CMAKE_BUILD_WITH_CMAKE
 # include "cmDependsFortran.h"
 # include "cmDependsJava.h"
+# include <cmsys/Terminal.h>
 #endif
 
 #include <memory> // auto_ptr
@@ -1225,7 +1226,8 @@
 
 //----------------------------------------------------------------------------
 bool cmLocalUnixMakefileGenerator3::UpdateDependencies(const char* tgtInfo,
-                                                       bool verbose)
+                                                       bool verbose,
+                                                       bool color)
 {
   std::string dir = cmSystemTools::GetFilenamePath(tgtInfo);
   std::string internalDependFile = dir + "/depend.internal";
@@ -1242,11 +1244,18 @@
   if(!checker.Check(dependFile.c_str(), internalDependFile.c_str()))
     {
     // The dependencies must be regenerated.
-
-    // TODO: Make this like cmLocalUnixMakefileGenerator3::EchoDepend
     std::string targetName = cmSystemTools::GetFilenameName(dir);
     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);
     }

Index: cmMakefileTargetGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefileTargetGenerator.cxx,v
retrieving revision 1.75
retrieving revision 1.76
diff -u -d -r1.75 -r1.76
--- cmMakefileTargetGenerator.cxx	19 Dec 2007 21:36:29 -0000	1.75
+++ cmMakefileTargetGenerator.cxx	19 Dec 2007 22:15:41 -0000	1.76
@@ -805,7 +805,7 @@
   //   cmake -E cmake_depends <generator>
   //                          <home-src-dir> <start-src-dir>
   //                          <home-out-dir> <start-out-dir>
-  //                          <dep-info>
+  //                          <dep-info> --color=$(COLOR)
   //
   // This gives the dependency scanner enough information to recreate
   // the state of our local generator sufficiently for its needs.
@@ -824,7 +824,8 @@
                           cmLocalGenerator::FULL, cmLocalGenerator::SHELL)
          << " "
          << this->Convert(this->InfoFileNameFull.c_str(),
-                          cmLocalGenerator::FULL, cmLocalGenerator::SHELL);
+                          cmLocalGenerator::FULL, cmLocalGenerator::SHELL)
+         << " --color=$(COLOR)";
   commands.push_back(depCmd.str());
 
   // Make sure all custom command outputs in this target are built.



More information about the Cmake-commits mailing list