Merge topic 'CPack-ChangeComponentNamingScheme'

3fb89cf CPack remove previously CPack generated files (if any) before running CPack
f2ab270 CPack  fix KWStyle warning
4deb308 CPack Authorize DISPLAY_NAME usage in component package
8c450f6 CPack remove "-ALL" suffix for ALL-IN-ONE packages
This commit is contained in:
Brad King 2011-03-01 15:30:14 -05:00 committed by CMake Topic Stage
commit b5b4aa2f71
5 changed files with 94 additions and 24 deletions

View File

@ -121,9 +121,11 @@ int cmCPackArchiveGenerator::PackageComponents(bool ignoreGroup)
<< std::endl);
// Begin the archive for this group
std::string packageFileName= std::string(toplevel);
packageFileName += "/"
+std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME"))
+"-"+compGIt->first + this->GetOutputExtension();
packageFileName += "/"+
GetComponentPackageFileName(this->GetOption("CPACK_PACKAGE_FILE_NAME"),
compGIt->first,
true)
+ this->GetOutputExtension();
// open a block in order to automatically close archive
// at the end of the block
{
@ -154,9 +156,11 @@ int cmCPackArchiveGenerator::PackageComponents(bool ignoreGroup)
std::string packageFileName = std::string(toplevel);
localToplevel += "/"+ compIt->first;
packageFileName += "/"
+std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME"))
+"-"+compIt->first + this->GetOutputExtension();
packageFileName += "/"+
GetComponentPackageFileName(this->GetOption("CPACK_PACKAGE_FILE_NAME"),
compIt->first,
false)
+ this->GetOutputExtension();
{
DECLARE_AND_OPEN_ARCHIVE(packageFileName,archive);
// Add the files of this component to the archive
@ -177,7 +181,7 @@ int cmCPackArchiveGenerator::PackageComponentsAllInOne(bool allComponent)
packageFileNames.push_back(std::string(toplevel));
packageFileNames[0] += "/"
+std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME"))
+"-ALL" + this->GetOutputExtension();
+ this->GetOutputExtension();
cmCPackLogger(cmCPackLog::LOG_VERBOSE,
"Packaging all groups in one package..."
"(CPACK_COMPONENTS_ALL_GROUPS_IN_ONE_PACKAGE is set)"

View File

@ -1309,10 +1309,51 @@ int cmCPackGenerator::PrepareGroupingKind()
return 1;
}
//----------------------------------------------------------------------
std::string cmCPackGenerator::GetComponentInstallDirNameSuffix(
const std::string& componentName) {
return componentName;
}
//----------------------------------------------------------------------
std::string cmCPackGenerator::GetComponentPackageFileName(
const std::string& initialPackageFileName,
const std::string& groupOrComponentName,
bool isGroupName) {
/*
* the default behavior is to use the
* component [group] name as a suffix
*/
std::string suffix="-"+groupOrComponentName;
/* check if we should use DISPLAY name */
std::string dispNameVar = "CPACK_"+Name+"_USE_DISPLAY_NAME_IN_FILENAME";
if (IsOn(dispNameVar.c_str()))
{
/* the component Group case */
if (isGroupName)
{
std::string groupDispVar = "CPACK_COMPONENT_GROUP_"
+ cmSystemTools::UpperCase(groupOrComponentName) + "_DISPLAY_NAME";
const char* groupDispName = GetOption(groupDispVar.c_str());
if (groupDispName)
{
suffix = "-"+std::string(groupDispName);
}
}
/* the [single] component case */
else
{
std::string dispVar = "CPACK_COMPONENT_"
+ cmSystemTools::UpperCase(groupOrComponentName) + "_DISPLAY_NAME";
const char* dispName = GetOption(dispVar.c_str());
if(dispName)
{
suffix = "-"+std::string(dispName);
}
}
}
return initialPackageFileName + suffix;
}
//----------------------------------------------------------------------
bool cmCPackGenerator::SupportsComponentInstallation() const

View File

@ -144,6 +144,19 @@ protected:
virtual std::string GetComponentInstallDirNameSuffix(
const std::string& componentName);
/**
* CPack specific generator may mangle CPACK_PACKAGE_FILE_NAME
* with CPACK_COMPONENT_xxxx_<NAME>_DISPLAY_NAME if
* CPACK_<GEN>_USE_DISPLAY_NAME_IN_FILENAME is ON.
* @param[in] initialPackageFileName
* @param[in] groupOrComponentName
* @param[in] isGroupName
*/
virtual std::string GetComponentPackageFileName(
const std::string& initialPackageFileName,
const std::string& groupOrComponentName,
bool isGroupName);
/**
* Package the list of files and/or components which
* has been prepared by the beginning of DoPackage.

View File

@ -75,8 +75,10 @@ int cmCPackRPMGenerator::PackageComponents(bool ignoreGroup)
cmSystemTools::GetParentDirectory(toplevel.c_str())
);
std::string outputFileName(
std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME"))
+"-"+compGIt->first + this->GetOutputExtension()
GetComponentPackageFileName(this->GetOption("CPACK_PACKAGE_FILE_NAME"),
compGIt->first,
true)
+ this->GetOutputExtension()
);
localToplevel += "/"+ compGIt->first;
@ -113,9 +115,10 @@ int cmCPackRPMGenerator::PackageComponents(bool ignoreGroup)
cmSystemTools::GetParentDirectory(toplevel.c_str())
);
std::string outputFileName(
std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME")
)
+"-"+compIt->first + this->GetOutputExtension());
GetComponentPackageFileName(this->GetOption("CPACK_PACKAGE_FILE_NAME"),
compIt->first,
false)
+ this->GetOutputExtension());
localToplevel += "/"+ compIt->first;
/* replace the TEMP DIRECTORY with the component one */
@ -173,7 +176,7 @@ int cmCPackRPMGenerator::PackageComponentsAllInOne(bool allComponent)
);
std::string outputFileName(
std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME"))
+"-ALL"+ this->GetOutputExtension()
+ this->GetOutputExtension()
);
// all GROUP in one vs all COMPONENT in one
localToplevel += "/"+compInstDirName;

View File

@ -32,17 +32,6 @@ if(config_type)
set(config_args -C ${config_type})
endif()
message(" ${config_args}")
execute_process(COMMAND ${CPackCommand} -G ${CPackGen} ${config_args}
RESULT_VARIABLE CPack_result
OUTPUT_VARIABLE CPack_output
ERROR_VARIABLE CPack_error
WORKING_DIRECTORY ${CPackComponentsForAll_BINARY_DIR})
if (CPack_result)
message(FATAL_ERROR "error: CPack execution went wrong!, CPack_output=${CPack_output}, CPack_error=${CPack_error}")
else (CPack_result)
message(STATUS "CPack_output=${CPack_output}")
endif(CPack_result)
if(CPackGen MATCHES "ZIP")
set(expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/MyLib-*.zip")
@ -63,6 +52,26 @@ if(CPackGen MATCHES "ZIP")
endif (${CPackComponentWay} STREQUAL "AllGroupsInOne")
endif(CPackGen MATCHES "ZIP")
# clean-up previously CPack generated files
if(expected_file_mask)
file(GLOB expected_file "${expected_file_mask}")
if (expected_file)
file(REMOVE ${expected_file})
endif(expected_file)
endif(expected_file_mask)
execute_process(COMMAND ${CPackCommand} -G ${CPackGen} ${config_args}
RESULT_VARIABLE CPack_result
OUTPUT_VARIABLE CPack_output
ERROR_VARIABLE CPack_error
WORKING_DIRECTORY ${CPackComponentsForAll_BINARY_DIR})
if (CPack_result)
message(FATAL_ERROR "error: CPack execution went wrong!, CPack_output=${CPack_output}, CPack_error=${CPack_error}")
else (CPack_result)
message(STATUS "CPack_output=${CPack_output}")
endif(CPack_result)
# Now verify if the number of expected file is OK
# - using expected_file_mask and
# - expected_count