|
| 1 | +from contextlib import redirect_stdout |
| 2 | +import os |
| 3 | + |
| 4 | +dll_components = open('wix/dll-components.wxi', 'w') |
| 5 | +dll_references = open('wix/dll-references.wxi', 'w') |
| 6 | +license_components = open('wix/license-components.wxi', 'w') |
| 7 | +license_references = open('wix/license-references.wxi', 'w') |
| 8 | + |
| 9 | +output_files = [ |
| 10 | + dll_components, |
| 11 | + dll_references, |
| 12 | + license_components, |
| 13 | + license_references |
| 14 | +] |
| 15 | + |
| 16 | +def component_name(filename): |
| 17 | + return filename.replace('-', '_').replace('+', '_') |
| 18 | + |
| 19 | +for file in output_files: |
| 20 | + print("<Include>", file=file) |
| 21 | + |
| 22 | +bin_dir = '$(env.VCPKG_INSTALLED_DIR)/x64-windows/bin' |
| 23 | + |
| 24 | +for line in open('wix/required-dlls.txt', 'r'): |
| 25 | + filename, guid = line.rstrip().split(' ') |
| 26 | + component = component_name(filename) |
| 27 | + with redirect_stdout(dll_components): |
| 28 | + print(f" <Component Id='{component}' Guid='{guid}'>") |
| 29 | + print(f" <File Id='{component}'") |
| 30 | + print(f" Name='{filename}'") |
| 31 | + print(f" DiskId='1'") |
| 32 | + print(f" Source='{bin_dir}/{filename}'/>") |
| 33 | + print(f" </Component>") |
| 34 | + with redirect_stdout(dll_references): |
| 35 | + print(f" <ComponentRef Id='{component}'/>") |
| 36 | + |
| 37 | +for filename in os.listdir('wix/full-licenses'): |
| 38 | + component = component_name(filename) |
| 39 | + with redirect_stdout(license_components): |
| 40 | + print(f" <Component Id='{component}' Guid='*'>") |
| 41 | + print(f" <File Id='{component}'") |
| 42 | + print(f" Name='{filename}'") |
| 43 | + print(f" DiskId='1'") |
| 44 | + print(f" Source='wix/full-licenses/{filename}'/>") |
| 45 | + print(f" </Component>") |
| 46 | + with redirect_stdout(license_references): |
| 47 | + print(f" <ComponentRef Id='{component}'/>") |
| 48 | + |
| 49 | +for file in output_files: |
| 50 | + print("</Include>", file=file) |
0 commit comments