[Cmake-commits] CMake branch, next, updated. v2.8.8-2882-ge023ee9

Stephen Kelly steveire at gmail.com
Thu May 17 08:41:17 EDT 2012


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  e023ee9117fd5e90b23bbe0e998ace04577ce5f1 (commit)
       via  28e6a3a291447e01d20c6b44de8b6eb3ab73d4fc (commit)
       via  713ffe650d5babd2dd0604b54a12c27a7cf119d0 (commit)
       via  6f649dc305ff6466f86bb5550cfc618b85ffe8a6 (commit)
       via  e839a0ec481b83199f86407e51e27ac41461b582 (commit)
      from  f9bc31f5fa499b6eec254ef88b2711bf848f425d (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=e023ee9117fd5e90b23bbe0e998ace04577ce5f1
commit e023ee9117fd5e90b23bbe0e998ace04577ce5f1
Merge: f9bc31f 28e6a3a
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Thu May 17 08:41:14 2012 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Thu May 17 08:41:14 2012 -0400

    Merge topic 'Ninja-EXPORT_COMPILE_COMMANDS' into next
    
    28e6a3a Make the CMAKE_EXPORT_COMPILE_COMMANDS option work with Ninja.
    713ffe6 Add newline to the output.
    6f649dc Move the EscapeJSON method to a sharable location.
    e839a0e CMake Nightly Date Stamp


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=28e6a3a291447e01d20c6b44de8b6eb3ab73d4fc
commit 28e6a3a291447e01d20c6b44de8b6eb3ab73d4fc
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Wed May 9 23:47:37 2012 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Thu May 17 14:40:29 2012 +0200

    Make the CMAKE_EXPORT_COMPILE_COMMANDS option work with Ninja.

diff --git a/Modules/CMakeGenericSystem.cmake b/Modules/CMakeGenericSystem.cmake
index ee8040e..78ce6f0 100644
--- a/Modules/CMakeGenericSystem.cmake
+++ b/Modules/CMakeGenericSystem.cmake
@@ -60,6 +60,12 @@ IF(CMAKE_GENERATOR MATCHES "Makefiles")
   ENDIF(CMAKE_GENERATOR MATCHES "Unix Makefiles")
 ENDIF(CMAKE_GENERATOR MATCHES "Makefiles")
 
+IF(CMAKE_GENERATOR MATCHES "Ninja")
+  SET(CMAKE_EXPORT_COMPILE_COMMANDS OFF CACHE BOOL
+    "Enable/Disable output of compile commands during generation."
+    )
+  MARK_AS_ADVANCED(CMAKE_EXPORT_COMPILE_COMMANDS)
+ENDIF(CMAKE_GENERATOR MATCHES "Ninja")
 
 # GetDefaultWindowsPrefixBase
 #
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index 5f52e1d..a24bc08 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -341,6 +341,7 @@ cmGlobalNinjaGenerator::cmGlobalNinjaGenerator()
   : cmGlobalGenerator()
   , BuildFileStream(0)
   , RulesFileStream(0)
+  , CompileCommandsStream(0)
   , Rules()
   , AllDependencies()
 {
@@ -390,6 +391,7 @@ void cmGlobalNinjaGenerator::Generate()
     this->BuildFileStream->setstate(std::ios_base::failbit);
   }
 
+  this->CloseCompileCommandsStream();
   this->CloseRulesFileStream();
   this->CloseBuildFileStream();
 }
@@ -623,6 +625,46 @@ void cmGlobalNinjaGenerator::CloseRulesFileStream()
    }
 }
 
