Source/CPack: Run clang-format to fix style

This commit is contained in:
Brad King 2016-06-07 08:39:45 -04:00
parent 3b2844328c
commit ff08a80af1
6 changed files with 77 additions and 112 deletions

View File

@ -57,9 +57,9 @@ int cmCPackDebGenerator::PackageOnePack(std::string const& initialTopLevel,
// Begin the archive for this pack // Begin the archive for this pack
std::string localToplevel(initialTopLevel); std::string localToplevel(initialTopLevel);
std::string packageFileName(cmSystemTools::GetParentDirectory(toplevel)); std::string packageFileName(cmSystemTools::GetParentDirectory(toplevel));
std::string outputFileName(std::string( std::string outputFileName(
this->GetOption("CPACK_PACKAGE_FILE_NAME")) + std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME")) + "-" +
"-" + packageName + this->GetOutputExtension()); packageName + this->GetOutputExtension());
localToplevel += "/" + packageName; localToplevel += "/" + packageName;
/* replace the TEMP DIRECTORY with the component one */ /* replace the TEMP DIRECTORY with the component one */
@ -174,9 +174,9 @@ int cmCPackDebGenerator::PackageComponentsAllInOne(
// The ALL GROUPS in ONE package case // The ALL GROUPS in ONE package case
std::string localToplevel(initialTopLevel); std::string localToplevel(initialTopLevel);
std::string packageFileName(cmSystemTools::GetParentDirectory(toplevel)); std::string packageFileName(cmSystemTools::GetParentDirectory(toplevel));
std::string outputFileName(std::string( std::string outputFileName(
this->GetOption("CPACK_PACKAGE_FILE_NAME")) + std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME")) +
this->GetOutputExtension()); this->GetOutputExtension());
// all GROUP in one vs all COMPONENT in one // all GROUP in one vs all COMPONENT in one
localToplevel += "/" + compInstDirName; localToplevel += "/" + compInstDirName;

View File

@ -125,7 +125,7 @@ cmCPackGeneratorFactory::cmCPackGeneratorFactory()
} }
if (cmCPackProductBuildGenerator::CanGenerate()) { if (cmCPackProductBuildGenerator::CanGenerate()) {
this->RegisterGenerator("productbuild", "Mac OSX pkg", this->RegisterGenerator("productbuild", "Mac OSX pkg",
cmCPackProductBuildGenerator::CreateGenerator); cmCPackProductBuildGenerator::CreateGenerator);
} }
#endif #endif
#if !defined(_WIN32) && !defined(__QNXNTO__) && !defined(__BEOS__) && \ #if !defined(_WIN32) && !defined(__QNXNTO__) && !defined(__BEOS__) && \

View File

@ -11,17 +11,17 @@
============================================================================*/ ============================================================================*/
#include "cmCPackPKGGenerator.h" #include "cmCPackPKGGenerator.h"
#include "cmake.h"
#include "cmGlobalGenerator.h"
#include "cmLocalGenerator.h"
#include "cmSystemTools.h"
#include "cmMakefile.h"
#include "cmGeneratedFileStream.h"
#include "cmCPackComponentGroup.h" #include "cmCPackComponentGroup.h"
#include "cmCPackLog.h" #include "cmCPackLog.h"
#include "cmGeneratedFileStream.h"
#include "cmGlobalGenerator.h"
#include "cmLocalGenerator.h"
#include "cmMakefile.h"
#include "cmSystemTools.h"
#include "cmake.h"
#include <cmsys/SystemTools.hxx>
#include <cmsys/Glob.hxx> #include <cmsys/Glob.hxx>
#include <cmsys/SystemTools.hxx>
cmCPackPKGGenerator::cmCPackPKGGenerator() cmCPackPKGGenerator::cmCPackPKGGenerator()
{ {
@ -39,13 +39,12 @@ bool cmCPackPKGGenerator::SupportsComponentInstallation() const
int cmCPackPKGGenerator::InitializeInternal() int cmCPackPKGGenerator::InitializeInternal()
{ {
cmCPackLogger(cmCPackLog::LOG_DEBUG, cmCPackLogger(cmCPackLog::LOG_DEBUG, "cmCPackPKGGenerator::Initialize()"
"cmCPackPKGGenerator::Initialize()" << std::endl); << std::endl);
return this->Superclass::InitializeInternal(); return this->Superclass::InitializeInternal();
} }
std::string cmCPackPKGGenerator::GetPackageName( std::string cmCPackPKGGenerator::GetPackageName(
const cmCPackComponent& component) const cmCPackComponent& component)
{ {
@ -53,16 +52,15 @@ std::string cmCPackPKGGenerator::GetPackageName(
std::string packagesDir = this->GetOption("CPACK_TEMPORARY_DIRECTORY"); std::string packagesDir = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
packagesDir += ".dummy"; packagesDir += ".dummy";
std::ostringstream out; std::ostringstream out;
out << cmSystemTools::GetFilenameWithoutLastExtension(packagesDir) out << cmSystemTools::GetFilenameWithoutLastExtension(packagesDir) << "-"
<< "-" << component.Name << ".pkg"; << component.Name << ".pkg";
return out.str(); return out.str();
} else { } else {
return component.ArchiveFile + ".pkg"; return component.ArchiveFile + ".pkg";
} }
} }
void cmCPackPKGGenerator::WriteDistributionFile( void cmCPackPKGGenerator::WriteDistributionFile(const char* metapackageFile)
const char* metapackageFile)
{ {
std::string distributionTemplate = std::string distributionTemplate =
this->FindTemplate("CPack.distribution.dist.in"); this->FindTemplate("CPack.distribution.dist.in");
@ -144,8 +142,8 @@ void cmCPackPKGGenerator::CreateChoiceOutline(
out << "</line>" << std::endl; out << "</line>" << std::endl;
} }
void cmCPackPKGGenerator::CreateChoice( void cmCPackPKGGenerator::CreateChoice(const cmCPackComponentGroup& group,
const cmCPackComponentGroup& group, std::ostringstream& out) std::ostringstream& out)
{ {
out << "<choice id=\"" << group.Name << "Choice\" " out << "<choice id=\"" << group.Name << "Choice\" "
<< "title=\"" << group.DisplayName << "\" " << "title=\"" << group.DisplayName << "\" "
@ -158,8 +156,8 @@ void cmCPackPKGGenerator::CreateChoice(
out << "></choice>" << std::endl; out << "></choice>" << std::endl;
} }
void cmCPackPKGGenerator::CreateChoice( void cmCPackPKGGenerator::CreateChoice(const cmCPackComponent& component,
const cmCPackComponent& component, std::ostringstream& out) std::ostringstream& out)
{ {
std::string packageId = "com."; std::string packageId = "com.";
packageId += this->GetOption("CPACK_PACKAGE_VENDOR"); packageId += this->GetOption("CPACK_PACKAGE_VENDOR");
@ -277,8 +275,8 @@ std::string cmCPackPKGGenerator::EscapeForXML(std::string str)
return str; return str;
} }
bool cmCPackPKGGenerator::CopyCreateResourceFile( bool cmCPackPKGGenerator::CopyCreateResourceFile(const std::string& name,
const std::string& name, const std::string& dirName) const std::string& dirName)
{ {
std::string uname = cmSystemTools::UpperCase(name); std::string uname = cmSystemTools::UpperCase(name);
std::string cpackVar = "CPACK_RESOURCE_FILE_" + uname; std::string cpackVar = "CPACK_RESOURCE_FILE_" + uname;
@ -323,8 +321,8 @@ bool cmCPackPKGGenerator::CopyCreateResourceFile(
return true; return true;
} }
bool cmCPackPKGGenerator::CopyResourcePlistFile( bool cmCPackPKGGenerator::CopyResourcePlistFile(const std::string& name,
const std::string& name, const char* outName) const char* outName)
{ {
if (!outName) { if (!outName) {
outName = name.c_str(); outName = name.c_str();

View File

@ -13,7 +13,6 @@
#ifndef cmCPackPKGGenerator_h #ifndef cmCPackPKGGenerator_h
#define cmCPackPKGGenerator_h #define cmCPackPKGGenerator_h
#include "cmCPackGenerator.h" #include "cmCPackGenerator.h"
class cmCPackComponent; class cmCPackComponent;
@ -97,7 +96,6 @@ protected:
// The PostFlight component when creating a metapackage // The PostFlight component when creating a metapackage
cmCPackComponent PostFlightComponent; cmCPackComponent PostFlightComponent;
}; };
#endif #endif

View File

@ -11,17 +11,17 @@
============================================================================*/ ============================================================================*/
#include "cmCPackProductBuildGenerator.h" #include "cmCPackProductBuildGenerator.h"
#include "cmake.h"
#include "cmGlobalGenerator.h"
#include "cmLocalGenerator.h"
#include "cmSystemTools.h"
#include "cmMakefile.h"
#include "cmGeneratedFileStream.h"
#include "cmCPackComponentGroup.h" #include "cmCPackComponentGroup.h"
#include "cmCPackLog.h" #include "cmCPackLog.h"
#include "cmGeneratedFileStream.h"
#include "cmGlobalGenerator.h"
#include "cmLocalGenerator.h"
#include "cmMakefile.h"
#include "cmSystemTools.h"
#include "cmake.h"
#include <cmsys/SystemTools.hxx>
#include <cmsys/Glob.hxx> #include <cmsys/Glob.hxx>
#include <cmsys/SystemTools.hxx>
cmCPackProductBuildGenerator::cmCPackProductBuildGenerator() cmCPackProductBuildGenerator::cmCPackProductBuildGenerator()
{ {
@ -37,56 +37,47 @@ int cmCPackProductBuildGenerator::PackageFiles()
// TODO: Use toplevel // TODO: Use toplevel
// It is used! Is this an obsolete comment? // It is used! Is this an obsolete comment?
std::string packageDirFileName std::string packageDirFileName =
= this->GetOption("CPACK_TEMPORARY_DIRECTORY"); this->GetOption("CPACK_TEMPORARY_DIRECTORY");
// Create the directory where component packages will be built. // Create the directory where component packages will be built.
std::string basePackageDir = packageDirFileName; std::string basePackageDir = packageDirFileName;
basePackageDir += "/Contents/Packages"; basePackageDir += "/Contents/Packages";
if (!cmsys::SystemTools::MakeDirectory(basePackageDir.c_str())) if (!cmsys::SystemTools::MakeDirectory(basePackageDir.c_str())) {
{
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,
"Problem creating component packages directory: " "Problem creating component packages directory: "
<< basePackageDir << std::endl); << basePackageDir << std::endl);
return 0; return 0;
} }
if (!this->Components.empty()) if (!this->Components.empty()) {
{
std::map<std::string, cmCPackComponent>::iterator compIt; std::map<std::string, cmCPackComponent>::iterator compIt;
for (compIt = this->Components.begin(); compIt != this->Components.end(); for (compIt = this->Components.begin(); compIt != this->Components.end();
++compIt) ++compIt) {
{
std::string packageDir = toplevel; std::string packageDir = toplevel;
packageDir += '/'; packageDir += '/';
packageDir += compIt->first; packageDir += compIt->first;
if (!this->GenerateComponentPackage(basePackageDir, if (!this->GenerateComponentPackage(basePackageDir,
GetPackageName(compIt->second), GetPackageName(compIt->second),
packageDir, packageDir, &compIt->second)) {
&compIt->second))
{
return 0; return 0;
}
} }
} }
else } else {
{ if (!this->GenerateComponentPackage(basePackageDir,
if(!this->GenerateComponentPackage(basePackageDir, this->GetOption("CPACK_PACKAGE_NAME"),
this->GetOption("CPACK_PACKAGE_NAME"), toplevel, NULL)) {
toplevel, NULL))
{
return 0; return 0;
} }
} }
// Copy or create all of the resource files we need. // Copy or create all of the resource files we need.
std::string resDir = packageDirFileName + "/Contents"; std::string resDir = packageDirFileName + "/Contents";
if ( !this->CopyCreateResourceFile("License", resDir.c_str()) if (!this->CopyCreateResourceFile("License", resDir.c_str()) ||
|| !this->CopyCreateResourceFile("ReadMe", resDir.c_str()) !this->CopyCreateResourceFile("ReadMe", resDir.c_str()) ||
|| !this->CopyCreateResourceFile("Welcome", resDir.c_str())) !this->CopyCreateResourceFile("Welcome", resDir.c_str())) {
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem copying the resource files" cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem copying the resource files"
<< std::endl); << std::endl);
return 0; return 0;
} }
@ -97,13 +88,13 @@ int cmCPackProductBuildGenerator::PackageFiles()
std::string version = this->GetOption("CPACK_PACKAGE_VERSION"); std::string version = this->GetOption("CPACK_PACKAGE_VERSION");
std::string productbuild = this->GetOption("CPACK_COMMAND_PRODUCTBUILD"); std::string productbuild = this->GetOption("CPACK_COMMAND_PRODUCTBUILD");
pkgCmd << productbuild pkgCmd << productbuild << " --distribution \"" << packageDirFileName
<< " --distribution \"" << packageDirFileName << "/Contents/distribution.dist\""
<< "/Contents/distribution.dist\"" << " --package-path \"" << packageDirFileName << "/Contents/Packages"
<< " --package-path \"" << packageDirFileName << "/Contents/Packages" << "\"" << "\""
<< " --resources \"" << resDir << "\"" << " --resources \"" << resDir << "\""
<< " --version \"" << version << "\"" << " --version \"" << version << "\""
<< " \"" << packageFileNames[0] << "\""; << " \"" << packageFileNames[0] << "\"";
// Run ProductBuild // Run ProductBuild
return RunProductBuild(pkgCmd.str()); return RunProductBuild(pkgCmd.str());
@ -123,7 +114,6 @@ int cmCPackProductBuildGenerator::InitializeInternal()
} }
this->SetOptionIfNotSet("CPACK_COMMAND_PKGBUILD", program.c_str()); this->SetOptionIfNotSet("CPACK_COMMAND_PKGBUILD", program.c_str());
program = cmSystemTools::FindProgram("productbuild", no_paths, false); program = cmSystemTools::FindProgram("productbuild", no_paths, false);
if (program.empty()) { if (program.empty()) {
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find productbuild executable" cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find productbuild executable"
@ -135,9 +125,7 @@ int cmCPackProductBuildGenerator::InitializeInternal()
return this->Superclass::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"); std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
tmpFile += "/ProductBuildOutput.log"; tmpFile += "/ProductBuildOutput.log";
@ -145,12 +133,11 @@ bool cmCPackProductBuildGenerator::RunProductBuild(
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << command << std::endl); cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << command << std::endl);
std::string output, error_output; std::string output, error_output;
int retVal = 1; int retVal = 1;
bool res = cmSystemTools::RunSingleCommand(command.c_str(), bool res =
&output, &error_output, &retVal, 0, this->GeneratorVerbose, 0); cmSystemTools::RunSingleCommand(command.c_str(), &output, &error_output,
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Done running command" &retVal, 0, this->GeneratorVerbose, 0);
<< std::endl); cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Done running command" << std::endl);
if ( !res || retVal ) if (!res || retVal) {
{
cmGeneratedFileStream ofs(tmpFile.c_str()); cmGeneratedFileStream ofs(tmpFile.c_str());
ofs << "# Run command: " << command << std::endl ofs << "# Run command: " << command << std::endl
<< "# Output:" << std::endl << "# Output:" << std::endl
@ -160,23 +147,20 @@ bool cmCPackProductBuildGenerator::RunProductBuild(
<< "Please check " << tmpFile << "Please check " << tmpFile
<< " for errors" << std::endl); << " for errors" << std::endl);
return false; return false;
} }
return true; return true;
} }
bool cmCPackProductBuildGenerator::GenerateComponentPackage( bool cmCPackProductBuildGenerator::GenerateComponentPackage(
const std::string& packageFileDir, const std::string& packageFileDir, const std::string& packageFileName,
const std::string& packageFileName, const std::string& packageDir, const cmCPackComponent* component)
const std::string& packageDir,
const cmCPackComponent* component)
{ {
std::string packageFile = packageFileDir; std::string packageFile = packageFileDir;
packageFile += '/'; packageFile += '/';
packageFile += packageFileName; packageFile += packageFileName;
cmCPackLogger(cmCPackLog::LOG_OUTPUT, cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Building component package: "
"- Building component package: " << << packageFile << std::endl);
packageFile << std::endl);
const char* comp_name = component ? component->Name.c_str() : NULL; 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); const char* postflight = this->GetComponentScript("POSTFLIGHT", comp_name);
std::string resDir = packageFileDir; std::string resDir = packageFileDir;
if(component) if (component) {
{
resDir += "/"; resDir += "/";
resDir += component->Name; resDir += component->Name;
} }
std::string scriptDir = resDir + "/scripts"; std::string scriptDir = resDir + "/scripts";
if ( !cmsys::SystemTools::MakeDirectory(scriptDir.c_str())) if (!cmsys::SystemTools::MakeDirectory(scriptDir.c_str())) {
{
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,
"Problem creating installer directory: " << scriptDir "Problem creating installer directory: " << scriptDir
<< std::endl); << std::endl);
@ -202,20 +184,13 @@ bool cmCPackProductBuildGenerator::GenerateComponentPackage(
// if preflight, postflight, or postupgrade are set // if preflight, postflight, or postupgrade are set
// then copy them into the script directory and make // then copy them into the script directory and make
// them executable // them executable
if(preflight) if (preflight) {
{ this->CopyInstallScript(scriptDir.c_str(), preflight, "preinstall");
this->CopyInstallScript(scriptDir.c_str(),
preflight,
"preinstall");
} }
if(postflight) if (postflight) {
{ this->CopyInstallScript(scriptDir.c_str(), postflight, "postinstall");
this->CopyInstallScript(scriptDir.c_str(),
postflight,
"postinstall");
} }
// The command that will be used to run ProductBuild // The command that will be used to run ProductBuild
std::ostringstream pkgCmd; std::ostringstream pkgCmd;
@ -223,17 +198,15 @@ bool cmCPackProductBuildGenerator::GenerateComponentPackage(
pkgId += this->GetOption("CPACK_PACKAGE_VENDOR"); pkgId += this->GetOption("CPACK_PACKAGE_VENDOR");
pkgId += '.'; pkgId += '.';
pkgId += this->GetOption("CPACK_PACKAGE_NAME"); pkgId += this->GetOption("CPACK_PACKAGE_NAME");
if(component) if (component) {
{
pkgId += '.'; pkgId += '.';
pkgId += component->Name; pkgId += component->Name;
} }
std::string version = this->GetOption("CPACK_PACKAGE_VERSION"); std::string version = this->GetOption("CPACK_PACKAGE_VERSION");
std::string pkgbuild = this->GetOption("CPACK_COMMAND_PKGBUILD"); std::string pkgbuild = this->GetOption("CPACK_COMMAND_PKGBUILD");
pkgCmd << pkgbuild pkgCmd << pkgbuild << " --root \"" << packageDir << "\""
<< " --root \"" << packageDir << "\""
<< " --identifier \"" << pkgId << "\"" << " --identifier \"" << pkgId << "\""
<< " --scripts \"" << scriptDir << "\"" << " --scripts \"" << scriptDir << "\""
<< " --version \"" << version << "\"" << " --version \"" << version << "\""
@ -245,12 +218,10 @@ bool cmCPackProductBuildGenerator::GenerateComponentPackage(
} }
const char* cmCPackProductBuildGenerator::GetComponentScript( const char* cmCPackProductBuildGenerator::GetComponentScript(
const char* script, const char* script, const char* component_name)
const char* component_name)
{ {
std::string scriptname = std::string("CPACK_") + script + "_"; std::string scriptname = std::string("CPACK_") + script + "_";
if(component_name) if (component_name) {
{
scriptname += cmSystemTools::UpperCase(component_name); scriptname += cmSystemTools::UpperCase(component_name);
scriptname += "_"; scriptname += "_";
} }

View File

@ -13,7 +13,6 @@
#ifndef cmCPackProductBuildGenerator_h #ifndef cmCPackProductBuildGenerator_h
#define cmCPackProductBuildGenerator_h #define cmCPackProductBuildGenerator_h
#include "cmCPackPKGGenerator.h" #include "cmCPackPKGGenerator.h"
class cmCPackComponent; class cmCPackComponent;
@ -54,7 +53,6 @@ protected:
const char* GetComponentScript(const char* script, const char* GetComponentScript(const char* script,
const char* script_component); const char* script_component);
}; };
#endif #endif