From 33b4de86a9dfb53d70ff08ce56cccdc545420ba5 Mon Sep 17 00:00:00 2001 From: Jay Lee Date: Fri, 20 Sep 2024 00:56:15 +0000 Subject: [PATCH] dynamic gam.wx2 generation based on compiled files in dist/gam --- .github/workflows/build.yml | 4 +++ src/{gam.wxs => gam.wxs.template} | 20 +---------- src/tools/gen-wix-xml-filelist.py | 58 +++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 19 deletions(-) rename src/{gam.wxs => gam.wxs.template} (60%) create mode 100644 src/tools/gen-wix-xml-filelist.py diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0b3b0643..f93f0aed 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -658,6 +658,10 @@ jobs: GAM_ARCHIVE="../gam-${GAMVERSION}-windows-${GAM_ARCHIVE_ARCH}.zip" /c/Program\ Files/7-Zip/7z.exe a -tzip $GAM_ARCHIVE gam7 "-xr@${GITHUB_WORKSPACE}/.github/actions/package_exclusions.txt" -bb3 cd .. + tools/gen-wix-xml-filelist.py "$gampath" gam.wxs.template gam.wxs + echo '-- begin generated gam.wxs --' + cat gam.wxs + echo '-- end generated gam.wxs --' /c/Program\ Files\ \(x86\)/WiX\ Toolset\ v3.14/bin/candle.exe -arch "${WIX_ARCH}" gam.wxs /c/Program\ Files\ \(x86\)/WiX\ Toolset\ v3.14/bin/light.exe -ext /c/Program\ Files\ \(x86\)/WiX\ Toolset\ v3.14/bin/WixUIExtension.dll gam.wixobj -o "gam-${GAMVERSION}-windows-${GAM_ARCHIVE_ARCH}.msi" || true; rm -v -f *.wixpdb diff --git a/src/gam.wxs b/src/gam.wxs.template similarity index 60% rename from src/gam.wxs rename to src/gam.wxs.template index 3da4d2e3..a27b3085 100644 --- a/src/gam.wxs +++ b/src/gam.wxs.template @@ -43,25 +43,7 @@ Id="ProductComponents" Directory="INSTALLFOLDER" Source="dist/gam7"> - - - - - - - - - - - - - - - - - - - +REPLACE_ME_WITH_FILE_COMPONENTS diff --git a/src/tools/gen-wix-xml-filelist.py b/src/tools/gen-wix-xml-filelist.py new file mode 100644 index 00000000..8702ee63 --- /dev/null +++ b/src/tools/gen-wix-xml-filelist.py @@ -0,0 +1,58 @@ +import os +import sys +import uuid + +source_dir = sys.argv[1] +template_file = sys.argv[2] +target_file = sys.argv[3] + +existing_components = { + 'gam.exe': ''' + + + +''', + 'LICENSE': ''' + + +''', + 'gam-setup.bat': ''' + + +''', + 'GamCommands.txt': ''' + + +''', + 'GamUpdate.txt': ''' + + +''', + 'cacerts.pem': ''' + + +''', +} + +component_xml = '' +all_files = [] +for root, dirs, files in os.walk(source_dir): + for filename in files: + relpath = os.path.relpath(root, source_dir) + if relpath == '.': + all_files.append(filename) + else: + all_files.append(os.path.join(relpath, filename)) +all_files.sort() +for filename in all_files: + component_xml += existing_components.get(filename, + f' \n \n \n') + +with open(template_file, 'r') as f: + template = f.read() + +full_xml = template.replace('REPLACE_ME_WITH_FILE_COMPONENTS', component_xml) + +with open(target_file, 'w') as f: + f.write(full_xml) +