Convert: Move access to BinaryDirectory out of loops

This commit is contained in:
Stephen Kelly 2016-09-07 23:14:30 +02:00
parent 25c39ac28b
commit 1825f876a7
3 changed files with 21 additions and 39 deletions

View File

@ -239,20 +239,18 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources,
// written by the original local generator for this directory // written by the original local generator for this directory
// convert the dependencies to paths relative to the home output // convert the dependencies to paths relative to the home output
// directory. We must do the same here. // directory. We must do the same here.
std::string obj_i = this->LocalGenerator->ConvertToRelativePath( std::string binDir = this->LocalGenerator->GetBinaryDirectory();
this->LocalGenerator->GetBinaryDirectory(), obj); std::string obj_i = this->LocalGenerator->ConvertToRelativePath(binDir, obj);
std::string obj_m = cmSystemTools::ConvertToOutputPath(obj_i.c_str()); std::string obj_m = cmSystemTools::ConvertToOutputPath(obj_i.c_str());
internalDepends << obj_i << std::endl; internalDepends << obj_i << std::endl;
for (std::set<std::string>::const_iterator i = dependencies.begin(); for (std::set<std::string>::const_iterator i = dependencies.begin();
i != dependencies.end(); ++i) { i != dependencies.end(); ++i) {
makeDepends << obj_m << ": " makeDepends
<< cmSystemTools::ConvertToOutputPath( << obj_m << ": "
this->LocalGenerator << cmSystemTools::ConvertToOutputPath(
->ConvertToRelativePath( this->LocalGenerator->ConvertToRelativePath(binDir, *i).c_str())
this->LocalGenerator->GetBinaryDirectory(), *i) << std::endl;
.c_str())
<< std::endl;
internalDepends << " " << *i << std::endl; internalDepends << " " << *i << std::endl;
} }
makeDepends << std::endl; makeDepends << std::endl;

View File