+void cmGlobalNinjaGenerator::AddCXXCompileCommand(
+                                      const std::string &commandLine,
+                                      const std::string &sourceFile)
+{
+  // Compute Ninja's build file path.
+  std::string buildFileDir =
+    this->GetCMakeInstance()->GetHomeOutputDirectory();
+  if (!this->CompileCommandsStream)
+    {
+    std::string buildFilePath = buildFileDir + "/compile_commands.json";
+
+    // Get a stream where to generate things.
+    this->CompileCommandsStream =
+      new cmGeneratedFileStream(buildFilePath.c_str());
+    *this->CompileCommandsStream << "[";
+    } else {
+    *this->CompileCommandsStream << "," << std::endl;
+    }
+
+  *this->CompileCommandsStream << "\n{\n"
+     << "  \"directory\": \""
+     << cmGlobalGenerator::EscapeJSON(buildFileDir) << "\",\n"
+     << "  \"command\": \""
+     << cmGlobalGenerator::EscapeJSON(commandLine) << "\",\n"
+     << "  \"file\": \""
+     << cmGlobalGenerator::EscapeJSON(sourceFile) << "\"\n"
+     << "}";
+}
+
+void cmGlobalNinjaGenerator::CloseCompileCommandsStream()
+{
+  if (this->CompileCommandsStream)
+    {
+    *this->CompileCommandsStream << "\n]";
+    delete this->CompileCommandsStream;
+    this->CompileCommandsStream = 0;
+    }
+
+}
+
 void cmGlobalNinjaGenerator::WriteDisclaimer(std::ostream& os)
 {
   os
diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h
index 3217581..7afef91 100644
--- a/Source/cmGlobalNinjaGenerator.h
+++ b/Source/cmGlobalNinjaGenerator.h
@@ -213,6 +213,9 @@ public:
   cmGeneratedFileStream* GetRulesFileStream() const
   { return this->RulesFileStream; }
 
+  void AddCXXCompileCommand(const std::string &commandLine,
+                            const std::string &sourceFile);
+
   /**
    * Add a rule to the generated build system.
    * Call WriteRule() behind the scene but perform some check before like:
@@ -254,6 +257,8 @@ private:
   void OpenBuildFileStream();
   void CloseBuildFileStream();
 
+  void CloseCompileCommandsStream();
+
   void OpenRulesFileStream();
   void CloseRulesFileStream();
 
@@ -309,6 +314,7 @@ private:
   /// The file containing the rule statements. (The action attached to each
   /// edge of the compilation DAG).
   cmGeneratedFileStream* RulesFileStream;
+  cmGeneratedFileStream* CompileCommandsStream;
 
   /// The type used to store the set of rules added to the generated build
   /// system.
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index 80007f1..7c58154 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -487,6 +487,36 @@ cmNinjaTargetGenerator
   vars["TARGET_PDB"] = this->GetLocalGenerator()->ConvertToOutputFormat(
     this->GetTargetPDB().c_str(), cmLocalGenerator::SHELL);
 
+  if(this->Makefile->IsOn("CMAKE_EXPORT_COMPILE_COMMANDS"))
+    {
+    cmLocalGenerator::RuleVariables compileObjectVars;
+    std::string lang = language;
+    compileObjectVars.Language = lang.c_str();
+    compileObjectVars.Source = sourceFileName.c_str();
+    compileObjectVars.Object = objectFileName.c_str();
+    compileObjectVars.Flags = vars["FLAGS"].c_str();
+    compileObjectVars.Defines = vars["DEFINES"].c_str();
+
+    // Rule for compiling object file.
+    std::string compileCmdVar = "CMAKE_";
+    compileCmdVar += language;
+    compileCmdVar += "_COMPILE_OBJECT";
+    std::string compileCmd =
+      this->GetMakefile()->GetRequiredDefinition(compileCmdVar.c_str());
+    std::vector<std::string> compileCmds;
+    cmSystemTools::ExpandListArgument(compileCmd, compileCmds);
+
+    for (std::vector<std::string>::iterator i = compileCmds.begin();
+        i != compileCmds.end(); ++i)
+      this->GetLocalGenerator()->ExpandRuleVariables(*i, compileObjectVars);
+
+    std::string cmdLine =
+      this->GetLocalGenerator()->BuildCommandLine(compileCmds);
+
+    this->GetGlobalGenerator()->AddCXXCompileCommand(cmdLine,
+                                                     sourceFileName);
+    }
+
   cmGlobalNinjaGenerator::WriteBuild(this->GetBuildFileStream(),
                                      comment,
                                      rule,
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index c0b7cd6..78ff82c 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -47,7 +47,7 @@ CONFIGURE_FILE(${CMake_SOURCE_DIR}/Tests/EnforceConfig.cmake.in
 
 # Testing
 IF(BUILD_TESTING)
-  IF("${CMAKE_TEST_GENERATOR}" MATCHES "Unix Makefiles")
+  IF("${CMAKE_TEST_GENERATOR}" MATCHES "Unix Makefiles" OR "${CMAKE_TEST_GENERATOR}" MATCHES Ninja)
     SET(TEST_CompileCommandOutput 1)
   ENDIF()
 

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=713ffe650d5babd2dd0604b54a12c27a7cf119d0
commit 713ffe650d5babd2dd0604b54a12c27a7cf119d0
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Wed May 9 22:55:51 2012 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Thu May 17 14:40:04 2012 +0200

    Add newline to the output.

diff --git a/Tests/CMakeLib/run_compile_commands.cxx b/Tests/CMakeLib/run_compile_commands.cxx
index 3f141c5..434cbee 100644
--- a/Tests/CMakeLib/run_compile_commands.cxx
+++ b/Tests/CMakeLib/run_compile_commands.cxx
@@ -35,7 +35,7 @@ private:
   void ParseTranslationUnits()
   {
     this->TranslationUnits = TranslationUnitsType();
-    ExpectOrDie('[', "at start of compile command file");
+    ExpectOrDie('[', "at start of compile command file\n");
     do
       {
       ParseTranslationUnit();

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6f649dc305ff6466f86bb5550cfc618b85ffe8a6
commit 6f649dc305ff6466f86bb5550cfc618b85ffe8a6
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun May 6 15:07:19 2012 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Thu May 17 14:40:04 2012 +0200

    Move the EscapeJSON method to a sharable location.

diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index b06cdb4..f883041 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -2474,3 +2474,16 @@ void cmGlobalGenerator::WriteSummary(cmTarget* target)
     cmSystemTools::RemoveFile(file.c_str());
     }
 }
+
+//----------------------------------------------------------------------------
+// static
+std::string cmGlobalGenerator::EscapeJSON(const std::string& s) {
+  std::string result;
+  for (std::string::size_type i = 0; i < s.size(); ++i) {
+    if (s[i] == '"' || s[i] == '\\') {
+      result += '\\';
+    }
+    result += s[i];
+  }
+  return result;
+}
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index 5254b89..8535edc 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -280,6 +280,8 @@ public:
   /** Generate an <output>.rule file path for a given command output.  */
   virtual std::string GenerateRuleFile(std::string const& output) const;
 
+  static std::string EscapeJSON(const std::string& s);
+
 protected:
   typedef std::vector<cmLocalGenerator*> GeneratorVector;
   // for a project collect all its targets by following depend
diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx
index e63de9c..ebd8219 100644
--- a/Source/cmGlobalUnixMakefileGenerator3.cxx
+++ b/Source/cmGlobalUnixMakefileGenerator3.cxx
@@ -103,18 +103,6 @@ cmGlobalUnixMakefileGenerator3
     }
 }
 
