diff options
Diffstat (limited to 'Source/CPack/cmCPackOSXX11Generator.cxx')
-rw-r--r-- | Source/CPack/cmCPackOSXX11Generator.cxx | 111 |
1 files changed, 52 insertions, 59 deletions
diff --git a/Source/CPack/cmCPackOSXX11Generator.cxx b/Source/CPack/cmCPackOSXX11Generator.cxx index 8ea88a87a..951c65f4d 100644 --- a/Source/CPack/cmCPackOSXX11Generator.cxx +++ b/Source/CPack/cmCPackOSXX11Generator.cxx @@ -4,19 +4,18 @@ #include <sstream> +#include "cm_sys_stat.h" + #include "cmCPackGenerator.h" #include "cmCPackLog.h" +#include "cmDuration.h" #include "cmGeneratedFileStream.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" -#include "cm_sys_stat.h" -cmCPackOSXX11Generator::cmCPackOSXX11Generator() -{ -} +cmCPackOSXX11Generator::cmCPackOSXX11Generator() = default; -cmCPackOSXX11Generator::~cmCPackOSXX11Generator() -{ -} +cmCPackOSXX11Generator::~cmCPackOSXX11Generator() = default; int cmCPackOSXX11Generator::PackageFiles() { @@ -26,13 +25,13 @@ int cmCPackOSXX11Generator::PackageFiles() const char* cpackPackageExecutables = this->GetOption("CPACK_PACKAGE_EXECUTABLES"); if (cpackPackageExecutables) { - cmCPackLogger(cmCPackLog::LOG_DEBUG, "The cpackPackageExecutables: " - << cpackPackageExecutables << "." << std::endl); + cmCPackLogger(cmCPackLog::LOG_DEBUG, + "The cpackPackageExecutables: " << cpackPackageExecutables + << "." << std::endl); std::ostringstream str; std::ostringstream deleteStr; - std::vector<std::string> cpackPackageExecutablesVector; - cmSystemTools::ExpandListArgument(cpackPackageExecutables, - cpackPackageExecutablesVector); + std::vector<std::string> cpackPackageExecutablesVector = + cmExpandedList(cpackPackageExecutables); if (cpackPackageExecutablesVector.size() % 2 != 0) { cmCPackLogger( cmCPackLog::LOG_ERROR, @@ -57,16 +56,14 @@ int cmCPackOSXX11Generator::PackageFiles() diskImageDirectory + "/.background"; // App bundle directories - std::string packageDirFileName = toplevel; - packageDirFileName += "/"; - packageDirFileName += this->GetOption("CPACK_PACKAGE_FILE_NAME"); - packageDirFileName += ".app"; + std::string packageDirFileName = cmStrCat( + toplevel, '/', this->GetOption("CPACK_PACKAGE_FILE_NAME"), ".app"); std::string contentsDirectory = packageDirFileName + "/Contents"; std::string resourcesDirectory = contentsDirectory + "/Resources"; std::string appDirectory = contentsDirectory + "/MacOS"; std::string scriptDirectory = resourcesDirectory + "/Scripts"; - std::string resourceFileName = this->GetOption("CPACK_PACKAGE_FILE_NAME"); - resourceFileName += ".rsrc"; + std::string resourceFileName = + cmStrCat(this->GetOption("CPACK_PACKAGE_FILE_NAME"), ".rsrc"); const char* dir = resourcesDirectory.c_str(); const char* appdir = appDirectory.c_str(); @@ -77,14 +74,15 @@ int cmCPackOSXX11Generator::PackageFiles() if (iconFile) { std::string iconFileName = cmsys::SystemTools::GetFilenameName(iconFile); if (!cmSystemTools::FileExists(iconFile)) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find icon file: " + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Cannot find icon file: " << iconFile << ". Please check CPACK_PACKAGE_ICON setting." << std::endl); return 0; } 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()); } @@ -108,19 +106,16 @@ int cmCPackOSXX11Generator::PackageFiles() !this->CopyResourcePlistFile("OSXScriptLauncher", appdir, this->GetOption("CPACK_PACKAGE_FILE_NAME"), true)) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem copying the resource files" - << std::endl); + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Problem copying the resource files" << std::endl); return 0; } // Two of the files need to have execute permission, so ensure they do: - std::string runTimeScript = dir; - runTimeScript += "/"; - runTimeScript += "RuntimeScript"; + std::string runTimeScript = cmStrCat(dir, "/RuntimeScript"); - std::string appScriptName = appdir; - appScriptName += "/"; - appScriptName += this->GetOption("CPACK_PACKAGE_FILE_NAME"); + std::string appScriptName = + cmStrCat(appdir, '/', this->GetOption("CPACK_PACKAGE_FILE_NAME")); mode_t mode; if (cmsys::SystemTools::GetPermissions(runTimeScript.c_str(), mode)) { @@ -140,23 +135,24 @@ int cmCPackOSXX11Generator::PackageFiles() } std::string output; - std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); - tmpFile += "/hdiutilOutput.log"; + std::string tmpFile = cmStrCat(this->GetOption("CPACK_TOPLEVEL_DIRECTORY"), + "/hdiutilOutput.log"); std::ostringstream dmgCmd; dmgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM_DISK_IMAGE") - << "\" create -ov -format UDZO -srcfolder \"" << diskImageDirectory - << "\" \"" << packageFileNames[0] << "\""; - cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Compress disk image using command: " - << dmgCmd.str() << std::endl); + << "\" create -ov -fs HFS+ -format UDZO -srcfolder \"" + << diskImageDirectory << "\" \"" << packageFileNames[0] << "\""; + cmCPackLogger(cmCPackLog::LOG_VERBOSE, + "Compress disk image using command: " << dmgCmd.str() + << std::endl); // since we get random dashboard failures with this one // try running it more than once int retVal = 1; int numTries = 10; bool res = false; while (numTries > 0) { - res = - cmSystemTools::RunSingleCommand(dmgCmd.str().c_str(), &output, &output, - &retVal, 0, this->GeneratorVerbose, 0); + res = cmSystemTools::RunSingleCommand( + dmgCmd.str(), &output, &output, &retVal, nullptr, this->GeneratorVerbose, + cmDuration::zero()); if (res && !retVal) { numTries = -1; break; @@ -165,11 +161,12 @@ int cmCPackOSXX11Generator::PackageFiles() numTries--; } if (!res || retVal) { - cmGeneratedFileStream ofs(tmpFile.c_str()); + cmGeneratedFileStream ofs(tmpFile); ofs << "# Run command: " << dmgCmd.str() << std::endl << "# Output:" << std::endl << output << std::endl; - cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running hdiutil command: " + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Problem running hdiutil command: " << dmgCmd.str() << std::endl << "Please check " << tmpFile << " for errors" << std::endl); @@ -181,13 +178,13 @@ int cmCPackOSXX11Generator::PackageFiles() int cmCPackOSXX11Generator::InitializeInternal() { - cmCPackLogger(cmCPackLog::LOG_DEBUG, "cmCPackOSXX11Generator::Initialize()" - << std::endl); + cmCPackLogger(cmCPackLog::LOG_DEBUG, + "cmCPackOSXX11Generator::Initialize()" << std::endl); std::vector<std::string> path; std::string pkgPath = cmSystemTools::FindProgram("hdiutil", path, false); if (pkgPath.empty()) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find hdiutil compiler" - << std::endl); + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Cannot find hdiutil compiler" << std::endl); return 0; } this->SetOptionIfNotSet("CPACK_INSTALLER_PROGRAM_DISK_IMAGE", @@ -227,15 +224,14 @@ bool cmCPackOSXX11Generator::CopyCreateResourceFile(const std::string& name) return false; } - std::string destFileName = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); - destFileName += "/Resources/"; - destFileName += name + ext; + std::string destFileName = cmStrCat( +this->GetOption("CPACK_TOPLEVEL_DIRECTORY"), "/Resources/", name, ext ); cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Configure file: " << (inFileName ? inFileName : "(NULL)") << " to " << destFileName << std::endl); - this->ConfigureFile(inFileName, destFileName.c_str()); + this->ConfigureFile(inFileName, destFileName); return true; } */ @@ -244,9 +240,7 @@ bool cmCPackOSXX11Generator::CopyResourcePlistFile( const std::string& name, const std::string& dir, const char* outputFileName /* = 0 */, bool copyOnly /* = false */) { - std::string inFName = "CPack."; - inFName += name; - inFName += ".in"; + std::string inFName = cmStrCat("CPack.", name, ".in"); std::string inFileName = this->FindTemplate(inFName.c_str()); if (inFileName.empty()) { cmCPackLogger(cmCPackLog::LOG_ERROR, @@ -258,20 +252,19 @@ bool cmCPackOSXX11Generator::CopyResourcePlistFile( outputFileName = name.c_str(); } - std::string destFileName = dir; - destFileName += "/"; - destFileName += outputFileName; + std::string destFileName = cmStrCat(dir, '/', outputFileName); - cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Configure file: " - << inFileName << " to " << destFileName << std::endl); - this->ConfigureFile(inFileName.c_str(), destFileName.c_str(), copyOnly); + cmCPackLogger(cmCPackLog::LOG_VERBOSE, + "Configure file: " << inFileName << " to " << destFileName + << std::endl); + this->ConfigureFile(inFileName, destFileName, copyOnly); return true; } const char* cmCPackOSXX11Generator::GetPackagingInstallPrefix() { - this->InstallPrefix = "/"; - this->InstallPrefix += this->GetOption("CPACK_PACKAGE_FILE_NAME"); - this->InstallPrefix += ".app/Contents/Resources"; + this->InstallPrefix = + cmStrCat('/', this->GetOption("CPACK_PACKAGE_FILE_NAME"), + ".app/Contents/Resources"); return this->InstallPrefix.c_str(); } |