cmMakefile::ConfigureFile: Accept std::string parameters

This commit is contained in:
Vitaly Stakhovsky 2019-02-18 09:54:51 -05:00
parent bafd0ffa98
commit 0281f9a4ca
15 changed files with 41 additions and 41 deletions

View File

@ -618,7 +618,7 @@ bool cmCPackWIXGenerator::GenerateMainSourceFileFromTemplate()
std::string mainSourceFilePath = this->CPackTopLevel + "/main.wxs"; std::string mainSourceFilePath = this->CPackTopLevel + "/main.wxs";
if (!ConfigureFile(wixTemplate.c_str(), mainSourceFilePath.c_str())) { if (!ConfigureFile(wixTemplate, mainSourceFilePath)) {
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,
"Failed creating '" << mainSourceFilePath "Failed creating '" << mainSourceFilePath
<< "'' from template." << std::endl); << "'' from template." << std::endl);

View File

@ -1245,7 +1245,8 @@ bool cmCPackGenerator::ConfigureString(const std::string& inString,
return true; return true;
} }
bool cmCPackGenerator::ConfigureFile(const char* inName, const char* outName, bool cmCPackGenerator::ConfigureFile(const std::string& inName,
const std::string& outName,
bool copyOnly /* = false */) bool copyOnly /* = false */)
{ {
return this->MakefileMap->ConfigureFile(inName, outName, copyOnly, true, return this->MakefileMap->ConfigureFile(inName, outName, copyOnly, true,

View File

@ -169,7 +169,8 @@ protected:
virtual const char* GetPackagingInstallPrefix(); virtual const char* GetPackagingInstallPrefix();
virtual std::string FindTemplate(const char* name); virtual std::string FindTemplate(const char* name);
virtual bool ConfigureFile(const char* inName, const char* outName, virtual bool ConfigureFile(const std::string& inName,
const std::string& outName,
bool copyOnly = false); bool copyOnly = false);
virtual bool ConfigureString(const std::string& input, std::string& output); virtual bool ConfigureString(const std::string& input, std::string& output);
virtual int InitializeInternal(); virtual int InitializeInternal();

View File

@ -292,9 +292,8 @@ int cmCPackNSISGenerator::PackageFiles()
this->SetOption("CPACK_NSIS_DEFINES", defines.c_str()); this->SetOption("CPACK_NSIS_DEFINES", defines.c_str());
} }
this->ConfigureFile(nsisInInstallOptions.c_str(), this->ConfigureFile(nsisInInstallOptions, nsisInstallOptions);
nsisInstallOptions.c_str()); this->ConfigureFile(nsisInFileName, nsisFileName);
this->ConfigureFile(nsisInFileName.c_str(), nsisFileName.c_str());
std::string nsisCmd = "\""; std::string nsisCmd = "\"";
nsisCmd += this->GetOption("CPACK_INSTALLER_PROGRAM"); nsisCmd += this->GetOption("CPACK_INSTALLER_PROGRAM");
nsisCmd += "\" \"" + nsisFileName + "\""; nsisCmd += "\" \"" + nsisFileName + "\"";

View File

@ -83,7 +83,7 @@ int cmCPackOSXX11Generator::PackageFiles()
return 0; return 0;
} }
std::string destFileName = resourcesDirectory + "/" + iconFileName; std::string destFileName = resourcesDirectory + "/" + iconFileName;
this->ConfigureFile(iconFile, destFileName.c_str(), true); this->ConfigureFile(iconFile, destFileName, true);
this->SetOptionIfNotSet("CPACK_APPLE_GUI_ICON", iconFileName.c_str()); this->SetOptionIfNotSet("CPACK_APPLE_GUI_ICON", iconFileName.c_str());
} }
@ -236,7 +236,7 @@ bool cmCPackOSXX11Generator::CopyCreateResourceFile(const std::string& name)
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Configure file: " cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Configure file: "
<< (inFileName ? inFileName : "(NULL)") << (inFileName ? inFileName : "(NULL)")
<< " to " << destFileName << std::endl); << " to " << destFileName << std::endl);
this->ConfigureFile(inFileName, destFileName.c_str()); this->ConfigureFile(inFileName, destFileName);
return true; return true;
} }
*/ */
@ -266,7 +266,7 @@ bool cmCPackOSXX11Generator::CopyResourcePlistFile(
cmCPackLogger(cmCPackLog::LOG_VERBOSE, cmCPackLogger(cmCPackLog::LOG_VERBOSE,
"Configure file: " << inFileName << " to " << destFileName "Configure file: " << inFileName << " to " << destFileName
<< std::endl); << std::endl);
this->ConfigureFile(inFileName.c_str(), destFileName.c_str(), copyOnly); this->ConfigureFile(inFileName, destFileName, copyOnly);
return true; return true;
} }

