diff options
author | Brad King <brad.king@kitware.com> | 2017-04-25 13:05:33 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2017-04-25 13:05:37 (GMT) |
commit | 75d91e9c85a26796a291a8fb4ba289802313f917 (patch) | |
tree | eb3f9b8fde429276ec753ccf4754ae2a871158b9 | |
parent | 60e48295ae95535af7e245f308cf204a3ca9680d (diff) | |
parent | 58cf9d417e8b3d4d76597b9950a5af4860d3512c (diff) | |
download | CMake-75d91e9c85a26796a291a8fb4ba289802313f917.zip CMake-75d91e9c85a26796a291a8fb4ba289802313f917.tar.gz CMake-75d91e9c85a26796a291a8fb4ba289802313f917.tar.bz2 |
Merge topic 'wix-attributes-patch'
58cf9d41 wix: adds ability to modify attributes with patch
03628bb6 wix: fix spelling error in function name
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !742
-rw-r--r-- | Help/release/dev/wix-attributes-patch.rst | 7 | ||||
-rw-r--r-- | Source/CPack/WiX/cmCPackWIXGenerator.cxx | 14 | ||||
-rw-r--r-- | Source/CPack/WiX/cmCPackWIXGenerator.h | 2 | ||||
-rw-r--r-- | Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx | 4 | ||||
-rw-r--r-- | Source/CPack/WiX/cmWIXFilesSourceWriter.cxx | 4 | ||||
-rw-r--r-- | Source/CPack/WiX/cmWIXPatch.cxx | 6 | ||||
-rw-r--r-- | Source/CPack/WiX/cmWIXPatchParser.cxx | 26 |
7 files changed, 44 insertions, 19 deletions
diff --git a/Help/release/dev/wix-attributes-patch.rst b/Help/release/dev/wix-attributes-patch.rst new file mode 100644 index 0000000..e68d9f2 --- /dev/null +++ b/Help/release/dev/wix-attributes-patch.rst @@ -0,0 +1,7 @@ +wix-attributes-patch +-------------------- + +* The patching system within the :module:`CPackWIX` module now allows the + ability to set additional attributes. This can be done by specifying + addional attributes with the ``CPackWiXFragment`` XML tag after the + ``Id`` attribute. See the :variable:`CPACK_WIX_PATCH_FILE` variable. diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx index 2df23fd..274dfd0 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx +++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx @@ -677,10 +677,10 @@ bool cmCPackWIXGenerator::AddComponentsToFeature( cpackPackageDesktopLinksList); } - AddDirectoryAndFileDefinitons(rootPath, "INSTALL_ROOT", directoryDefinitions, - fileDefinitions, featureDefinitions, - cpackPackageExecutablesList, - cpackPackageDesktopLinksList, shortcuts); + AddDirectoryAndFileDefinitions( + rootPath, "INSTALL_ROOT", directoryDefinitions, fileDefinitions, + featureDefinitions, cpackPackageExecutablesList, + cpackPackageDesktopLinksList, shortcuts); featureDefinitions.EndElement("FeatureRef"); @@ -841,7 +841,7 @@ bool cmCPackWIXGenerator::CreateLicenseFile() return true; } -void cmCPackWIXGenerator::AddDirectoryAndFileDefinitons( +void cmCPackWIXGenerator::AddDirectoryAndFileDefinitions( std::string const& topdir, std::string const& directoryId, cmWIXDirectoriesSourceWriter& directoryDefinitions, cmWIXFilesSourceWriter& fileDefinitions, @@ -906,12 +906,12 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitons( directoryDefinitions.BeginElement("Directory"); directoryDefinitions.AddAttribute("Id", subDirectoryId); directoryDefinitions.AddAttribute("Name", fileName); + this->Patch->ApplyFragment(subDirectoryId, directoryDefinitions); - AddDirectoryAndFileDefinitons( + AddDirectoryAndFileDefinitions( fullPath, subDirectoryId, directoryDefinitions, fileDefinitions, featureDefinitions, packageExecutables, desktopExecutables, shortcuts); - this->Patch->ApplyFragment(subDirectoryId, directoryDefinitions); directoryDefinitions.EndElement("Directory"); } else { cmInstalledFile const* installedFile = this->GetInstalledFile( diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.h b/Source/CPack/WiX/cmCPackWIXGenerator.h index 353d6c0..b2633a7 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.h +++ b/Source/CPack/WiX/cmCPackWIXGenerator.h @@ -104,7 +104,7 @@ private: bool RunLightCommand(std::string const& objectFiles); - void AddDirectoryAndFileDefinitons( + void AddDirectoryAndFileDefinitions( std::string const& topdir, std::string const& directoryId, cmWIXDirectoriesSourceWriter& directoryDefinitions, cmWIXFilesSourceWriter& fileDefinitions, diff --git a/Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx b/Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx index 79a9fdd..0be4377 100644 --- a/Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx +++ b/Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx @@ -44,6 +44,8 @@ void cmWIXFeaturesSourceWriter::EmitFeatureForComponentGroup( AddAttributeUnlessEmpty("Title", group.DisplayName); AddAttributeUnlessEmpty("Description", group.Description); + patch.ApplyFragment("CM_G_" + group.Name, *this); + for (std::vector<cmCPackComponentGroup*>::const_iterator i = group.Subgroups.begin(); i != group.Subgroups.end(); ++i) { @@ -56,8 +58,6 @@ void cmWIXFeaturesSourceWriter::EmitFeatureForComponentGroup( EmitFeatureForComponent(**i, patch); } - patch.ApplyFragment("CM_G_" + group.Name, *this); - EndElement("Feature"); } diff --git a/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx b/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx index 7aa1212..b4cd1a3 100644 --- a/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx +++ b/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx @@ -136,6 +136,7 @@ std::string cmWIXFilesSourceWriter::EmitComponentFile( } } + patch.ApplyFragment(componentId, *this); BeginElement("File"); AddAttribute("Id", fileId); AddAttribute("Source", filePath); @@ -147,16 +148,15 @@ std::string cmWIXFilesSourceWriter::EmitComponentFile( if (!(fileMode & S_IWRITE)) { AddAttribute("ReadOnly", "yes"); } + patch.ApplyFragment(fileId, *this); if (installedFile) { cmWIXAccessControlList acl(Logger, *installedFile, *this); acl.Apply(); } - patch.ApplyFragment(fileId, *this); EndElement("File"); - patch.ApplyFragment(componentId, *this); EndElement("Component"); EndElement("DirectoryRef"); diff --git a/Source/CPack/WiX/cmWIXPatch.cxx b/Source/CPack/WiX/cmWIXPatch.cxx index 3a7dbfd..287a644 100644 --- a/Source/CPack/WiX/cmWIXPatch.cxx +++ b/Source/CPack/WiX/cmWIXPatch.cxx @@ -29,7 +29,11 @@ void cmWIXPatch::ApplyFragment(std::string const& id, return; const cmWIXPatchElement& fragment = i->second; - + for (cmWIXPatchElement::attributes_t::const_iterator attr_i = + fragment.attributes.begin(); + attr_i != fragment.attributes.end(); ++attr_i) { + writer.AddAttribute(attr_i->first, attr_i->second); + } this->ApplyElementChildren(fragment, writer); Fragments.erase(i); diff --git a/Source/CPack/WiX/cmWIXPatchParser.cxx b/Source/CPack/WiX/cmWIXPatchParser.cxx index 7f2ae19..0dcc74a 100644 --- a/Source/CPack/WiX/cmWIXPatchParser.cxx +++ b/Source/CPack/WiX/cmWIXPatchParser.cxx @@ -72,9 +72,11 @@ void cmWIXPatchParser::StartElement(const std::string& name, const char** atts) void cmWIXPatchParser::StartFragment(const char** attributes) { + cmWIXPatchElement* new_element = CM_NULLPTR; + /* find the id of for fragment */ for (size_t i = 0; attributes[i]; i += 2) { - std::string key = attributes[i]; - std::string value = attributes[i + 1]; + const std::string key = attributes[i]; + const std::string value = attributes[i + 1]; if (key == "Id") { if (Fragments.find(value) != Fragments.end()) { @@ -83,10 +85,22 @@ void cmWIXPatchParser::StartFragment(const char** attributes) ReportValidationError(tmp.str()); } - ElementStack.push_back(&Fragments[value]); - } else { - ReportValidationError( - "The only allowed 'CPackWixFragment' attribute is 'Id'"); + new_element = &Fragments[value]; + ElementStack.push_back(new_element); + } + } + + /* add any additional attributes for the fragement */ + if (!new_element) { + ReportValidationError("No 'Id' specified for 'CPackWixFragment' element"); + } else { + for (size_t i = 0; attributes[i]; i += 2) { + const std::string key = attributes[i]; + const std::string value = attributes[i + 1]; + + if (key != "Id") { + new_element->attributes[key] = value; + } } } } |