file(GENERATE): Refactor inputFileName calculation

This commit is contained in:
Josef Angstenberger
2020-08-01 02:58:26 +02:00
committed by Brad King
parent 31b057182e
commit a9602bb41e
2 changed files with 16 additions and 6 deletions

View File

@@ -125,12 +125,7 @@ void cmGeneratorExpressionEvaluationFile::Generate(cmLocalGenerator* lg)
if (this->InputIsContent) { if (this->InputIsContent) {
inputContent = this->Input; inputContent = this->Input;
} else { } else {
std::string inputFileName = this->Input; const std::string inputFileName = this->GetInputFileName(lg);
if (cmSystemTools::FileIsFullPath(inputFileName)) {
inputFileName = cmSystemTools::CollapseFullPath(inputFileName);
} else {
inputFileName = this->FixRelativePath(inputFileName, PathForInput, lg);
}
lg->GetMakefile()->AddCMakeDependFile(inputFileName); lg->GetMakefile()->AddCMakeDependFile(inputFileName);
cmSystemTools::GetPermissions(inputFileName.c_str(), perm); cmSystemTools::GetPermissions(inputFileName.c_str(), perm);
cmsys::ifstream fin(inputFileName.c_str()); cmsys::ifstream fin(inputFileName.c_str());
@@ -174,6 +169,20 @@ void cmGeneratorExpressionEvaluationFile::Generate(cmLocalGenerator* lg)
} }
} }
std::string cmGeneratorExpressionEvaluationFile::GetInputFileName(
cmLocalGenerator* lg)
{
std::string inputFileName = this->Input;
if (cmSystemTools::FileIsFullPath(inputFileName)) {
inputFileName = cmSystemTools::CollapseFullPath(inputFileName);
} else {
inputFileName = this->FixRelativePath(inputFileName, PathForInput, lg);
}
return inputFileName;
}
std::string cmGeneratorExpressionEvaluationFile::FixRelativePath( std::string cmGeneratorExpressionEvaluationFile::FixRelativePath(
std::string const& relativePath, PathRole role, cmLocalGenerator* lg) std::string const& relativePath, PathRole role, cmLocalGenerator* lg)
{ {

View File

@@ -38,6 +38,7 @@ private:
cmCompiledGeneratorExpression* inputExpression, cmCompiledGeneratorExpression* inputExpression,
std::map<std::string, std::string>& outputFiles, mode_t perm); std::map<std::string, std::string>& outputFiles, mode_t perm);
std::string GetInputFileName(cmLocalGenerator* lg);
enum PathRole enum PathRole
{ {
PathForInput, PathForInput,