View File

@ -105,7 +105,7 @@ void cmCPackPKGGenerator::WriteDistributionFile(const char* metapackageFile)
// Create the distribution.dist file in the metapackage to turn it // Create the distribution.dist file in the metapackage to turn it
// into a distribution package. // into a distribution package.
this->ConfigureFile(distributionTemplate.c_str(), distributionFile.c_str()); this->ConfigureFile(distributionTemplate, distributionFile);
} }
void cmCPackPKGGenerator::CreateChoiceOutline( void cmCPackPKGGenerator::CreateChoiceOutline(
@ -294,7 +294,7 @@ bool cmCPackPKGGenerator::CopyCreateResourceFile(const std::string& name,
cmCPackLogger(cmCPackLog::LOG_VERBOSE, cmCPackLogger(cmCPackLog::LOG_VERBOSE,
"Configure file: " << (inFileName ? inFileName : "(NULL)") "Configure file: " << (inFileName ? inFileName : "(NULL)")
<< " to " << destFileName << std::endl); << " to " << destFileName << std::endl);
this->ConfigureFile(inFileName, destFileName.c_str()); this->ConfigureFile(inFileName, destFileName);
return true; return true;
} }
@ -322,7 +322,7 @@ bool cmCPackPKGGenerator::CopyResourcePlistFile(const std::string& name,
cmCPackLogger(cmCPackLog::LOG_VERBOSE, cmCPackLogger(cmCPackLog::LOG_VERBOSE,
"Configure file: " << inFileName << " to " << destFileName "Configure file: " << inFileName << " to " << destFileName
<< std::endl); << std::endl);
this->ConfigureFile(inFileName.c_str(), destFileName.c_str()); this->ConfigureFile(inFileName, destFileName);
return true; return true;
} }

View File