-//----------------------------------------------------------------------------
-std::string EscapeJSON(const std::string& s) {
-  std::string result;
-  for (std::string::size_type i = 0; i < s.size(); ++i) {
-    if (s[i] == '"' || s[i] == '\\') {
-      result += '\\';
-    }
-    result += s[i];
-  }
-  return result;
-}
-
 void cmGlobalUnixMakefileGenerator3::Generate()
 {
   // first do superclass method
@@ -179,11 +167,14 @@ void cmGlobalUnixMakefileGenerator3::AddCXXCompileCommand(
     *this->CommandDatabase << "," << std::endl;
     }
   *this->CommandDatabase << "{" << std::endl
-      << "  \"directory\": \"" << EscapeJSON(workingDirectory) << "\","
+      << "  \"directory\": \""
+      << cmGlobalGenerator::EscapeJSON(workingDirectory) << "\","
       << std::endl
-      << "  \"command\": \"" << EscapeJSON(compileCommand) << "\","
+      << "  \"command\": \"" <<
+      cmGlobalGenerator::EscapeJSON(compileCommand) << "\","
       << std::endl
-      << "  \"file\": \"" << EscapeJSON(sourceFile) << "\""
+      << "  \"file\": \"" <<
+      cmGlobalGenerator::EscapeJSON(sourceFile) << "\""
       << std::endl << "}";
 }
 

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e839a0ec481b83199f86407e51e27ac41461b582
commit e839a0ec481b83199f86407e51e27ac41461b582
Author:     Kitware Robot <kwrobot at kitware.com>
AuthorDate: Thu May 17 00:01:03 2012 -0400
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Thu May 17 14:40:04 2012 +0200

    CMake Nightly Date Stamp

diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index a8c6e04..bb1005c 100644
--- a/Source/CMakeVersion.cmake
+++ b/Source/CMakeVersion.cmake
@@ -2,5 +2,5 @@
 SET(CMake_VERSION_MAJOR 2)
 SET(CMake_VERSION_MINOR 8)
 SET(CMake_VERSION_PATCH 8)
-SET(CMake_VERSION_TWEAK 20120516)
+SET(CMake_VERSION_TWEAK 20120517)
 #SET(CMake_VERSION_RC 1)

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

Summary of changes:
 Modules/CMakeGenericSystem.cmake          |    6 ++++
 Source/CMakeVersion.cmake                 |    2 +-
 Source/cmGlobalGenerator.cxx              |   13 +++++++++
 Source/cmGlobalGenerator.h                |    2 +
 Source/cmGlobalNinjaGenerator.cxx         |   42 +++++++++++++++++++++++++++++
 Source/cmGlobalNinjaGenerator.h           |    6 ++++
 Source/cmGlobalUnixMakefileGenerator3.cxx |   21 ++++----------
 Source/cmNinjaTargetGenerator.cxx         |   30 ++++++++++++++++++++
 Tests/CMakeLib/run_compile_commands.cxx   |    2 +-
 Tests/CMakeLists.txt                      |    2 +-
 10 files changed, 108 insertions(+), 18 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list