Merge topic 'ninja-target-pdb-cleanup'
709fa59 Ninja: remove GetTargetPDB because it is used only once 4bb4787 Ninja:split out setting of msvc TARGET_PDB 59cbc28 Ninja: prepare msvc pdb cleanup
This commit is contained in:
commit
ed01420c23
@ -459,25 +459,16 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string path;
|
|
||||||
if (!this->TargetNameImport.empty()) {
|
if (!this->TargetNameImport.empty()) {
|
||||||
path = this->GetLocalGenerator()->ConvertToOutputFormat(
|
const std::string impLibPath = this->GetLocalGenerator()
|
||||||
targetOutputImplib.c_str(), cmLocalGenerator::SHELL);
|
->ConvertToOutputFormat(targetOutputImplib.c_str(),
|
||||||
vars["TARGET_IMPLIB"] = path;
|
cmLocalGenerator::SHELL);
|
||||||
EnsureParentDirectoryExists(path);
|
vars["TARGET_IMPLIB"] = impLibPath;
|
||||||
|
EnsureParentDirectoryExists(impLibPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
cmMakefile* mf = this->GetMakefile();
|
cmMakefile* mf = this->GetMakefile();
|
||||||
if (mf->GetDefinition("MSVC_C_ARCHITECTURE_ID") ||
|
if (!this->SetMsvcTargetPdbVariable(vars))
|
||||||
mf->GetDefinition("MSVC_CXX_ARCHITECTURE_ID"))
|
|
||||||
{
|
|
||||||
path = this->GetTargetPDB();
|
|
||||||
vars["TARGET_PDB"] = this->GetLocalGenerator()->ConvertToOutputFormat(
|
|
||||||
ConvertToNinjaPath(path.c_str()).c_str(),
|
|
||||||
cmLocalGenerator::SHELL);
|
|
||||||
EnsureParentDirectoryExists(path);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
// It is common to place debug symbols at a specific place,
|
// It is common to place debug symbols at a specific place,
|
||||||
// so we need a plain target name in the rule available.
|
// so we need a plain target name in the rule available.
|
||||||
@ -494,9 +485,9 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
|
|||||||
|
|
||||||
if (mf->IsOn("CMAKE_COMPILER_IS_MINGW"))
|
if (mf->IsOn("CMAKE_COMPILER_IS_MINGW"))
|
||||||
{
|
{
|
||||||
path = GetTarget()->GetSupportDirectory();
|
const std::string objPath = GetTarget()->GetSupportDirectory();
|
||||||
vars["OBJECT_DIR"] = ConvertToNinjaPath(path.c_str());
|
vars["OBJECT_DIR"] = ConvertToNinjaPath(objPath.c_str());
|
||||||
EnsureDirectoryExists(path);
|
EnsureDirectoryExists(objPath);
|
||||||
// ar.exe can't handle backslashes in rsp files (implictly used by gcc)
|
// ar.exe can't handle backslashes in rsp files (implictly used by gcc)
|
||||||
std::string& linkLibraries = vars["LINK_LIBRARIES"];
|
std::string& linkLibraries = vars["LINK_LIBRARIES"];
|
||||||
std::replace(linkLibraries.begin(), linkLibraries.end(), '\\', '/');
|
std::replace(linkLibraries.begin(), linkLibraries.end(), '\\', '/');
|
||||||
@ -527,10 +518,10 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
|
|||||||
// If we have any PRE_LINK commands, we need to go back to HOME_OUTPUT for
|
// If we have any PRE_LINK commands, we need to go back to HOME_OUTPUT for
|
||||||
// the link commands.
|
// the link commands.
|
||||||
if (!preLinkCmdLines.empty()) {
|
if (!preLinkCmdLines.empty()) {
|
||||||
path = this->GetLocalGenerator()->ConvertToOutputFormat(
|
const std::string homeOutDir = this->GetLocalGenerator()
|
||||||
this->GetMakefile()->GetHomeOutputDirectory(),
|
->ConvertToOutputFormat(this->GetMakefile()->GetHomeOutputDirectory(),
|
||||||
cmLocalGenerator::SHELL);
|
cmLocalGenerator::SHELL);
|
||||||
preLinkCmdLines.push_back("cd " + path);
|
preLinkCmdLines.push_back("cd " + homeOutDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
vars["PRE_LINK"] =
|
vars["PRE_LINK"] =
|
||||||
|
@ -292,23 +292,33 @@ std::string cmNinjaTargetGenerator::GetTargetName() const
|
|||||||
return this->Target->GetName();
|
return this->Target->GetName();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string cmNinjaTargetGenerator::GetTargetPDB() const
|
|
||||||
|
bool cmNinjaTargetGenerator::SetMsvcTargetPdbVariable(cmNinjaVars& vars) const
|
||||||
{
|
{
|
||||||
std::string targetFullPathPDB;
|
cmMakefile* mf = this->GetMakefile();
|
||||||
if(this->Target->GetType() == cmTarget::EXECUTABLE ||
|
if (mf->GetDefinition("MSVC_C_ARCHITECTURE_ID") ||
|
||||||
this->Target->GetType() == cmTarget::STATIC_LIBRARY ||
|
mf->GetDefinition("MSVC_CXX_ARCHITECTURE_ID"))
|
||||||
this->Target->GetType() == cmTarget::SHARED_LIBRARY ||
|
|
||||||
this->Target->GetType() == cmTarget::MODULE_LIBRARY)
|
|
||||||
{
|
{
|
||||||
targetFullPathPDB = this->Target->GetDirectory(this->GetConfigName());
|
std::string pdbPath;
|
||||||
targetFullPathPDB += "/";
|
if(this->Target->GetType() == cmTarget::EXECUTABLE ||
|
||||||
targetFullPathPDB += this->Target->GetPDBName(this->GetConfigName());
|
this->Target->GetType() == cmTarget::STATIC_LIBRARY ||
|
||||||
|
this->Target->GetType() == cmTarget::SHARED_LIBRARY ||
|
||||||
|
this->Target->GetType() == cmTarget::MODULE_LIBRARY)
|
||||||
|
{
|
||||||
|
pdbPath = this->Target->GetDirectory(this->GetConfigName());
|
||||||
|
pdbPath += "/";
|
||||||
|
pdbPath += this->Target->GetPDBName(this->GetConfigName());
|
||||||
}
|
}
|
||||||
|
|
||||||
return targetFullPathPDB.c_str();
|
vars["TARGET_PDB"] = this->GetLocalGenerator()->ConvertToOutputFormat(
|
||||||
|
ConvertToNinjaPath(pdbPath.c_str()).c_str(),
|
||||||
|
cmLocalGenerator::SHELL);
|
||||||
|
EnsureParentDirectoryExists(pdbPath);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
cmNinjaTargetGenerator
|
cmNinjaTargetGenerator
|
||||||
::WriteLanguageRules(const std::string& language)
|
::WriteLanguageRules(const std::string& language)
|
||||||
@ -534,15 +544,7 @@ cmNinjaTargetGenerator
|
|||||||
vars["DEP_FILE"] = objectFileName + ".d";;
|
vars["DEP_FILE"] = objectFileName + ".d";;
|
||||||
EnsureParentDirectoryExists(objectFileName);
|
EnsureParentDirectoryExists(objectFileName);
|
||||||
|
|
||||||
// TODO move to GetTargetPDB
|
this->SetMsvcTargetPdbVariable(vars);
|
||||||
cmMakefile* mf = this->GetMakefile();
|
|
||||||
if (mf->GetDefinition("MSVC_C_ARCHITECTURE_ID") ||
|
|
||||||
mf->GetDefinition("MSVC_CXX_ARCHITECTURE_ID"))
|
|
||||||
{
|
|
||||||
vars["TARGET_PDB"] = this->GetLocalGenerator()->ConvertToOutputFormat(
|
|
||||||
ConvertToNinjaPath(GetTargetPDB().c_str()).c_str(),
|
|
||||||
cmLocalGenerator::SHELL);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(this->Makefile->IsOn("CMAKE_EXPORT_COMPILE_COMMANDS"))
|
if(this->Makefile->IsOn("CMAKE_EXPORT_COMPILE_COMMANDS"))
|
||||||
{
|
{
|
||||||
@ -638,14 +640,14 @@ cmNinjaTargetGenerator
|
|||||||
|
|
||||||
void
|
void
|
||||||
cmNinjaTargetGenerator
|
cmNinjaTargetGenerator
|
||||||
::EnsureDirectoryExists(const std::string& dir)
|
::EnsureDirectoryExists(const std::string& dir) const
|
||||||
{
|
{
|
||||||
cmSystemTools::MakeDirectory(dir.c_str());
|
cmSystemTools::MakeDirectory(dir.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cmNinjaTargetGenerator
|
cmNinjaTargetGenerator
|
||||||
::EnsureParentDirectoryExists(const std::string& path)
|
::EnsureParentDirectoryExists(const std::string& path) const
|
||||||
{
|
{
|
||||||
EnsureDirectoryExists(cmSystemTools::GetParentDirectory(path.c_str()));
|
EnsureDirectoryExists(cmSystemTools::GetParentDirectory(path.c_str()));
|
||||||
}
|
}
|
||||||
|
@ -40,10 +40,12 @@ public:
|
|||||||
|
|
||||||
virtual void Generate() = 0;
|
virtual void Generate() = 0;
|
||||||
|
|
||||||
std::string GetTargetPDB() const;
|
|
||||||
std::string GetTargetName() const;
|
std::string GetTargetName() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
bool SetMsvcTargetPdbVariable(cmNinjaVars&) const;
|
||||||
|
|
||||||
cmGeneratedFileStream& GetBuildFileStream() const;
|
cmGeneratedFileStream& GetBuildFileStream() const;
|
||||||
cmGeneratedFileStream& GetRulesFileStream() const;
|
cmGeneratedFileStream& GetRulesFileStream() const;
|
||||||
|
|
||||||
@ -112,8 +114,8 @@ protected:
|
|||||||
// Helper to add flag for windows .def file.
|
// Helper to add flag for windows .def file.
|
||||||
void AddModuleDefinitionFlag(std::string& flags);
|
void AddModuleDefinitionFlag(std::string& flags);
|
||||||
|
|
||||||
void EnsureDirectoryExists(const std::string& dir);
|
void EnsureDirectoryExists(const std::string& dir) const;
|
||||||
void EnsureParentDirectoryExists(const std::string& path);
|
void EnsureParentDirectoryExists(const std::string& path) const;
|
||||||
|
|
||||||
// write rules for Mac OS X Application Bundle content.
|
// write rules for Mac OS X Application Bundle content.
|
||||||
struct MacOSXContentGeneratorType :
|
struct MacOSXContentGeneratorType :
|
||||||
|
Loading…
x
Reference in New Issue
Block a user