@ -102,7 +102,7 @@ bool cmConfigureFileCommand::InitialPass(std::vector<std::string> const& args,
int cmConfigureFileCommand::ConfigureFile() int cmConfigureFileCommand::ConfigureFile()
{ {
return this->Makefile->ConfigureFile( return this->Makefile->ConfigureFile(this->InputFile, this->OutputFile,
this->InputFile.c_str(), this->OutputFile.c_str(), this->CopyOnly, this->CopyOnly, this->AtOnly,
this->AtOnly, this->EscapeQuotes, this->NewLineStyle); this->EscapeQuotes, this->NewLineStyle);
} }

View File

@ -136,8 +136,7 @@ bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& args,
this->Makefile->AddDefinition("CMAKE_FUNCTION_TABLE_ENTIRES", this->Makefile->AddDefinition("CMAKE_FUNCTION_TABLE_ENTIRES",
functionMapCode.c_str()); functionMapCode.c_str());
bool res = true; bool res = true;
if (!this->Makefile->ConfigureFile(configFile.c_str(), driver.c_str(), false, if (!this->Makefile->ConfigureFile(configFile, driver, false, true, false)) {
true, false)) {
res = false; res = false;
} }

View File

@ -2002,7 +2002,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
// so let it replace the framework name. This avoids creating // so let it replace the framework name. This avoids creating
// a per-configuration Info.plist file. // a per-configuration Info.plist file.
this->CurrentLocalGenerator->GenerateFrameworkInfoPList( this->CurrentLocalGenerator->GenerateFrameworkInfoPList(
gtgt, "$(EXECUTABLE_NAME)", plist.c_str()); gtgt, "$(EXECUTABLE_NAME)", plist);
buildSettings->AddAttribute("INFOPLIST_FILE", buildSettings->AddAttribute("INFOPLIST_FILE",
this->CreateString(plist)); this->CreateString(plist));
buildSettings->AddAttribute("MACH_O_TYPE", buildSettings->AddAttribute("MACH_O_TYPE",
@ -2043,7 +2043,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
// a per-configuration Info.plist file. The cfbundle plist // a per-configuration Info.plist file. The cfbundle plist
// is very similar to the application bundle plist // is very similar to the application bundle plist
this->CurrentLocalGenerator->GenerateAppleInfoPList( this->CurrentLocalGenerator->GenerateAppleInfoPList(
gtgt, "$(EXECUTABLE_NAME)", plist.c_str()); gtgt, "$(EXECUTABLE_NAME)", plist);
buildSettings->AddAttribute("INFOPLIST_FILE", buildSettings->AddAttribute("INFOPLIST_FILE",
this->CreateString(plist)); this->CreateString(plist));
} else { } else {
@ -2077,7 +2077,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
// so let it replace the framework name. This avoids creating // so let it replace the framework name. This avoids creating
// a per-configuration Info.plist file. // a per-configuration Info.plist file.
this->CurrentLocalGenerator->GenerateFrameworkInfoPList( this->CurrentLocalGenerator->GenerateFrameworkInfoPList(
gtgt, "$(EXECUTABLE_NAME)", plist.c_str()); gtgt, "$(EXECUTABLE_NAME)", plist);
buildSettings->AddAttribute("INFOPLIST_FILE", buildSettings->AddAttribute("INFOPLIST_FILE",
this->CreateString(plist)); this->CreateString(plist));
} else { } else {
@ -2115,7 +2115,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
// so let it replace the executable name. This avoids creating // so let it replace the executable name. This avoids creating
// a per-configuration Info.plist file. // a per-configuration Info.plist file.
this->CurrentLocalGenerator->GenerateAppleInfoPList( this->CurrentLocalGenerator->GenerateAppleInfoPList(
gtgt, "$(EXECUTABLE_NAME)", plist.c_str()); gtgt, "$(EXECUTABLE_NAME)", plist);
buildSettings->AddAttribute("INFOPLIST_FILE", buildSettings->AddAttribute("INFOPLIST_FILE",
this->CreateString(plist)); this->CreateString(plist));
} }

View File

@ -2822,7 +2822,7 @@ static void cmLGInfoProp(cmMakefile* mf, cmGeneratorTarget* target,
void cmLocalGenerator::GenerateAppleInfoPList(cmGeneratorTarget* target, void cmLocalGenerator::GenerateAppleInfoPList(cmGeneratorTarget* target,
const std::string& targetName, const std::string& targetName,
const char* fname) const std::string& fname)
{ {
// Find the Info.plist template. // Find the Info.plist template.
const char* in = target->GetProperty("MACOSX_BUNDLE_INFO_PLIST"); const char* in = target->GetProperty("MACOSX_BUNDLE_INFO_PLIST");
@ -2856,11 +2856,12 @@ void cmLocalGenerator::GenerateAppleInfoPList(cmGeneratorTarget* target,
cmLGInfoProp(mf, target, "MACOSX_BUNDLE_SHORT_VERSION_STRING"); cmLGInfoProp(mf, target, "MACOSX_BUNDLE_SHORT_VERSION_STRING");
cmLGInfoProp(mf, target, "MACOSX_BUNDLE_BUNDLE_VERSION"); cmLGInfoProp(mf, target, "MACOSX_BUNDLE_BUNDLE_VERSION");
cmLGInfoProp(mf, target, "MACOSX_BUNDLE_COPYRIGHT"); cmLGInfoProp(mf, target, "MACOSX_BUNDLE_COPYRIGHT");
mf->ConfigureFile(inFile.c_str(), fname, false, false, false); mf->ConfigureFile(inFile, fname, false, false, false);
} }
void cmLocalGenerator::GenerateFrameworkInfoPList( void cmLocalGenerator::GenerateFrameworkInfoPList(
cmGeneratorTarget* target, const std::string& targetName, const char* fname) cmGeneratorTarget* target, const std::string& targetName,
const std::string& fname)
{ {
// Find the Info.plist template. // Find the Info.plist template.
const char* in = target->GetProperty("MACOSX_FRAMEWORK_INFO_PLIST"); const char* in = target->GetProperty("MACOSX_FRAMEWORK_INFO_PLIST");
@ -2890,5 +2891,5 @@ void cmLocalGenerator::GenerateFrameworkInfoPList(
cmLGInfoProp(mf, target, "MACOSX_FRAMEWORK_IDENTIFIER"); cmLGInfoProp(mf, target, "MACOSX_FRAMEWORK_IDENTIFIER");
cmLGInfoProp(mf, target, "MACOSX_FRAMEWORK_SHORT_VERSION_STRING"); cmLGInfoProp(mf, target, "MACOSX_FRAMEWORK_SHORT_VERSION_STRING");
cmLGInfoProp(mf, target, "MACOSX_FRAMEWORK_BUNDLE_VERSION"); cmLGInfoProp(mf, target, "MACOSX_FRAMEWORK_BUNDLE_VERSION");
mf->ConfigureFile(inFile.c_str(), fname, false, false, false); mf->ConfigureFile(inFile, fname, false, false, false);
} }

View File

@ -340,14 +340,14 @@ public:
*/ */
void GenerateAppleInfoPList(cmGeneratorTarget* target, void GenerateAppleInfoPList(cmGeneratorTarget* target,
const std::string& targetName, const std::string& targetName,
const char* fname); const std::string& fname);
/** /**
* Generate a macOS framework Info.plist file. * Generate a macOS framework Info.plist file.
*/ */
void GenerateFrameworkInfoPList(cmGeneratorTarget* target, void GenerateFrameworkInfoPList(cmGeneratorTarget* target,
const std::string& targetName, const std::string& targetName,
const char* fname); const std::string& fname);
/** Construct a comment for a custom command. */ /** Construct a comment for a custom command. */
std::string ConstructComment(cmCustomCommandGenerator const& ccg, std::string ConstructComment(cmCustomCommandGenerator const& ccg,
const char* default_comment = ""); const char* default_comment = "");

View File

@ -3729,22 +3729,23 @@ void cmMakefile::ConfigureString(const std::string& input, std::string& output,
lineNumber, true, true); lineNumber, true, true);
} }
int cmMakefile::ConfigureFile(const char* infile, const char* outfile, int cmMakefile::ConfigureFile(const std::string& infile,
bool copyonly, bool atOnly, bool escapeQuotes, const std::string& outfile, bool copyonly,
bool atOnly, bool escapeQuotes,
cmNewLineStyle newLine) cmNewLineStyle newLine)
{ {
int res = 1; int res = 1;
if (!this->CanIWriteThisFile(outfile)) { if (!this->CanIWriteThisFile(outfile)) {
cmSystemTools::Error("Attempt to write file: ", outfile, cmSystemTools::Error("Attempt to write file: " + outfile +
" into a source directory."); " into a source directory.");
return 0; return 0;
} }
if (!cmSystemTools::FileExists(infile)) { if (!cmSystemTools::FileExists(infile)) {
cmSystemTools::Error("File ", infile, " does not exist."); cmSystemTools::Error("File " + infile + " does not exist.");
return 0; return 0;
} }
std::string soutfile = outfile; std::string soutfile = outfile;
std::string sinfile = infile; const std::string& sinfile = infile;
this->AddCMakeDependFile(sinfile); this->AddCMakeDependFile(sinfile);
cmSystemTools::ConvertToUnixSlashes(soutfile); cmSystemTools::ConvertToUnixSlashes(soutfile);

View File

@ -610,8 +610,8 @@ public:
/** /**
* Copy file but change lines according to ConfigureString * Copy file but change lines according to ConfigureString
*/ */
int ConfigureFile(const char* infile, const char* outfile, bool copyonly, int ConfigureFile(const std::string& infile, const std::string& outfile,
bool atOnly, bool escapeQuotes, bool copyonly, bool atOnly, bool escapeQuotes,
cmNewLineStyle = cmNewLineStyle()); cmNewLineStyle = cmNewLineStyle());
/** /**

View File

@ -54,8 +54,7 @@ void cmOSXBundleGenerator::CreateAppBundle(const std::string& targetName,
plist += this->GT->GetAppBundleDirectory(this->ConfigName, plist += this->GT->GetAppBundleDirectory(this->ConfigName,
cmGeneratorTarget::ContentLevel); cmGeneratorTarget::ContentLevel);
plist += "/Info.plist"; plist += "/Info.plist";
this->LocalGenerator->GenerateAppleInfoPList(this->GT, targetName, this->LocalGenerator->GenerateAppleInfoPList(this->GT, targetName, plist);
plist.c_str());
this->Makefile->AddCMakeOutputFile(plist); this->Makefile->AddCMakeOutputFile(plist);
outpath = out; outpath = out;
} }
@ -90,8 +89,7 @@ void cmOSXBundleGenerator::CreateFramework(const std::string& targetName,
} }
plist += "/Info.plist"; plist += "/Info.plist";
std::string name = cmSystemTools::GetFilenameName(targetName); std::string name = cmSystemTools::GetFilenameName(targetName);
this->LocalGenerator->GenerateFrameworkInfoPList(this->GT, name, this->LocalGenerator->GenerateFrameworkInfoPList(this->GT, name, plist);
plist.c_str());
// Generate Versions directory only for MacOSX frameworks // Generate Versions directory only for MacOSX frameworks
if (this->Makefile->PlatformIsAppleEmbedded()) { if (this->Makefile->PlatformIsAppleEmbedded()) {
@ -184,7 +182,7 @@ void cmOSXBundleGenerator::CreateCFBundle(const std::string& targetName,
cmGeneratorTarget::ContentLevel); cmGeneratorTarget::ContentLevel);
plist += "/Info.plist"; plist += "/Info.plist";
std::string name = cmSystemTools::GetFilenameName(targetName); std::string name = cmSystemTools::GetFilenameName(targetName);
this->LocalGenerator->GenerateAppleInfoPList(this->GT, name, plist.c_str()); this->LocalGenerator->GenerateAppleInfoPList(this->GT, name, plist);
this->Makefile->AddCMakeOutputFile(plist); this->Makefile->AddCMakeOutputFile(plist);
} }

View File

@ -622,8 +622,8 @@ void cmVisualStudio10TargetGenerator::Generate()
propsLocal += this->DefaultArtifactDir; propsLocal += this->DefaultArtifactDir;
propsLocal += "\\nasm.props"; propsLocal += "\\nasm.props";
ConvertToWindowsSlash(propsLocal); ConvertToWindowsSlash(propsLocal);
this->Makefile->ConfigureFile(propsTemplate.c_str(), this->Makefile->ConfigureFile(propsTemplate, propsLocal, false, true,
propsLocal.c_str(), false, true, true); true);
Elem(e1, "Import").Attribute("Project", propsLocal); Elem(e1, "Import").Attribute("Project", propsLocal);
} }
} }