Browse Source

[#891]: Fix building the Arabic dictionary on windows.

master
Reece H. Dunn 4 years ago
parent
commit
e6880b27de
3 changed files with 78 additions and 1 deletions
  1. 1
    0
      .gitignore
  2. 1
    1
      src/windows/data.vcxproj
  3. 76
    0
      tests/windows-data.test

+ 1
- 0
.gitignore View File

!tests/mbrola.test !tests/mbrola.test
!tests/dictionary.test !tests/dictionary.test
!tests/cmd_options.test !tests/cmd_options.test
!tests/windows-data.test
!tests/windows-installer.test !tests/windows-installer.test


espeak-ng.pc espeak-ng.pc

+ 1
- 1
src/windows/data.vcxproj View File

<Target Name="zhy" Inputs="$(ProjectDir)..\..\dictsource\zhy_rules;$(ProjectDir)..\..\dictsource\zhy_list" Outputs="$(ProjectDir)..\..\espeak-ng-data\zhy_dict" DependsOnTargets="Phonemes"> <Target Name="zhy" Inputs="$(ProjectDir)..\..\dictsource\zhy_rules;$(ProjectDir)..\..\dictsource\zhy_list" Outputs="$(ProjectDir)..\..\espeak-ng-data\zhy_dict" DependsOnTargets="Phonemes">
<Exec Command="cd $(ProjectDir)..\..\dictsource &amp;&amp; $(TargetDir)espeak-ng.exe --path=$(ProjectDir)..\.. --compile=yue" /> <Exec Command="cd $(ProjectDir)..\..\dictsource &amp;&amp; $(TargetDir)espeak-ng.exe --path=$(ProjectDir)..\.. --compile=yue" />
</Target> </Target>
<Target Name="Dictionaries" DependsOnTargets="af;am;an;as;az;bg;bn;bs;ca;cs;cy;da;de;el;en;eo;es;et;eu;fa;fi;fr;ga;gd;gn;grc;gu;hi;hr;hu;hy;ia;id;is;it;jbo;ja;ka;kl;kn;ko;ku;ky;la;lfn;lt;lv;mk;ml;mr;ms;mt;my;nci;ne;nl;no;om;or;pa;pap;pl;pt;ro;ru;si;sk;sl;sq;sr;sv;sw;ta;te;tn;tr;tt;ur;vi;zh;zhy" />
<Target Name="Dictionaries" DependsOnTargets="af;am;an;ar;as;az;bg;bn;bs;ca;cs;cy;da;de;el;en;eo;es;et;eu;fa;fi;fr;ga;gd;gn;grc;gu;hi;hr;hu;hy;ia;id;is;it;jbo;ja;ka;kl;kn;ko;ku;ky;la;lfn;lt;lv;mk;ml;mr;ms;mt;my;nci;ne;nl;no;om;or;pa;pap;pl;pt;ro;ru;si;sk;sl;sq;sr;sv;sw;ta;te;tn;tr;tt;ur;vi;zh;zhy" />
</Project> </Project>

+ 76
- 0
tests/windows-data.test View File

#!/usr/bin/env python3

import sys
import os
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 check_missing(items, target):
missing = []
for item in items:
if not item in target:
missing.append(item)
check_result(len(missing) == 0, ', '.join(missing))
return missing

def all_descendants(proj, name):
for e in proj.iter():
if e.tag == '{http://schemas.microsoft.com/developer/msbuild/2003}' + name:
yield e

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

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

def list_dictionaries():
for file in os.listdir('dictsource'):
if file.endswith('_rules'):
yield file.split('_')[0]

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

proj = etree.parse('src/windows/data.vcxproj').getroot()
targets = element_map(proj, 'Target')

# 2. Check for missing dictionaries ####################################################################################

dictionaries = list(list_dictionaries())
depends_on_dictionaries = targets['Dictionaries'].attrib.get('DependsOnTargets').split(';')

print('testing for missing dictionary targets ... ', end='')
check_missing(depends_on_dictionaries, targets.keys())

print('testing for missing dependencies on dictionaries ... ', end='')
check_missing(set.intersection(set(dictionaries), set(targets.keys())), depends_on_dictionaries)

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

if not passed:
sys.exit(-1)

Loading…
Cancel
Save