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.
This commit is contained in:
parent
148b528f9d
commit
64a5e20999
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,41 +1294,64 @@ 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue