summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClinton Stimpson <clinton@elemtech.com>2011-03-25 16:18:59 (GMT)
committerBrad King <brad.king@kitware.com>2011-03-31 17:33:03 (GMT)
commit64a5e209998f12662a56346f855b1973cbbd0440 (patch)
tree7c4c071ee6ae358399d0ddfb7ea2b058826d20ca
parent148b528f9d7d991dc01f277624df4a8aa41feccc (diff)
downloadCMake-64a5e209998f12662a56346f855b1973cbbd0440.zip
CMake-64a5e209998f12662a56346f855b1973cbbd0440.tar.gz
CMake-64a5e209998f12662a56346f855b1973cbbd0440.tar.bz2
Combine component packaging methods into an enum.
Also allow generators to override the default packaging method. Add a ONE_PER_GROUP option so that method can be specified by the user without relying on defaults.
-rw-r--r--Source/CPack/cmCPackArchiveGenerator.cxx4
-rw-r--r--Source/CPack/cmCPackDebGenerator.cxx8
-rw-r--r--Source/CPack/cmCPackGenerator.cxx83
-rw-r--r--Source/CPack/cmCPackGenerator.h26
-rw-r--r--Source/CPack/cmCPackRPMGenerator.cxx8
5 files changed, 86 insertions, 43 deletions
diff --git a/Source/CPack/cmCPackArchiveGenerator.cxx b/Source/CPack/cmCPackArchiveGenerator.cxx
index 55d9890..5b4625b 100644
--- a/Source/CPack/cmCPackArchiveGenerator.cxx
+++ b/Source/CPack/cmCPackArchiveGenerator.cxx
@@ -244,7 +244,7 @@ int cmCPackArchiveGenerator::PackageFiles()
// CASE 1 : COMPONENT ALL-IN-ONE package
// If ALL COMPONENTS in ONE package has been requested
// then the package file is unique and should be open here.
- if (allComponentInOne)
+ if (componentPackageMethod == ONE_PACKAGE)
{
return PackageComponentsAllInOne();
}
@@ -254,7 +254,7 @@ int cmCPackArchiveGenerator::PackageFiles()
// in this case you'll get 1 package for each component.
else
{
- return PackageComponents(ignoreComponentGroup);
+ return PackageComponents(componentPackageMethod == ONE_PACKAGE_PER_COMPONENT);
}
}
diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx
index 82038e9..582f3e6 100644
--- a/Source/CPack/cmCPackDebGenerator.cxx
+++ b/Source/CPack/cmCPackDebGenerator.cxx
@@ -240,7 +240,7 @@ int cmCPackDebGenerator::PackageFiles()
// CASE 1 : COMPONENT ALL-IN-ONE package
// If ALL GROUPS or ALL COMPONENTS in ONE package has been requested
// then the package file is unique and should be open here.
- if (allComponentInOne)
+ if (componentPackageMethod == ONE_PACKAGE)
{
return PackageComponentsAllInOne();
}
@@ -250,7 +250,7 @@ int cmCPackDebGenerator::PackageFiles()
// in this case you'll get 1 package for each component.
else
{
- return PackageComponents(ignoreComponentGroup);
+ return PackageComponents(componentPackageMethod == ONE_PACKAGE_PER_COMPONENT);
}
}
// CASE 3 : NON COMPONENT package.
@@ -560,11 +560,11 @@ bool cmCPackDebGenerator::SupportsComponentInstallation() const
std::string cmCPackDebGenerator::GetComponentInstallDirNameSuffix(
const std::string& componentName)
{
- if (ignoreComponentGroup) {
+ if (componentPackageMethod == ONE_PACKAGE_PER_COMPONENT) {
return componentName;
}
- if (allComponentInOne) {
+ if (componentPackageMethod == ONE_PACKAGE) {
return std::string("ALL_COMPONENTS_IN_ONE");
}
// We have to find the name of the COMPONENT GROUP
diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx
index 691092f..6d71ad2 100644
--- a/Source/CPack/cmCPackGenerator.cxx
+++ b/Source/CPack/cmCPackGenerator.cxx
@@ -36,8 +36,7 @@ cmCPackGenerator::cmCPackGenerator()
this->GeneratorVerbose = false;
this->MakefileMap = 0;
this->Logger = 0;
- this->allComponentInOne = false;
- this->ignoreComponentGroup = false;
+ this->componentPackageMethod = ONE_PACKAGE_PER_GROUP;
}
//----------------------------------------------------------------------
@@ -1263,14 +1262,23 @@ int cmCPackGenerator::CleanTemporaryDirectory()
//----------------------------------------------------------------------
int cmCPackGenerator::PrepareGroupingKind()
{
- // The default behavior is to create 1 package by component group
- // unless the user asked to put all COMPONENTS in a single package
- allComponentInOne = (NULL != (this->GetOption(
- "CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE"))
- );
- ignoreComponentGroup = (NULL != (this->GetOption(
- "CPACK_COMPONENTS_IGNORE_GROUPS"))
- );
+ // find a component package method specified by the user
+ ComponentPackageMethod method = UNKNOWN_COMPONENT_PACKAGE_METHOD;
+
+ if(this->GetOption("CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE"))
+ {
+ method = ONE_PACKAGE;
+ }
+
+ if(this->GetOption("CPACK_COMPONENTS_IGNORE_GROUPS"))
+ {
+ method = ONE_PACKAGE_PER_COMPONENT;
+ }
+
+ if(this->GetOption("CPACK_COMPONENTS_ONE_PACKAGE_PER_GROUP"))
+ {
+ method = ONE_PACKAGE_PER_GROUP;
+ }
std::string groupingType;
@@ -1286,40 +1294,63 @@ int cmCPackGenerator::PrepareGroupingKind()
<< " requested component grouping = "<< groupingType <<std::endl);
if (groupingType == "ALL_COMPONENTS_IN_ONE")
{
- allComponentInOne = true;
+ method = ONE_PACKAGE;
}
else if (groupingType == "IGNORE")
{
- ignoreComponentGroup = true;
+ method = ONE_PACKAGE_PER_COMPONENT;
+ }
+ else if (groupingType == "ONE_PER_GROUP")
+ {
+ method = ONE_PACKAGE_PER_GROUP;
}
else
{
cmCPackLogger(cmCPackLog::LOG_WARNING, "["
<< this->Name << "]"
<< " requested component grouping type <"<< groupingType
- << "> UNKNOWN not in (ALL_COMPONENTS_IN_ONE,IGNORE)"
+ << "> UNKNOWN not in (ALL_COMPONENTS_IN_ONE,IGNORE,ONE_PER_GROUP)"
<< std::endl);
}
}
- cmCPackLogger(cmCPackLog::LOG_VERBOSE, "["
- << this->Name << "]"
- << " requested component grouping = ("
- << ", ALL_COMPONENTS_IN_ONE=" << allComponentInOne
- << ", IGNORE_GROUPS=" << ignoreComponentGroup
- << ")"
- << std::endl);
// Some components were defined but NO group
- // force ignoreGroups
- if (this->ComponentGroups.empty() && (!this->Components.empty())
- && (!ignoreComponentGroup)) {
+ // fallback to default if not group based
+ if(method == ONE_PACKAGE_PER_GROUP &&
+ this->ComponentGroups.empty() && !this->Components.empty())
+ {
+ if(componentPackageMethod == ONE_PACKAGE)
+ {
+ method = ONE_PACKAGE;
+ }
+ else
+ {
+ method = ONE_PACKAGE_PER_COMPONENT;
+ }
cmCPackLogger(cmCPackLog::LOG_WARNING, "["
<< this->Name << "]"
- << " Some Components defined but NO component group:"
+ << " One package per component group requested, but NO component groups exist:"
<< " Ignoring component group."
<< std::endl);
- ignoreComponentGroup = true;
- }
+ }
+
+ // if user specified packaging method, override the default packaging method
+ if(method != UNKNOWN_COMPONENT_PACKAGE_METHOD)
+ {
+ componentPackageMethod = method;
+ }
+
+ const char* method_names[] =
+ {
+ "ALL_COMPONENTS_IN_ONE",
+ "IGNORE_GROUPS",
+ "ONE_PER_GROUP"
+ };
+
+ cmCPackLogger(cmCPackLog::LOG_VERBOSE, "["
+ << this->Name << "]"
+ << " requested component grouping = " << method_names[componentPackageMethod]
+ << std::endl);
return 1;
}
diff --git a/Source/CPack/cmCPackGenerator.h b/Source/CPack/cmCPackGenerator.h
index 9549d0b..f09c2a7 100644
--- a/Source/CPack/cmCPackGenerator.h
+++ b/Source/CPack/cmCPackGenerator.h
@@ -125,7 +125,7 @@ protected:
* CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE
* CPACK_COMPONENTS_IGNORE_GROUPS
* or
- * CPACK_COMPONENTS_GROUPING
+ * CPACK_COMPONENTS_ONE_PACKAGE_PER_GROUP
* @return 1 on success 0 on failure.
*/
virtual int PrepareGroupingKind();
@@ -237,16 +237,28 @@ protected:
*/
std::map<std::string, cmCPackComponent> Components;
std::map<std::string, cmCPackComponentGroup> ComponentGroups;
+
/**
- * If true All component will be put in a single package.
+ * If components are enabled, this enum represents the different
+ * ways of mapping components to package files.
*/
- bool allComponentInOne;
+ enum ComponentPackageMethod
+ {
+ /* one package for all components */
+ ONE_PACKAGE,
+ /* one package for each component */
+ ONE_PACKAGE_PER_COMPONENT,
+ /* one package for each group, with left over components in their own package */
+ ONE_PACKAGE_PER_GROUP,
+ UNKNOWN_COMPONENT_PACKAGE_METHOD
+ };
+
/**
- * If true component grouping will be ignored.
- * You will still get 1 package for each component unless
- * allComponentInOne is true.
+ * The component package method
+ * The default is ONE_PACKAGE_PER_GROUP, and generators may override the default
+ * before PrepareGroupingKind() is called.
*/
- bool ignoreComponentGroup;
+ ComponentPackageMethod componentPackageMethod;
cmCPackLog* Logger;
private:
diff --git a/Source/CPack/cmCPackRPMGenerator.cxx b/Source/CPack/cmCPackRPMGenerator.cxx
index c926be6..9f55d23 100644
--- a/Source/CPack/cmCPackRPMGenerator.cxx
+++ b/Source/CPack/cmCPackRPMGenerator.cxx
@@ -205,7 +205,7 @@ int cmCPackRPMGenerator::PackageFiles()
// CASE 1 : COMPONENT ALL-IN-ONE package
// If ALL COMPONENTS in ONE package has been requested
// then the package file is unique and should be open here.
- if (allComponentInOne)
+ if (componentPackageMethod == ONE_PACKAGE)
{
return PackageComponentsAllInOne();
}
@@ -215,7 +215,7 @@ int cmCPackRPMGenerator::PackageFiles()
// in this case you'll get 1 package for each component.
else
{
- return PackageComponents(ignoreComponentGroup);
+ return PackageComponents(componentPackageMethod == ONE_PACKAGE_PER_COMPONENT);
}
}
// CASE 3 : NON COMPONENT package.
@@ -252,11 +252,11 @@ bool cmCPackRPMGenerator::SupportsComponentInstallation() const
std::string cmCPackRPMGenerator::GetComponentInstallDirNameSuffix(
const std::string& componentName)
{
- if (ignoreComponentGroup) {
+ if (componentPackageMethod == ONE_PACKAGE_PER_COMPONENT) {
return componentName;
}
- if (allComponentInOne) {
+ if (componentPackageMethod == ONE_PACKAGE) {
return std::string("ALL_COMPONENTS_IN_ONE");
}
// We have to find the name of the COMPONENT GROUP