[Cmake-commits] CMake branch, next, updated. v3.3.0-1407-g1915a0d
Brad King
brad.king at kitware.com
Mon Jul 27 10:08:36 EDT 2015
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 1915a0d7a0dfa4af4c874714413a4c9a28bd2936 (commit)
via cd530df88ff17a3b150ab62b930fab0da2df8605 (commit)
from ff266fda8d3a7e1b138b7081ffc48e5a5b3758c2 (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=1915a0d7a0dfa4af4c874714413a4c9a28bd2936
commit 1915a0d7a0dfa4af4c874714413a4c9a28bd2936
Merge: ff266fd cd530df
Author: Brad King <brad.king at kitware.com>
AuthorDate: Mon Jul 27 10:08:36 2015 -0400
Commit: CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Mon Jul 27 10:08:36 2015 -0400
Merge topic 'refactor-ninja-command-exporter' into next
cd530df8 cmNinjaTargetGenerator: Factor out compile command exporter
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=cd530df88ff17a3b150ab62b930fab0da2df8605
commit cd530df88ff17a3b150ab62b930fab0da2df8605
Author: Brad King <brad.king at kitware.com>
AuthorDate: Wed Jul 15 14:16:11 2015 -0400
Commit: Brad King <brad.king at kitware.com>
CommitDate: Mon Jul 27 09:54:07 2015 -0400
cmNinjaTargetGenerator: Factor out compile command exporter
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index 74f262c..4bc6b98 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -546,22 +546,39 @@ cmNinjaTargetGenerator
::WriteObjectBuildStatement(
cmSourceFile const* source, bool writeOrderDependsTargetForTarget)
{
+ std::string const language = source->GetLanguage();
+ std::string const sourceFileName =
+ language=="RC" ? source->GetFullPath() : this->GetSourceFilePath(source);
+ std::string const objectDir = this->Target->GetSupportDirectory();
+ std::string const objectFileName = this->GetObjectFilePath(source);
+ std::string const objectFileDir =
+ cmSystemTools::GetFilenamePath(objectFileName);
+
+ cmNinjaVars vars;
+ vars["FLAGS"] = this->ComputeFlagsForObject(source, language);
+ vars["DEFINES"] = this->ComputeDefines(source, language);
+ vars["INCLUDES"] = this->GetIncludes(language);
+ if (!this->NeedDepTypeMSVC(language))
+ {
+ vars["DEP_FILE"] =
+ cmGlobalNinjaGenerator::EncodeDepfileSpace(objectFileName + ".d");
+ }
+
+ this->ExportObjectCompileCommand(
+ language, sourceFileName,
+ objectDir, objectFileName, objectFileDir,
+ vars["FLAGS"], vars["DEFINES"], vars["INCLUDES"]
+ );
+
std::string comment;
- const std::string language = source->GetLanguage();
std::string rule = this->LanguageCompilerRule(language);
cmNinjaDeps outputs;
- std::string objectFileName = this->GetObjectFilePath(source);
outputs.push_back(objectFileName);
// Add this object to the list of object files.
this->Objects.push_back(objectFileName);
cmNinjaDeps explicitDeps;
- std::string sourceFileName;
- if (language == "RC")
- sourceFileName = source->GetFullPath();
- else
- sourceFileName = this->GetSourceFilePath(source);
explicitDeps.push_back(sourceFileName);
cmNinjaDeps implicitDeps;
@@ -596,21 +613,11 @@ cmNinjaTargetGenerator
orderOnlyDeps);
}
- cmNinjaVars vars;
- vars["FLAGS"] = this->ComputeFlagsForObject(source, language);
- vars["DEFINES"] = this->ComputeDefines(source, language);
- vars["INCLUDES"] = this->GetIncludes(language);
- if (!this->NeedDepTypeMSVC(language)) {
- vars["DEP_FILE"] =
- cmGlobalNinjaGenerator::EncodeDepfileSpace(objectFileName + ".d");
- }
EnsureParentDirectoryExists(objectFileName);
- std::string objectDir = this->Target->GetSupportDirectory();
vars["OBJECT_DIR"] = this->GetLocalGenerator()->ConvertToOutputFormat(
ConvertToNinjaPath(objectDir),
cmLocalGenerator::SHELL);
- std::string objectFileDir = cmSystemTools::GetFilenamePath(objectFileName);
vars["OBJECT_FILE_DIR"] = this->GetLocalGenerator()->ConvertToOutputFormat(
ConvertToNinjaPath(objectFileDir),
cmLocalGenerator::SHELL);
@@ -619,54 +626,6 @@ cmNinjaTargetGenerator
this->SetMsvcTargetPdbVariable(vars);
- if(this->Makefile->IsOn("CMAKE_EXPORT_COMPILE_COMMANDS"))
- {
- cmLocalGenerator::RuleVariables compileObjectVars;
- std::string lang = language;
- compileObjectVars.Language = lang.c_str();
-
- std::string escapedSourceFileName = sourceFileName;
-
- if (!cmSystemTools::FileIsFullPath(sourceFileName.c_str()))
- {
- escapedSourceFileName = cmSystemTools::CollapseFullPath(
- escapedSourceFileName,
- this->GetGlobalGenerator()->GetCMakeInstance()->
- GetHomeOutputDirectory());
- }
-
- escapedSourceFileName =
- this->LocalGenerator->ConvertToOutputFormat(
- escapedSourceFileName, cmLocalGenerator::SHELL);
-
- compileObjectVars.Source = escapedSourceFileName.c_str();
- compileObjectVars.Object = objectFileName.c_str();
- compileObjectVars.ObjectDir = objectDir.c_str();
- compileObjectVars.ObjectFileDir = objectFileDir.c_str();
- compileObjectVars.Flags = vars["FLAGS"].c_str();
- compileObjectVars.Defines = vars["DEFINES"].c_str();
- compileObjectVars.Includes = vars["INCLUDES"].c_str();
-
- // Rule for compiling object file.
- std::string compileCmdVar = "CMAKE_";
- compileCmdVar += language;
- compileCmdVar += "_COMPILE_OBJECT";
- std::string compileCmd =
- this->GetMakefile()->GetRequiredDefinition(compileCmdVar);
- 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);
- }
-
this->GetGlobalGenerator()->WriteBuild(this->GetBuildFileStream(),
comment,
rule,
@@ -690,6 +649,69 @@ cmNinjaTargetGenerator
void
cmNinjaTargetGenerator
+::ExportObjectCompileCommand(
+ std::string const& language,
+ std::string const& sourceFileName,
+ std::string const& objectDir,
+ std::string const& objectFileName,
+ std::string const& objectFileDir,
+ std::string const& flags,
+ std::string const& defines,
+ std::string const& includes
+ )
+{
+ if(!this->Makefile->IsOn("CMAKE_EXPORT_COMPILE_COMMANDS"))
+ {
+ return;
+ }
+
+ cmLocalGenerator::RuleVariables compileObjectVars;
+ compileObjectVars.Language = language.c_str();
+
+ std::string escapedSourceFileName = sourceFileName;
+
+ if (!cmSystemTools::FileIsFullPath(sourceFileName.c_str()))
+ {
+ escapedSourceFileName = cmSystemTools::CollapseFullPath(
+ escapedSourceFileName,
+ this->GetGlobalGenerator()->GetCMakeInstance()->
+ GetHomeOutputDirectory());
+ }
+
+ escapedSourceFileName =
+ this->LocalGenerator->ConvertToOutputFormat(
+ escapedSourceFileName, cmLocalGenerator::SHELL);
+
+ compileObjectVars.Source = escapedSourceFileName.c_str();
+ compileObjectVars.Object = objectFileName.c_str();
+ compileObjectVars.ObjectDir = objectDir.c_str();
+ compileObjectVars.ObjectFileDir = objectFileDir.c_str();
+ compileObjectVars.Flags = flags.c_str();
+ compileObjectVars.Defines = defines.c_str();
+ compileObjectVars.Includes = includes.c_str();
+
+ // Rule for compiling object file.
+ std::string compileCmdVar = "CMAKE_";
+ compileCmdVar += language;
+ compileCmdVar += "_COMPILE_OBJECT";
+ std::string compileCmd =
+ this->GetMakefile()->GetRequiredDefinition(compileCmdVar);
+ 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);
+}
+
+void
+cmNinjaTargetGenerator
::EnsureDirectoryExists(const std::string& path) const
{
if (cmSystemTools::FileIsFullPath(path.c_str()))
diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h
index 8912431..a10ceba 100644
--- a/Source/cmNinjaTargetGenerator.h
+++ b/Source/cmNinjaTargetGenerator.h
@@ -114,6 +114,17 @@ protected:
void WriteObjectBuildStatement(cmSourceFile const* source,
bool writeOrderDependsTargetForTarget);
+ void ExportObjectCompileCommand(
+ std::string const& language,
+ std::string const& sourceFileName,
+ std::string const& objectDir,
+ std::string const& objectFileName,
+ std::string const& objectFileDir,
+ std::string const& flags,
+ std::string const& defines,
+ std::string const& includes
+ );
+
cmNinjaDeps GetObjects() const
{ return this->Objects; }
-----------------------------------------------------------------------
Summary of changes:
Source/cmNinjaTargetGenerator.cxx | 152 +++++++++++++++++++++----------------
Source/cmNinjaTargetGenerator.h | 11 +++
2 files changed, 98 insertions(+), 65 deletions(-)
hooks/post-receive
--
CMake
More information about the Cmake-commits
mailing list