Merge topic 'Ninja-absolute-compile-commands'
ca403b8
Construct the full path before escaping it.f9383a9
STYLE: Fix line length, remove extra blank linee30d46e
Use full paths in compile_commands.json for out of source builds.
This commit is contained in:
commit
8947f11d07
|
@ -701,13 +701,22 @@ void cmGlobalNinjaGenerator::AddCXXCompileCommand(
|
||||||
*this->CompileCommandsStream << "," << std::endl;
|
*this->CompileCommandsStream << "," << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string sourceFileName = sourceFile;
|
||||||
|
if (!cmSystemTools::FileIsFullPath(sourceFileName.c_str()))
|
||||||
|
{
|
||||||
|
sourceFileName = cmSystemTools::CollapseFullPath(
|
||||||
|
sourceFileName.c_str(),
|
||||||
|
this->GetCMakeInstance()->GetHomeOutputDirectory());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
*this->CompileCommandsStream << "\n{\n"
|
*this->CompileCommandsStream << "\n{\n"
|
||||||
<< " \"directory\": \""
|
<< " \"directory\": \""
|
||||||
<< cmGlobalGenerator::EscapeJSON(buildFileDir) << "\",\n"
|
<< cmGlobalGenerator::EscapeJSON(buildFileDir) << "\",\n"
|
||||||
<< " \"command\": \""
|
<< " \"command\": \""
|
||||||
<< cmGlobalGenerator::EscapeJSON(commandLine) << "\",\n"
|
<< cmGlobalGenerator::EscapeJSON(commandLine) << "\",\n"
|
||||||
<< " \"file\": \""
|
<< " \"file\": \""
|
||||||
<< cmGlobalGenerator::EscapeJSON(sourceFile) << "\"\n"
|
<< cmGlobalGenerator::EscapeJSON(sourceFileName) << "\"\n"
|
||||||
<< "}";
|
<< "}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -534,9 +534,21 @@ cmNinjaTargetGenerator
|
||||||
cmLocalGenerator::RuleVariables compileObjectVars;
|
cmLocalGenerator::RuleVariables compileObjectVars;
|
||||||
std::string lang = language;
|
std::string lang = language;
|
||||||
compileObjectVars.Language = lang.c_str();
|
compileObjectVars.Language = lang.c_str();
|
||||||
std::string escapedSourceFileName =
|
|
||||||
|
std::string escapedSourceFileName = sourceFileName;
|
||||||
|
|
||||||
|
if (!cmSystemTools::FileIsFullPath(sourceFileName.c_str()))
|
||||||
|
{
|
||||||
|
escapedSourceFileName = cmSystemTools::CollapseFullPath(
|
||||||
|
escapedSourceFileName.c_str(),
|
||||||
|
this->GetGlobalGenerator()->GetCMakeInstance()->
|
||||||
|
GetHomeOutputDirectory());
|
||||||
|
}
|
||||||
|
|
||||||
|
escapedSourceFileName =
|
||||||
this->LocalGenerator->ConvertToOutputFormat(
|
this->LocalGenerator->ConvertToOutputFormat(
|
||||||
sourceFileName.c_str(), cmLocalGenerator::SHELL);
|
escapedSourceFileName.c_str(), cmLocalGenerator::SHELL);
|
||||||
|
|
||||||
compileObjectVars.Source = escapedSourceFileName.c_str();
|
compileObjectVars.Source = escapedSourceFileName.c_str();
|
||||||
compileObjectVars.Object = objectFileName.c_str();
|
compileObjectVars.Object = objectFileName.c_str();
|
||||||
compileObjectVars.Flags = vars["FLAGS"].c_str();
|
compileObjectVars.Flags = vars["FLAGS"].c_str();
|
||||||
|
|
Loading…
Reference in New Issue