@ -331,20 +331,18 @@ bool cmDependsFortran::WriteDependenciesReal(const char* obj,
const char* src = info.Source.c_str(); const char* src = info.Source.c_str();
// Write the include dependencies to the output stream. // Write the include dependencies to the output stream.
std::string obj_i = this->LocalGenerator->ConvertToRelativePath( std::string binDir = this->LocalGenerator->GetBinaryDirectory();
this->LocalGenerator->GetBinaryDirectory(), obj); std::string obj_i = this->LocalGenerator->ConvertToRelativePath(binDir, obj);
std::string obj_m = cmSystemTools::ConvertToOutputPath(obj_i.c_str()); std::string obj_m = cmSystemTools::ConvertToOutputPath(obj_i.c_str());
internalDepends << obj_i << std::endl; internalDepends << obj_i << std::endl;
internalDepends << " " << src << std::endl; internalDepends << " " << src << std::endl;
for (std::set<std::string>::const_iterator i = info.Includes.begin(); for (std::set<std::string>::const_iterator i = info.Includes.begin();
i != info.Includes.end(); ++i) { i != info.Includes.end(); ++i) {
makeDepends << obj_m << ": " makeDepends
<< cmSystemTools::ConvertToOutputPath( << obj_m << ": "
this->LocalGenerator << cmSystemTools::ConvertToOutputPath(
->ConvertToRelativePath( this->LocalGenerator->ConvertToRelativePath(binDir, *i).c_str())
this->LocalGenerator->GetBinaryDirectory(), *i) << std::endl;
.c_str())
<< std::endl;
internalDepends << " " << *i << std::endl; internalDepends << " " << *i << std::endl;
} }
makeDepends << std::endl; makeDepends << std::endl;
@ -370,10 +368,7 @@ bool cmDependsFortran::WriteDependenciesReal(const char* obj,
proxy += *i; proxy += *i;
proxy += ".mod.proxy"; proxy += ".mod.proxy";
proxy = cmSystemTools::ConvertToOutputPath( proxy = cmSystemTools::ConvertToOutputPath(
this->LocalGenerator this->LocalGenerator->ConvertToRelativePath(binDir, proxy).c_str());
->ConvertToRelativePath(this->LocalGenerator->GetBinaryDirectory(),
proxy)
.c_str());
// since we require some things add them to our list of requirements // since we require some things add them to our list of requirements
makeDepends << obj_m << ".requires: " << proxy << std::endl; makeDepends << obj_m << ".requires: " << proxy << std::endl;
@ -389,9 +384,7 @@ bool cmDependsFortran::WriteDependenciesReal(const char* obj,
if (!required->second.empty()) { if (!required->second.empty()) {
// This module is known. Depend on its timestamp file. // This module is known. Depend on its timestamp file.
std::string stampFile = cmSystemTools::ConvertToOutputPath( std::string stampFile = cmSystemTools::ConvertToOutputPath(
this->LocalGenerator this->LocalGenerator->ConvertToRelativePath(binDir, required->second)
->ConvertToRelativePath(this->LocalGenerator->GetBinaryDirectory(),
required->second)
.c_str()); .c_str());
makeDepends << obj_m << ": " << stampFile << "\n"; makeDepends << obj_m << ": " << stampFile << "\n";
} else { } else {
@ -400,10 +393,7 @@ bool cmDependsFortran::WriteDependenciesReal(const char* obj,
std::string module; std::string module;
if (this->FindModule(*i, module)) { if (this->FindModule(*i, module)) {
module = cmSystemTools::ConvertToOutputPath( module = cmSystemTools::ConvertToOutputPath(
this->LocalGenerator this->LocalGenerator->ConvertToRelativePath(binDir, module).c_str());
->ConvertToRelativePath(this->LocalGenerator->GetBinaryDirectory(),
module)
.c_str());
makeDepends << obj_m << ": " << module << "\n"; makeDepends << obj_m << ": " << module << "\n";
} }
} }
@ -417,10 +407,7 @@ bool cmDependsFortran::WriteDependenciesReal(const char* obj,
proxy += *i; proxy += *i;
proxy += ".mod.proxy"; proxy += ".mod.proxy";
proxy = cmSystemTools::ConvertToOutputPath( proxy = cmSystemTools::ConvertToOutputPath(
this->LocalGenerator this->LocalGenerator->ConvertToRelativePath(binDir, proxy).c_str());
->ConvertToRelativePath(this->LocalGenerator->GetBinaryDirectory(),
proxy)
.c_str());
makeDepends << proxy << ": " << obj_m << ".provides" << std::endl; makeDepends << proxy << ": " << obj_m << ".provides" << std::endl;
} }
@ -468,10 +455,7 @@ bool cmDependsFortran::WriteDependenciesReal(const char* obj,
std::string driver = this->TargetDirectory; std::string driver = this->TargetDirectory;
driver += "/build"; driver += "/build";
driver = cmSystemTools::ConvertToOutputPath( driver = cmSystemTools::ConvertToOutputPath(
this->LocalGenerator this->LocalGenerator->ConvertToRelativePath(binDir, driver).c_str());
->ConvertToRelativePath(this->LocalGenerator->GetBinaryDirectory(),
driver)
.c_str());
makeDepends << driver << ": " << obj_m << ".provides.build\n"; makeDepends << driver << ": " << obj_m << ".provides.build\n";
} }

View File

@ -581,12 +581,12 @@ void cmLocalUnixMakefileGenerator3::WriteMakeRule(
} else { } else {
// Split dependencies into multiple rule lines. This allows for // Split dependencies into multiple rule lines. This allows for
// very long dependency lists even on older make implementations. // very long dependency lists even on older make implementations.
std::string binDir = this->GetBinaryDirectory();
for (std::vector<std::string>::const_iterator dep = depends.begin(); for (std::vector<std::string>::const_iterator dep = depends.begin();
dep != depends.end(); ++dep) { dep != depends.end(); ++dep) {
replace = *dep; replace = *dep;
replace = cmSystemTools::ConvertToOutputPath( replace = cmSystemTools::ConvertToOutputPath(
this->ConvertToRelativePath(this->GetBinaryDirectory(), replace) this->ConvertToRelativePath(binDir, replace).c_str());
.c_str());
os << cmMakeSafe(tgt) << space << ": " << cmMakeSafe(replace) << "\n"; os << cmMakeSafe(tgt) << space << ": " << cmMakeSafe(replace) << "\n";
} }
} }