From ff08a80af19530c95db4faa921168fb9ab346047 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 7 Jun 2016 08:39:45 -0400 Subject: Source/CPack: Run clang-format to fix style --- Source/CPack/cmCPackDebGenerator.cxx | 12 +-- Source/CPack/cmCPackGeneratorFactory.cxx | 2 +- Source/CPack/cmCPackPKGGenerator.cxx | 40 ++++---- Source/CPack/cmCPackPKGGenerator.h | 2 - Source/CPack/cmCPackProductBuildGenerator.cxx | 127 ++++++++++---------------- Source/CPack/cmCPackProductBuildGenerator.h | 2 - 6 files changed, 75 insertions(+), 110 deletions(-) diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index ddaa483..bef0fb4 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -57,9 +57,9 @@ int cmCPackDebGenerator::PackageOnePack(std::string const& initialTopLevel, // Begin the archive for this pack std::string localToplevel(initialTopLevel); std::string packageFileName(cmSystemTools::GetParentDirectory(toplevel)); - std::string outputFileName(std::string( - this->GetOption("CPACK_PACKAGE_FILE_NAME")) + - "-" + packageName + this->GetOutputExtension()); + std::string outputFileName( + std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME")) + "-" + + packageName + this->GetOutputExtension()); localToplevel += "/" + packageName; /* replace the TEMP DIRECTORY with the component one */ @@ -174,9 +174,9 @@ int cmCPackDebGenerator::PackageComponentsAllInOne( // The ALL GROUPS in ONE package case std::string localToplevel(initialTopLevel); std::string packageFileName(cmSystemTools::GetParentDirectory(toplevel)); - std::string outputFileName(std::string( - this->GetOption("CPACK_PACKAGE_FILE_NAME")) + - this->GetOutputExtension()); + std::string outputFileName( + std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME")) + + this->GetOutputExtension()); // all GROUP in one vs all COMPONENT in one localToplevel += "/" + compInstDirName; diff --git a/Source/CPack/cmCPackGeneratorFactory.cxx b/Source/CPack/cmCPackGeneratorFactory.cxx index cf072bb..2210835 100644 --- a/Source/CPack/cmCPackGeneratorFactory.cxx +++ b/Source/CPack/cmCPackGeneratorFactory.cxx @@ -125,7 +125,7 @@ cmCPackGeneratorFactory::cmCPackGeneratorFactory() } if (cmCPackProductBuildGenerator::CanGenerate()) { this->RegisterGenerator("productbuild", "Mac OSX pkg", - cmCPackProductBuildGenerator::CreateGenerator); + cmCPackProductBuildGenerator::CreateGenerator); } #endif #if !defined(_WIN32) && !defined(__QNXNTO__) && !defined(__BEOS__) && \ diff --git a/Source/CPack/cmCPackPKGGenerator.cxx b/Source/CPack/cmCPackPKGGenerator.cxx index 7bc05d0..3d3ef31 100644 --- a/Source/CPack/cmCPackPKGGenerator.cxx +++ b/Source/CPack/cmCPackPKGGenerator.cxx @@ -11,17 +11,17 @@ ============================================================================*/ #include "cmCPackPKGGenerator.h" -#include "cmake.h" +#include "cmCPackComponentGroup.h" +#include "cmCPackLog.h" +#include "cmGeneratedFileStream.h" #include "cmGlobalGenerator.h" #include "cmLocalGenerator.h" -#include "cmSystemTools.h" #include "cmMakefile.h" -#include "cmGeneratedFileStream.h" -#include "cmCPackComponentGroup.h" -#include "cmCPackLog.h" +#include "cmSystemTools.h" +#include "cmake.h" -#include #include +#include cmCPackPKGGenerator::cmCPackPKGGenerator() { @@ -39,13 +39,12 @@ bool cmCPackPKGGenerator::SupportsComponentInstallation() const int cmCPackPKGGenerator::InitializeInternal() { - cmCPackLogger(cmCPackLog::LOG_DEBUG, - "cmCPackPKGGenerator::Initialize()" << std::endl); + cmCPackLogger(cmCPackLog::LOG_DEBUG, "cmCPackPKGGenerator::Initialize()" + << std::endl); return this->Superclass::InitializeInternal(); } - std::string cmCPackPKGGenerator::GetPackageName( const cmCPackComponent& component) { @@ -53,16 +52,15 @@ std::string cmCPackPKGGenerator::GetPackageName( std::string packagesDir = this->GetOption("CPACK_TEMPORARY_DIRECTORY"); packagesDir += ".dummy"; std::ostringstream out; - out << cmSystemTools::GetFilenameWithoutLastExtension(packagesDir) - << "-" << component.Name << ".pkg"; + out << cmSystemTools::GetFilenameWithoutLastExtension(packagesDir) << "-" + << component.Name << ".pkg"; return out.str(); } else { return component.ArchiveFile + ".pkg"; } } -void cmCPackPKGGenerator::WriteDistributionFile( - const char* metapackageFile) +void cmCPackPKGGenerator::WriteDistributionFile(const char* metapackageFile) { std::string distributionTemplate = this->FindTemplate("CPack.distribution.dist.in"); @@ -144,8 +142,8 @@ void cmCPackPKGGenerator::CreateChoiceOutline( out << "" << std::endl; } -void cmCPackPKGGenerator::CreateChoice( - const cmCPackComponentGroup& group, std::ostringstream& out) +void cmCPackPKGGenerator::CreateChoice(const cmCPackComponentGroup& group, + std::ostringstream& out) { out << "" << std::endl; } -void cmCPackPKGGenerator::CreateChoice( - const cmCPackComponent& component, std::ostringstream& out) +void cmCPackPKGGenerator::CreateChoice(const cmCPackComponent& component, + std::ostringstream& out) { std::string packageId = "com."; packageId += this->GetOption("CPACK_PACKAGE_VENDOR"); @@ -277,8 +275,8 @@ std::string cmCPackPKGGenerator::EscapeForXML(std::string str) return str; } -bool cmCPackPKGGenerator::CopyCreateResourceFile( - const std::string& name, const std::string& dirName) +bool cmCPackPKGGenerator::CopyCreateResourceFile(const std::string& name, + const std::string& dirName) { std::string uname = cmSystemTools::UpperCase(name); std::string cpackVar = "CPACK_RESOURCE_FILE_" + uname; @@ -323,8 +321,8 @@ bool cmCPackPKGGenerator::CopyCreateResourceFile( return true; } -bool cmCPackPKGGenerator::CopyResourcePlistFile( - const std::string& name, const char* outName) +bool cmCPackPKGGenerator::CopyResourcePlistFile(const std::string& name, + const char* outName) { if (!outName) { outName = name.c_str(); diff --git a/Source/CPack/cmCPackPKGGenerator.h b/Source/CPack/cmCPackPKGGenerator.h index 3011f78..20ba94c 100644 --- a/Source/CPack/cmCPackPKGGenerator.h +++ b/Source/CPack/cmCPackPKGGenerator.h @@ -13,7 +13,6 @@ #ifndef cmCPackPKGGenerator_h #define cmCPackPKGGenerator_h - #include "cmCPackGenerator.h" class cmCPackComponent; @@ -97,7 +96,6 @@ protected: // The PostFlight component when creating a metapackage cmCPackComponent PostFlightComponent; - }; #endif diff --git a/Source/CPack/cmCPackProductBuildGenerator.cxx b/Source/CPack/cmCPackProductBuildGenerator.cxx index aa9a27d..c2a13d0 100644 --- a/Source/CPack/cmCPackProductBuildGenerator.cxx +++ b/Source/CPack/cmCPackProductBuildGenerator.cxx @@ -11,17 +11,17 @@ ============================================================================*/ #include "cmCPackProductBuildGenerator.h" -#include "cmake.h" +#include "cmCPackComponentGroup.h" +#include "cmCPackLog.h" +#include "cmGeneratedFileStream.h" #include "cmGlobalGenerator.h" #include "cmLocalGenerator.h" -#include "cmSystemTools.h" #include "cmMakefile.h" -#include "cmGeneratedFileStream.h" -#include "cmCPackComponentGroup.h" -#include "cmCPackLog.h" +#include "cmSystemTools.h" +#include "cmake.h" -#include #include +#include cmCPackProductBuildGenerator::cmCPackProductBuildGenerator() { @@ -37,56 +37,47 @@ int cmCPackProductBuildGenerator::PackageFiles() // TODO: Use toplevel // It is used! Is this an obsolete comment? - std::string packageDirFileName - = this->GetOption("CPACK_TEMPORARY_DIRECTORY"); + std::string packageDirFileName = + this->GetOption("CPACK_TEMPORARY_DIRECTORY"); // Create the directory where component packages will be built. std::string basePackageDir = packageDirFileName; basePackageDir += "/Contents/Packages"; - if (!cmsys::SystemTools::MakeDirectory(basePackageDir.c_str())) - { + if (!cmsys::SystemTools::MakeDirectory(basePackageDir.c_str())) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem creating component packages directory: " << basePackageDir << std::endl); return 0; } - if (!this->Components.empty()) - { + if (!this->Components.empty()) { std::map::iterator compIt; for (compIt = this->Components.begin(); compIt != this->Components.end(); - ++compIt) - { + ++compIt) { std::string packageDir = toplevel; packageDir += '/'; packageDir += compIt->first; if (!this->GenerateComponentPackage(basePackageDir, GetPackageName(compIt->second), - packageDir, - &compIt->second)) - { + packageDir, &compIt->second)) { return 0; - } } } - else - { - if(!this->GenerateComponentPackage(basePackageDir, - this->GetOption("CPACK_PACKAGE_NAME"), - toplevel, NULL)) - { + } else { + if (!this->GenerateComponentPackage(basePackageDir, + this->GetOption("CPACK_PACKAGE_NAME"), + toplevel, NULL)) { return 0; } } // Copy or create all of the resource files we need. std::string resDir = packageDirFileName + "/Contents"; - if ( !this->CopyCreateResourceFile("License", resDir.c_str()) - || !this->CopyCreateResourceFile("ReadMe", resDir.c_str()) - || !this->CopyCreateResourceFile("Welcome", resDir.c_str())) - { + if (!this->CopyCreateResourceFile("License", resDir.c_str()) || + !this->CopyCreateResourceFile("ReadMe", resDir.c_str()) || + !this->CopyCreateResourceFile("Welcome", resDir.c_str())) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem copying the resource files" - << std::endl); + << std::endl); return 0; } @@ -97,13 +88,13 @@ int cmCPackProductBuildGenerator::PackageFiles() std::string version = this->GetOption("CPACK_PACKAGE_VERSION"); std::string productbuild = this->GetOption("CPACK_COMMAND_PRODUCTBUILD"); - pkgCmd << productbuild - << " --distribution \"" << packageDirFileName - << "/Contents/distribution.dist\"" - << " --package-path \"" << packageDirFileName << "/Contents/Packages" << "\"" - << " --resources \"" << resDir << "\"" - << " --version \"" << version << "\"" - << " \"" << packageFileNames[0] << "\""; + pkgCmd << productbuild << " --distribution \"" << packageDirFileName + << "/Contents/distribution.dist\"" + << " --package-path \"" << packageDirFileName << "/Contents/Packages" + << "\"" + << " --resources \"" << resDir << "\"" + << " --version \"" << version << "\"" + << " \"" << packageFileNames[0] << "\""; // Run ProductBuild return RunProductBuild(pkgCmd.str()); @@ -123,7 +114,6 @@ int cmCPackProductBuildGenerator::InitializeInternal() } this->SetOptionIfNotSet("CPACK_COMMAND_PKGBUILD", program.c_str()); - program = cmSystemTools::FindProgram("productbuild", no_paths, false); if (program.empty()) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find productbuild executable" @@ -135,9 +125,7 @@ int cmCPackProductBuildGenerator::InitializeInternal() return this->Superclass::InitializeInternal(); } - -bool cmCPackProductBuildGenerator::RunProductBuild( - const std::string& command) +bool cmCPackProductBuildGenerator::RunProductBuild(const std::string& command) { std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); tmpFile += "/ProductBuildOutput.log"; @@ -145,12 +133,11 @@ bool cmCPackProductBuildGenerator::RunProductBuild( cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << command << std::endl); std::string output, error_output; int retVal = 1; - bool res = cmSystemTools::RunSingleCommand(command.c_str(), - &output, &error_output, &retVal, 0, this->GeneratorVerbose, 0); - cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Done running command" - << std::endl); - if ( !res || retVal ) - { + bool res = + cmSystemTools::RunSingleCommand(command.c_str(), &output, &error_output, + &retVal, 0, this->GeneratorVerbose, 0); + cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Done running command" << std::endl); + if (!res || retVal) { cmGeneratedFileStream ofs(tmpFile.c_str()); ofs << "# Run command: " << command << std::endl << "# Output:" << std::endl @@ -160,23 +147,20 @@ bool cmCPackProductBuildGenerator::RunProductBuild( << "Please check " << tmpFile << " for errors" << std::endl); return false; - } + } return true; } bool cmCPackProductBuildGenerator::GenerateComponentPackage( - const std::string& packageFileDir, - const std::string& packageFileName, - const std::string& packageDir, - const cmCPackComponent* component) + const std::string& packageFileDir, const std::string& packageFileName, + const std::string& packageDir, const cmCPackComponent* component) { std::string packageFile = packageFileDir; packageFile += '/'; packageFile += packageFileName; - cmCPackLogger(cmCPackLog::LOG_OUTPUT, - "- Building component package: " << - packageFile << std::endl); + cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Building component package: " + << packageFile << std::endl); const char* comp_name = component ? component->Name.c_str() : NULL; @@ -184,15 +168,13 @@ bool cmCPackProductBuildGenerator::GenerateComponentPackage( const char* postflight = this->GetComponentScript("POSTFLIGHT", comp_name); std::string resDir = packageFileDir; - if(component) - { + if (component) { resDir += "/"; resDir += component->Name; } std::string scriptDir = resDir + "/scripts"; - if ( !cmsys::SystemTools::MakeDirectory(scriptDir.c_str())) - { + if (!cmsys::SystemTools::MakeDirectory(scriptDir.c_str())) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem creating installer directory: " << scriptDir << std::endl); @@ -202,20 +184,13 @@ bool cmCPackProductBuildGenerator::GenerateComponentPackage( // if preflight, postflight, or postupgrade are set // then copy them into the script directory and make // them executable - if(preflight) - { - this->CopyInstallScript(scriptDir.c_str(), - preflight, - "preinstall"); + if (preflight) { + this->CopyInstallScript(scriptDir.c_str(), preflight, "preinstall"); } - if(postflight) - { - this->CopyInstallScript(scriptDir.c_str(), - postflight, - "postinstall"); + if (postflight) { + this->CopyInstallScript(scriptDir.c_str(), postflight, "postinstall"); } - // The command that will be used to run ProductBuild std::ostringstream pkgCmd; @@ -223,17 +198,15 @@ bool cmCPackProductBuildGenerator::GenerateComponentPackage( pkgId += this->GetOption("CPACK_PACKAGE_VENDOR"); pkgId += '.'; pkgId += this->GetOption("CPACK_PACKAGE_NAME"); - if(component) - { + if (component) { pkgId += '.'; pkgId += component->Name; - } + } std::string version = this->GetOption("CPACK_PACKAGE_VERSION"); std::string pkgbuild = this->GetOption("CPACK_COMMAND_PKGBUILD"); - pkgCmd << pkgbuild - << " --root \"" << packageDir << "\"" + pkgCmd << pkgbuild << " --root \"" << packageDir << "\"" << " --identifier \"" << pkgId << "\"" << " --scripts \"" << scriptDir << "\"" << " --version \"" << version << "\"" @@ -245,12 +218,10 @@ bool cmCPackProductBuildGenerator::GenerateComponentPackage( } const char* cmCPackProductBuildGenerator::GetComponentScript( - const char* script, - const char* component_name) + const char* script, const char* component_name) { std::string scriptname = std::string("CPACK_") + script + "_"; - if(component_name) - { + if (component_name) { scriptname += cmSystemTools::UpperCase(component_name); scriptname += "_"; } diff --git a/Source/CPack/cmCPackProductBuildGenerator.h b/Source/CPack/cmCPackProductBuildGenerator.h index 0740f89..b05b50a 100644 --- a/Source/CPack/cmCPackProductBuildGenerator.h +++ b/Source/CPack/cmCPackProductBuildGenerator.h @@ -13,7 +13,6 @@ #ifndef cmCPackProductBuildGenerator_h #define cmCPackProductBuildGenerator_h - #include "cmCPackPKGGenerator.h" class cmCPackComponent; @@ -54,7 +53,6 @@ protected: const char* GetComponentScript(const char* script, const char* script_component); - }; #endif -- cgit v0.12