diff options
author | Brad King <brad.king@kitware.com> | 2011-04-05 18:29:06 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2011-04-05 18:29:06 (GMT) |
commit | b7b9597b75ef44b4e7b03020aedfc2466be4dc89 (patch) | |
tree | 578a9bc68f1776baa51b2dfaff997aae2a9bfd85 /Source/CPack | |
parent | c90fa7c00c142d42067ce90c07d52c6d489fe815 (diff) | |
parent | dd04608132f6580df6fd857d5bfc4f67ad2b0ec3 (diff) | |
download | CMake-b7b9597b75ef44b4e7b03020aedfc2466be4dc89.zip CMake-b7b9597b75ef44b4e7b03020aedfc2466be4dc89.tar.gz CMake-b7b9597b75ef44b4e7b03020aedfc2466be4dc89.tar.bz2 |
Merge topic 'drag-n-drop-components'
dd04608 Fix KWStyle warnings
2973c1f Add component support to DragNDrop generator.
Diffstat (limited to 'Source/CPack')
-rw-r--r-- | Source/CPack/cmCPackBundleGenerator.cxx | 7 | ||||
-rw-r--r-- | Source/CPack/cmCPackBundleGenerator.h | 1 | ||||
-rw-r--r-- | Source/CPack/cmCPackDragNDropGenerator.cxx | 106 | ||||
-rw-r--r-- | Source/CPack/cmCPackDragNDropGenerator.h | 7 |
4 files changed, 114 insertions, 7 deletions
diff --git a/Source/CPack/cmCPackBundleGenerator.cxx b/Source/CPack/cmCPackBundleGenerator.cxx index 06a0509..af78e78 100644 --- a/Source/CPack/cmCPackBundleGenerator.cxx +++ b/Source/CPack/cmCPackBundleGenerator.cxx @@ -165,5 +165,10 @@ int cmCPackBundleGenerator::PackageFiles() cmSystemTools::SetPermissions(command_target.str().c_str(), 0777); } - return this->CreateDMG(); + return this->CreateDMG(toplevel, packageFileNames[0]); +} + +bool cmCPackBundleGenerator::SupportsComponentInstallation() const +{ + return false; } diff --git a/Source/CPack/cmCPackBundleGenerator.h b/Source/CPack/cmCPackBundleGenerator.h index 82814b0..ed0187d 100644 --- a/Source/CPack/cmCPackBundleGenerator.h +++ b/Source/CPack/cmCPackBundleGenerator.h @@ -32,6 +32,7 @@ protected: virtual int InitializeInternal(); virtual const char* GetPackagingInstallPrefix(); int PackageFiles(); + bool SupportsComponentInstallation() const; std::string InstallPrefix; }; diff --git a/Source/CPack/cmCPackDragNDropGenerator.cxx b/Source/CPack/cmCPackDragNDropGenerator.cxx index e9ce76c..83b6b64 100644 --- a/Source/CPack/cmCPackDragNDropGenerator.cxx +++ b/Source/CPack/cmCPackDragNDropGenerator.cxx @@ -51,6 +51,8 @@ static const char* SLASTREnglish = //---------------------------------------------------------------------- cmCPackDragNDropGenerator::cmCPackDragNDropGenerator() { + // default to one package file for components + this->componentPackageMethod = ONE_PACKAGE; } //---------------------------------------------------------------------- @@ -106,8 +108,57 @@ const char* cmCPackDragNDropGenerator::GetOutputExtension() //---------------------------------------------------------------------- int cmCPackDragNDropGenerator::PackageFiles() { + // gather which directories to make dmg files for + // multiple directories occur if packaging components or groups separately - return this->CreateDMG(); + // monolith + if(this->Components.empty()) + { + return this->CreateDMG(toplevel, packageFileNames[0]); + } + + // component install + std::vector<std::string> package_files; + + std::map<std::string, cmCPackComponent>::iterator compIt; + for (compIt=this->Components.begin(); + compIt!=this->Components.end(); ++compIt ) + { + std::string name = GetComponentInstallDirNameSuffix(compIt->first); + package_files.push_back(name); + } + std::sort(package_files.begin(), package_files.end()); + package_files.erase(std::unique(package_files.begin(), + package_files.end()), + package_files.end()); + + + // loop to create dmg files + packageFileNames.clear(); + for(size_t i=0; i<package_files.size(); i++) + { + std::string full_package_name = std::string(toplevel) + std::string("/"); + if(package_files[i] == "ALL_IN_ONE") + { + full_package_name += this->GetOption("CPACK_PACKAGE_FILE_NAME"); + } + else + { + full_package_name += package_files[i]; + } + full_package_name += std::string(GetOutputExtension()); + packageFileNames.push_back(full_package_name); + + std::string src_dir = toplevel; + src_dir += "/"; + src_dir += package_files[i]; + + if(0 == this->CreateDMG(src_dir, full_package_name)) + { + return 0; + } + } + return 1; } //---------------------------------------------------------------------- @@ -159,10 +210,11 @@ bool cmCPackDragNDropGenerator::RunCommand(cmOStringStream& command, } //---------------------------------------------------------------------- -int cmCPackDragNDropGenerator::CreateDMG() +int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, + const std::string& output_file) { // Get optional arguments ... - const std::string cpack_package_icon = this->GetOption("CPACK_PACKAGE_ICON") + const std::string cpack_package_icon = this->GetOption("CPACK_PACKAGE_ICON") ? this->GetOption("CPACK_PACKAGE_ICON") : ""; const std::string cpack_dmg_volume_name = @@ -197,7 +249,7 @@ int cmCPackDragNDropGenerator::CreateDMG() // The staging directory contains everything that will end-up inside the // final disk image ... cmOStringStream staging; - staging << toplevel; + staging << src_dir; // Add a symlink to /Applications so users can drag-and-drop the bundle // into it @@ -472,7 +524,7 @@ int cmCPackDragNDropGenerator::CreateDMG() final_image_command << cpack_dmg_format; final_image_command << " -imagekey"; final_image_command << " zlib-level=9"; - final_image_command << " -o \"" << packageFileNames[0] << "\""; + final_image_command << " -o \"" << output_file << "\""; if(!this->RunCommand(final_image_command)) { @@ -485,3 +537,47 @@ int cmCPackDragNDropGenerator::CreateDMG() return 1; } + +bool cmCPackDragNDropGenerator::SupportsComponentInstallation() const +{ + return true; +} + +std::string +cmCPackDragNDropGenerator::GetComponentInstallDirNameSuffix( + const std::string& componentName) +{ + // we want to group components together that go in the same dmg package + std::string package_file_name = this->GetOption("CPACK_PACKAGE_FILE_NAME"); + + // we have 3 mutually exclusive modes to work in + // 1. all components in one package + // 2. each group goes in its own package with left over + // components in their own package + // 3. ignore groups - if grouping is defined, it is ignored + // and each component goes in its own package + + if(this->componentPackageMethod == ONE_PACKAGE) + { + return "ALL_IN_ONE"; + } + + if(this->componentPackageMethod == ONE_PACKAGE_PER_GROUP) + { + // We have to find the name of the COMPONENT GROUP + // the current COMPONENT belongs to. + std::string groupVar = "CPACK_COMPONENT_" + + cmSystemTools::UpperCase(componentName) + "_GROUP"; + const char* _groupName = GetOption(groupVar.c_str()); + if (_groupName) + { + std::string groupName = _groupName; + + groupName = GetComponentPackageFileName(package_file_name, + groupName, true); + return groupName; + } + } + + return GetComponentPackageFileName(package_file_name, componentName, false); +} diff --git a/Source/CPack/cmCPackDragNDropGenerator.h b/Source/CPack/cmCPackDragNDropGenerator.h index dcef7fb..808c618 100644 --- a/Source/CPack/cmCPackDragNDropGenerator.h +++ b/Source/CPack/cmCPackDragNDropGenerator.h @@ -30,11 +30,16 @@ protected: virtual int InitializeInternal(); virtual const char* GetOutputExtension(); int PackageFiles(); + bool SupportsComponentInstallation() const; + bool CopyFile(cmOStringStream& source, cmOStringStream& target); bool RunCommand(cmOStringStream& command, std::string* output = 0); - int CreateDMG(); + std::string + GetComponentInstallDirNameSuffix(const std::string& componentName); + + int CreateDMG(const std::string& src_dir, const std::string& output_file); std::string InstallPrefix; }; |