cmNinjaTargetGenerator: add a method to compute the object directory

This commit is contained in:
Ben Boeckel
2023-12-26 14:45:37 -05:00
parent 159872ab8b
commit 4a9613ff9b
2 changed files with 14 additions and 15 deletions

View File

@@ -411,28 +411,29 @@ std::string cmNinjaTargetGenerator::GetCompiledSourceNinjaPath(
return this->ConvertToNinjaAbsPath(source->GetFullPath()); return this->ConvertToNinjaAbsPath(source->GetFullPath());
} }
std::string cmNinjaTargetGenerator::GetObjectFilePath( std::string cmNinjaTargetGenerator::GetObjectFileDir(
cmSourceFile const* source, const std::string& config) const const std::string& config) const
{ {
std::string path = this->LocalGenerator->GetHomeRelativeOutputPath(); std::string path = this->LocalGenerator->GetHomeRelativeOutputPath();
if (!path.empty()) { if (!path.empty()) {
path += '/'; path += '/';
} }
std::string const& objectName = this->GeneratorTarget->GetObjectName(source); path +=
path += cmStrCat( cmStrCat(this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget),
this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget), this->GetGlobalGenerator()->ConfigDirectory(config));
this->GetGlobalGenerator()->ConfigDirectory(config), '/', objectName);
return path; return path;
} }
std::string cmNinjaTargetGenerator::GetObjectFilePath(
cmSourceFile const* source, const std::string& config) const
{
std::string const& objectName = this->GeneratorTarget->GetObjectName(source);
return cmStrCat(this->GetObjectFileDir(config), '/', objectName);
}
std::string cmNinjaTargetGenerator::GetBmiFilePath( std::string cmNinjaTargetGenerator::GetBmiFilePath(
cmSourceFile const* source, const std::string& config) const cmSourceFile const* source, const std::string& config) const
{ {
std::string path = this->LocalGenerator->GetHomeRelativeOutputPath();
if (!path.empty()) {
path += '/';
}
auto& importedConfigInfo = this->Configs.at(config).ImportedCxxModules; auto& importedConfigInfo = this->Configs.at(config).ImportedCxxModules;
if (!importedConfigInfo.Initialized()) { if (!importedConfigInfo.Initialized()) {
std::string configUpper = cmSystemTools::UpperCase(config); std::string configUpper = cmSystemTools::UpperCase(config);
@@ -444,10 +445,7 @@ std::string cmNinjaTargetGenerator::GetBmiFilePath(
std::string bmiName = std::string bmiName =
importedConfigInfo.BmiNameForSource(source->GetFullPath()); importedConfigInfo.BmiNameForSource(source->GetFullPath());
path += cmStrCat( return cmStrCat(this->GetObjectFileDir(config), '/', bmiName);
this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget),
this->GetGlobalGenerator()->ConfigDirectory(config), '/', bmiName);
return path;
} }
std::string cmNinjaTargetGenerator::GetClangTidyReplacementsFilePath( std::string cmNinjaTargetGenerator::GetClangTidyReplacementsFilePath(

View File

@@ -128,6 +128,7 @@ protected:
/// @return the source file path for the given @a source. /// @return the source file path for the given @a source.
std::string GetCompiledSourceNinjaPath(cmSourceFile const* source) const; std::string GetCompiledSourceNinjaPath(cmSourceFile const* source) const;
std::string GetObjectFileDir(const std::string& config) const;
/// @return the object file path for the given @a source. /// @return the object file path for the given @a source.
std::string GetObjectFilePath(cmSourceFile const* source, std::string GetObjectFilePath(cmSourceFile const* source,
const std::string& config) const; const std::string& config) const;