Skip to content

Commit

Permalink
[#864]: Fix installing the Japanese language on windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
rhdunn committed Mar 24, 2021
1 parent 1432684 commit a0b0f58
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -116,6 +116,7 @@ tests/*.check
!tests/mbrola.test
!tests/dictionary.test
!tests/cmd_options.test
!tests/windows-installer.test

espeak-ng.pc

Expand Down
1 change: 1 addition & 0 deletions Makefile.am
Expand Up @@ -273,6 +273,7 @@ check: tests/encoding.check \
tests/klatt.check \
tests/mbrola.check \
tests/variants.check \
tests/windows-installer.check \
tests/bom.check \
tests/cmd_options.check

Expand Down
10 changes: 9 additions & 1 deletion src/windows/installer/Product.wxs
Expand Up @@ -13,7 +13,7 @@
<?define PlatformProgramFilesFolder = "ProgramFilesFolder" ?>
<?endif ?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="3DA6DF03-E5CD-4A93-B06F-707484742BAB" Name="$(var.ProductDisplayName)" Language="1033" Version="$(var.ProductVersion)" Manufacturer="Cainteoir Technologies" UpgradeCode="B4F779EB-AC6C-49D2-A12D-4871E4520C0F">
<Product Id="3DA6DF03-E5CD-4A93-B06F-707484742BAB" Name="$(var.ProductDisplayName)" Language="1033" Version="$(var.ProductVersion)" Manufacturer="eSpeak Community" UpgradeCode="B4F779EB-AC6C-49D2-A12D-4871E4520C0F">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" Platform="$(var.Platform)" />

<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
Expand Down Expand Up @@ -459,6 +459,9 @@
<Component Id="it_dict" Win64="$(var.Win64)" Guid="A91D9D76-5BA7-45BB-B1B0-FF52EDA40141">
<File Name="it_dict" Source="$(var.ProjectDir)..\..\..\espeak-ng-data\it_dict" KeyPath="yes"/>
</Component>
<Component Id="ja_dict" Win64="$(var.Win64)" Guid="BC2849B8-3F19-4543-B698-D53F43DEF831">
<File Name="ja_dict" Source="$(var.ProjectDir)..\..\..\espeak-ng-data\ja_dict" KeyPath="yes"/>
</Component>
<Component Id="jbo_dict" Win64="$(var.Win64)" Guid="C1A9EB60-2825-460B-8F4F-E31610697BCE">
<File Name="jbo_dict" Source="$(var.ProjectDir)..\..\..\espeak-ng-data\jbo_dict" KeyPath="yes"/>
</Component>
Expand Down Expand Up @@ -800,6 +803,11 @@
<Component Id="ko" Win64="$(var.Win64)" Guid="0F759436-12BD-4FC5-80C0-6E755E021E40">
<File Name="ko" Source="$(var.ProjectDir)..\..\..\espeak-ng-data\lang\ko" KeyPath="yes"/>
</Component>
<Directory Id="JPX" Name="jpx">
<Component Id="ja" Win64="$(var.Win64)" Guid="00A542A4-48FD-450D-84F5-8035B0EB1FBB">
<File Name="ja" Source="$(var.ProjectDir)..\..\..\espeak-ng-data\lang\jpx\ja" KeyPath="yes"/>
</Component>
</Directory>
<Directory Id="POZ" Name="poz">
<Component Id="id" Win64="$(var.Win64)" Guid="C9BFD2A4-A105-4061-961A-DF6CB6C02854">
<File Name="id" Source="$(var.ProjectDir)..\..\..\espeak-ng-data\lang\poz\id" KeyPath="yes"/>
Expand Down
91 changes: 91 additions & 0 deletions tests/windows-installer.test
@@ -0,0 +1,91 @@
#!/usr/bin/env python3

import sys
import xml.etree.ElementTree as etree

passed = True

def check_result(check, message):
global passed
if check:
print('passed')
elif message:
print('failed: ' + message)
passed = False
else:
print('failed')
passed = False

def all_descendants(wix, name):
for e in wix.iter():
if e.tag == '{http://schemas.microsoft.com/wix/2006/wi}' + name:
yield e

def children(e, name):
for c in e:
if not isinstance(c, str):
if c.tag == '{http://schemas.microsoft.com/wix/2006/wi}' + name:
yield c

def element_map(wix, name):
print('testing for duplicate \'' + name + '\' ids ... ', end='')
items = {}
duplicates = []
for e in all_descendants(wix, name):
id = e.attrib.get("Id")
if id in items.keys():
duplicates.append(id)
else:
items[id] = e
check_result(len(duplicates) == 0 , ', '.join(duplicates))
return items

def check_element_guids(wix, name):
print('testing for duplicate \'' + name + '\' guids ... ', end='')
guids = []
missing_guids = []
duplicates = []
for e in all_descendants(wix, name):
id = e.attrib.get("Id")
guid = e.attrib.get("Guid")
if not guid:
missing_guids.append(id)
elif guid in guids:
duplicates.append(guid)
else:
guids.append(guid)
check_result(len(duplicates) == 0 , ', '.join(duplicates))
return (guids, missing_guids)

def check_references(nodes, node_name, name, item_name, items):
print('testing for missing \'' + item_name + '\' ids in \'' + node_name + '/' + name + '\' ... ', end='')
missing = []
for node in nodes.values():
for ref in children(node, name):
id = ref.attrib.get("Id")
if not id in items.keys():
missing.append(id)
check_result(len(missing) == 0 , ', '.join(missing))

# 1. Check for missing/duplicate ids ###################################################################################

wix = etree.parse('src/windows/installer/Product.wxs').getroot()
features = element_map(wix, 'Feature')
component_groups = element_map(wix, 'ComponentGroup')
components = element_map(wix, 'Component')
directories = element_map(wix, 'Directory')

check_references(features, 'Feature', 'ComponentGroupRef', 'ComponentGroup', component_groups)
check_references(component_groups, 'ComponentGroups', 'ComponentRef', 'Component', components)

# 2. Check for missing/duplicate guids #################################################################################

guids, missing_guids = check_element_guids(wix, 'Component')

print('testing for missing \'Component\' guids ... ', end='')
check_result(len(missing_guids) == 0 , ', '.join(missing_guids))

########################################################################################################################

if not passed:
sys.exit(-1)

0 comments on commit a0b0f58

Please sign in to comment.