From 4deb308e82b8f9e56ce41eba211f330ff66902a3 Mon Sep 17 00:00:00 2001 From: Eric NOULARD Date: Tue, 22 Feb 2011 23:49:49 +0100 Subject: [PATCH] CPack Authorize DISPLAY_NAME usage in component package Second (last) part fix of feature request #11814 --- Source/CPack/cmCPackArchiveGenerator.cxx | 16 +++++---- Source/CPack/cmCPackGenerator.cxx | 41 ++++++++++++++++++++++++ Source/CPack/cmCPackGenerator.h | 13 ++++++++ Source/CPack/cmCPackRPMGenerator.cxx | 13 +++++--- 4 files changed, 72 insertions(+), 11 deletions(-) diff --git a/Source/CPack/cmCPackArchiveGenerator.cxx b/Source/CPack/cmCPackArchiveGenerator.cxx index ff8841292..3c670a166 100644 --- a/Source/CPack/cmCPackArchiveGenerator.cxx +++ b/Source/CPack/cmCPackArchiveGenerator.cxx @@ -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 diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index 69d9b8ceb..4cb4f36f3 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -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 diff --git a/Source/CPack/cmCPackGenerator.h b/Source/CPack/cmCPackGenerator.h index d4b1b16ef..0497d1c86 100644 --- a/Source/CPack/cmCPackGenerator.h +++ b/Source/CPack/cmCPackGenerator.h @@ -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__DISPLAY_NAME if + * CPACK__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. diff --git a/Source/CPack/cmCPackRPMGenerator.cxx b/Source/CPack/cmCPackRPMGenerator.cxx index 995adf6f3..58039592c 100644 --- a/Source/CPack/cmCPackRPMGenerator.cxx +++ b/Source/CPack/cmCPackRPMGenerator.cxx @@ -60,8 +60,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; @@ -98,9 +100,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 */