[Cmake-commits] CMake branch, next, updated. v2.8.11.2-3302-gadfb168

Robert Maynard robert.maynard at kitware.com
Tue Jul 23 10:30:58 EDT 2013


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  adfb1689bf88067c94b72494fb44f81d2020732c (commit)
       via  11391b75693a5006966217b785b76ff0249709ad (commit)
       via  ffe79b582ffeb05b5db3a5fd6b4450f848f9ffe6 (commit)
      from  e371468d0e0890ab810acb1ddfd176424974a09e (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=adfb1689bf88067c94b72494fb44f81d2020732c
commit adfb1689bf88067c94b72494fb44f81d2020732c
Merge: e371468 11391b7
Author:     Robert Maynard <robert.maynard at kitware.com>
AuthorDate: Tue Jul 23 10:30:56 2013 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Tue Jul 23 10:30:56 2013 -0400

    Merge topic 'ninja_bad_cmcldeps_paths' into next
    
    11391b7 Ninja: Make cmcldeps depfile output more consistent with 'ninja -t msvc'
    ffe79b5 CMake Nightly Date Stamp


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=11391b75693a5006966217b785b76ff0249709ad
commit 11391b75693a5006966217b785b76ff0249709ad
Author:     Reid Kleckner <rnk at google.com>
AuthorDate: Thu May 23 15:13:55 2013 -0400
Commit:     Robert Maynard <robert.maynard at kitware.com>
CommitDate: Tue Jul 23 09:58:12 2013 -0400

    Ninja: Make cmcldeps depfile output more consistent with 'ninja -t msvc'
    
    Ninja relies on the generator to produce paths that match up with the
    paths used in the build.ninja file, which are spelled with backslashes.
    Therefore, cmcldeps should canonicalize depfile paths to use backslashes
    and relativize paths to the build directory.

diff --git a/Source/cmcldeps.cxx b/Source/cmcldeps.cxx
index 262d83b..a0ef6e6 100644
--- a/Source/cmcldeps.cxx
+++ b/Source/cmcldeps.cxx
@@ -62,8 +62,8 @@ static std::string trimLeadingSpace(const std::string& cmdline) {
   return cmdline.substr(i);
 }
 
-static void doEscape(std::string& str, const std::string& search,
-                                       const std::string& repl) {
+static void replaceAll(std::string& str, const std::string& search,
+                                         const std::string& repl) {
   std::string::size_type pos = 0;
   while ((pos = str.find(search, pos)) != std::string::npos) {
     str.replace(pos, search.size(), repl);
@@ -71,6 +71,10 @@ static void doEscape(std::string& str, const std::string& search,
   }
 }
 
+bool startsWith(const std::string& str, const std::string& what) {
+  return str.compare(0, what.size(), what) == 0;
+}
+
 // Strips one argument from the cmdline and returns it. "surrounding quotes"
 // are removed from the argument if there were any.
 static std::string getArg(std::string& cmdline) {
@@ -117,6 +121,13 @@ static void parseCommandLine(LPTSTR wincmdline,
   rest = trimLeadingSpace(cmdline);
 }
 
+// Not all backslashes need to be escaped in a depfile, but it's easier that
+// way.  See the re2c grammar in ninja's source code for more info.
+static void escapePath(std::string &path) {
+  replaceAll(path, "\\", "\\\\");
+  replaceAll(path, " ", "\\ ");
+}
+
 static void outputDepFile(const std::string& dfile, const std::string& objfile,
         std::vector<std::string>& incs) {
 
@@ -132,16 +143,24 @@ static void outputDepFile(const std::string& dfile, const std::string& objfile,
   // FIXME should this be fatal or not? delete obj? delete d?
   if (!out)
     return;
+  std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
+  replaceAll(cwd, "/", "\\");
+  cwd.push_back('\\');
 
   std::string tmp = objfile;
-  doEscape(tmp, " ", "\\ ");
+  escapePath(tmp);
   fprintf(out, "%s: \\\n", tmp.c_str());
 
   std::vector<std::string>::iterator it = incs.begin();
   for (; it != incs.end(); ++it) {
     tmp = *it;
-    doEscape(tmp, "\\", "/");
-    doEscape(tmp, " ", "\\ ");
+    // The paths need to match the ones used to identify build artifacts in the
+    // build.ninja file.  Therefore we need to canonicalize the path to use
+    // backward slashes and relativize the path to the build directory.
+    replaceAll(tmp, "/", "\\");
+    if (startsWith(tmp, cwd))
+      tmp = tmp.substr(cwd.size());
+    escapePath(tmp);
     fprintf(out, "%s \\\n", tmp.c_str());
   }
 
@@ -150,10 +169,6 @@ static void outputDepFile(const std::string& dfile, const std::string& objfile,
 }
 
 
-bool startsWith(const std::string& str, const std::string& what) {
-  return str.compare(0, what.size(), what) == 0;
-}
-
 bool contains(const std::string& str, const std::string& what) {
   return str.find(what) != std::string::npos;
 }

-----------------------------------------------------------------------

Summary of changes:
 Source/CMakeVersion.cmake |    2 +-
 Source/cmcldeps.cxx       |   33 ++++++++++++++++++++++++---------
 2 files changed, 25 insertions(+), 10 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list