Skip to content

Commit

Permalink
Experiment: Make generating wxs completely deterministic with WiX v5 …
Browse files Browse the repository at this point in the history
…`naked files` feature

See [1]

[1] https://wixtoolset.org/docs/fivefour/#naked-files
  • Loading branch information
jkarasti committed Sep 23, 2024
1 parent fdceab7 commit 622cf7f
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions install/windows/build-wxs.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env python3
import os
import uuid
import xml.etree.ElementTree as ET


Expand All @@ -13,10 +12,9 @@ def build_data(base_path, path_prefix, dir_id, dir_name):
}

if dir_id == "INSTALLFOLDER":
data["component_id"] = "ApplicationFiles"
data["componentgroup_id"] = "ApplicationFiles"
else:
data["component_id"] = "Component" + dir_id
data["component_guid"] = str(uuid.uuid4()).upper()
data["componentgroup_id"] = "ComponentGroup" + dir_id

for entry in os.listdir(base_path):
entry_path = os.path.join(base_path, entry)
Expand Down Expand Up @@ -61,18 +59,27 @@ def build_directory_xml(root, data):
build_directory_xml(directory_el, subdata)


def build_components_xml(root, data):
def build_componentgroup_xml(root, data):
component_el = ET.SubElement(
root,
"Component",
Id=data["component_id"],
Guid=data["component_guid"],
"ComponentGroup",
Id=data["componentgroup_id"],
Directory=data["directory_id"],
)
for filename in data["files"]:
ET.SubElement(component_el, "File", Source=filename)
for subdata in data["dirs"]:
build_components_xml(root, subdata)
build_componentgroup_xml(root, subdata)


def build_feature_xml(root, data):
ET.SubElement(
root,
"ComponentGroupRef",
Id=data["componentgroup_id"],
)
for subdata in data["dirs"]:
build_feature_xml(root, subdata)


def main():
Expand Down Expand Up @@ -220,16 +227,12 @@ def main():
# Generate the directory layout for the installed product
build_directory_xml(programfilesfolder_el, data)

applicationcomponents_el = ET.SubElement(
package_el, "ComponentGroup", Id="ApplicationComponents"
)

# Generate the components for the installed product
build_components_xml(applicationcomponents_el, data)
build_componentgroup_xml(package_el, data)

# Add the Feature element
feature_el = ET.SubElement(package_el, "Feature", Id="DefaultFeature", Level="1")
ET.SubElement(feature_el, "ComponentGroupRef", Id="ApplicationComponents")
build_feature_xml(feature_el, data)
ET.SubElement(feature_el, "ComponentRef", Id="ApplicationShortcuts")

ET.indent(wix_el, space=" ")
Expand Down

0 comments on commit 622cf7f

Please sign in to comment.