Browse Source

win32: replace Wix heat with a python script

It allows showing friendly names in the .msi for each file rather than some hash.

For now we never keep the .pdb files.
pull/141/head
Steve Lhomme 4 years ago
parent
commit
6f996ffa27
  1. 12
      extras/package/win32/msi.mak
  2. 97
      extras/package/win32/msi/msi-heat.py

12
extras/package/win32/msi.mak

@ -4,10 +4,10 @@ BUILT_SOURCES_distclean += \
endif
WIXPATH=`wine winepath -u 'C:\\Program Files (x86)\\Windows Installer XML v3.5\\bin'`
HEAT=wine "$(WIXPATH)/heat.exe"
HEAT=$(MSIDIR)/msi-heat.py
CANDLE=wine "$(WIXPATH)/candle.exe"
LIGHT=wine "$(WIXPATH)/light.exe"
VLCDIR=`wine winepath -s \`wine winepath -w '$(abs_top_builddir)/vlc-$(VERSION)'\``
VLCDIR=$(abs_top_builddir)/vlc-$(VERSION)
MSIDIR=$(abs_srcdir)/extras/package/win32/msi
W_MSIDIR=`wine winepath -w '$(MSIDIR)'`
MSIBUILDDIR=$(abs_top_builddir)/extras/package/win32/msi
@ -21,13 +21,13 @@ W_WINE_C=c:/v
WINE_C=`wine winepath $(W_WINE_C)`
heat: package-win-strip
$(HEAT) dir $(VLCDIR)/plugins -cg CompPluginsGroup -gg -scom -sreg -sfrag -dr APPLICATIONFOLDER -out $(W_MSIBUILDDIR)/Plugins.fragment.wxs
$(HEAT) dir $(VLCDIR)/locale -cg CompLocaleGroup -gg -scom -sreg -sfrag -dr APPLICATIONFOLDER -out $(W_MSIBUILDDIR)/Locale.fragment.wxs
$(HEAT) --dir $(VLCDIR)/plugins -cg CompPluginsGroup -gg -scom -sreg -sfrag -dr APPLICATIONFOLDER -out $(MSIBUILDDIR)/Plugins.fragment.wxs
$(HEAT) --dir $(VLCDIR)/locale -cg CompLocaleGroup -gg -scom -sreg -sfrag -dr APPLICATIONFOLDER -out $(MSIBUILDDIR)/Locale.fragment.wxs
if BUILD_LUA
$(HEAT) dir $(VLCDIR)/lua -cg CompLuaGroup -gg -scom -sreg -sfrag -dr APPLICATIONFOLDER -out $(W_MSIBUILDDIR)/Lua.fragment.wxs
$(HEAT) --dir $(VLCDIR)/lua -cg CompLuaGroup -gg -scom -sreg -sfrag -dr APPLICATIONFOLDER -out $(MSIBUILDDIR)/Lua.fragment.wxs
endif
if BUILD_SKINS
$(HEAT) dir $(VLCDIR)/skins -cg CompSkinsGroup -gg -scom -sreg -sfrag -dr APPLICATIONFOLDER -out $(W_MSIBUILDDIR)/Skins.fragment.wxs
$(HEAT) --dir $(VLCDIR)/skins -cg CompSkinsGroup -gg -scom -sreg -sfrag -dr APPLICATIONFOLDER -out $(MSIBUILDDIR)/Skins.fragment.wxs
endif
candle: heat

97
extras/package/win32/msi/msi-heat.py

@ -0,0 +1,97 @@
#!/usr/bin/env python3
# Copyright © 2022 VideoLabs, VLC authors and VideoLAN
#
# Authors: Steve Lhomme <robux4@videolabs.io>
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
import argparse
import os
import pathlib
import hashlib
# Argument parsing
parser = argparse.ArgumentParser(description="Generate WIX compatible wxs listing")
parser.add_argument('-d', "--dir", type=pathlib.Path, help='directory with files to list')
parser.add_argument('-out', type=argparse.FileType('w', encoding='UTF-8'), help="output file")
parser.add_argument('-pdb', action=argparse.BooleanOptionalAction, help='keep PDB files', default=False)
parser.add_argument('-dr', "--directory-reference", help='directory reference')
parser.add_argument('-cg', "--component-group", help='component group')
args, remaining = parser.parse_known_args()
# print(args.out)
# print(args.dir)
def generate_id(prefix='', file=''):
joined = prefix + file
hash_object = hashlib.sha1(joined.encode('ascii'))
pbHash = hash_object.hexdigest()
return prefix + pbHash.upper()
args.out.write('<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n')
args.out.write('<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">\r\n')
args.out.write(' <Fragment>\r\n')
args.out.write(' <DirectoryRef Id="{}">\r\n'.format(args.directory_reference))
# args.out.write(' <Directory Id="{}" Name="{}">\r\n'.format(generate_id('dir', args.dir.name), args.dir.name))
fileIdList =[]
def outputDir(top, parent: str, dir: str, with_pdb: bool):
cwd = top.joinpath(parent).joinpath(dir)
dirName = os.path.join(parent, dir)
if dir=='':
dir = top.name
dirId = generate_id('dir', os.path.join(top.name, dir))
else:
dirId = generate_id('dir', os.path.join(parent, dir))
args.out.write(' <Directory Id="{}" Name="{}">\r\n'.format(dirId, dir))
if cwd.is_dir():
# first list files
for file in cwd.iterdir():
if not file.is_dir():
# args.out.write(' file <{}>\r\n'.format(file))
if not file.name.endswith('.pdb'):
outname = os.path.join(dirName, file.name)
fileId = generate_id('cmp', outname)
args.out.write(' <Component Id="{}" Guid="*">\r\n'.format(fileId))
fileIdList.append(fileId)
args.out.write(' <File Id="{}" Name="{}" KeyPath="yes" Source="SourceDir/{}"/>\r\n'.format(generate_id('fil', outname), file.name, outname))
args.out.write(' </Component>\r\n')
# then sub directories
for file in cwd.iterdir():
if file.is_dir():
# args.out.write(' dir <{}>\r\n'.format(file))
outputDir(top, dirName, file.name, with_pdb)
args.out.write(' </Directory>\r\n')
print(args.dir.parent)
print(args.dir.name)
outputDir(args.dir, '', '', args.pdb)
# args.out.write(' </Directory>\r\n')
args.out.write(' </DirectoryRef>\r\n')
args.out.write(' </Fragment>\r\n')
args.out.write(' <Fragment>\r\n')
args.out.write(' <ComponentGroup Id="{}">\r\n'.format(args.component_group))
for name in fileIdList:
args.out.write(' <ComponentRef Id="{}"/>\r\n'.format(name))
args.out.write(' </ComponentGroup>\r\n')
args.out.write(' </Fragment>\r\n')
args.out.write('</Wix>\r\n')
Loading…
Cancel
Save