scons: Improve validation of XML dialogs, and make it work on Windows if xmllint is installed

This commit is contained in:
2015-09-13 23:55:32 -04:00
parent a38a8e3a7d
commit 19197a64e7
2 changed files with 31 additions and 21 deletions

View File

@@ -320,11 +320,15 @@ elif str(platform) == "win32":
target_dirs = ["#build/Blades of Exile", "#build/test"] target_dirs = ["#build/Blades of Exile", "#build/test"]
for lib in bundled_libs: for lib in bundled_libs:
for lpath in env['LIBPATH']: for lpath in env['LIBPATH']:
if 'Visual Studio' in lpath:
lpath = lpath.replace('lib', 'bin')
src_file = path.join(lpath, lib + ".dll") src_file = path.join(lpath, lib + ".dll")
if path.exists(src_file): if path.exists(src_file):
for targ in target_dirs: for targ in target_dirs:
env.Install(targ, src_file) env.Install(targ, src_file)
break break
elif 'lib' in lpath:
src_file = path.join(lpath.replace('lib', 'bin'), lib + ".dll")
if path.exists(src_file):
for targ in target_dirs:
env.Install(targ, src_file)
break

View File

@@ -21,26 +21,32 @@ env.Install(path.join(data_dir, "shaders"), Glob("#src/tools/mask.*"))
env.Install(path.join(install_dir, "Blades of Exile Scenarios"), Glob("Blades of Exile Scenarios/*.exs") + Glob("Blades of Exile Scenarios/*.meg")) env.Install(path.join(install_dir, "Blades of Exile Scenarios"), Glob("Blades of Exile Scenarios/*.exs") + Glob("Blades of Exile Scenarios/*.meg"))
env.Install(path.join(install_dir, "Blades of Exile Base"), Glob("Blades of Exile Bases/*.exs")) env.Install(path.join(install_dir, "Blades of Exile Base"), Glob("Blades of Exile Bases/*.exs"))
if str(platform) != "win32" and subprocess.call(['which', '-s', 'xmllint']) == 0: have_xmllint = False
if ((str(platform) != "win32" and subprocess.call(['which', '-s', 'xmllint']) == 0) or
(str(platform) == "win32" and subprocess.call(['where', '/Q', 'xmllint'])) == 0):
have_xmllint = True have_xmllint = True
xmllint_command = ('xmllint', '--nonet', '--noout', '--schema', '../schemas/dialog.xsd') xmllint_command = ('xmllint', '--nonet', '--noout', '--schema', '../schemas/dialog.xsd')
if have_xmllint: # This is separate so that alternate xml validators could be user if have_xmllint: # This is separate so that alternate xml validators could be used
def validate_dialogs(target, source, env): def validate_dialog(target, source, env):
sources = source
PIPE = subprocess.PIPE PIPE = subprocess.PIPE
with open(target[0].path, 'w') as log: with open(target[0].abspath, 'w') as log:
for source in sources: src_name = path.basename(source[0].path)
src_name = path.basename(source.path) cmd_line = xmllint_command + (src_name,)
if src_name == 'dialog.xsd': print(*cmd_line)
continue p = subprocess.Popen(cmd_line,
cmd_line = xmllint_command + (src_name,) bufsize=1, stdin=PIPE, stdout=PIPE, stderr=PIPE,
print(*cmd_line) cwd=source[0].Dir('.').abspath
p = subprocess.Popen(cmd_line, )
bufsize=1, stdin=PIPE, stdout=PIPE, stderr=PIPE, out, err = p.communicate()
cwd=Dir('rsrc/dialogs').abspath print(err, end='')
) print(err, file=log)
out, err = p.communicate() return p.returncode
print(err, end='') # We use these .log files as dummy targets, basically (though they also store the validation results)
print(err, file=log) env.Append(BUILDERS={"ValidateDialogXml": Builder(action=validate_dialog,suffix='.log',src_suffix='.xml')})
env.Command('#build/dialogs.log', Glob('dialogs/*.xml') + ['schemas/dialog.xsd'], validate_dialogs) for dlg in Glob('dialogs/*.xml'):
dlg = path.basename(dlg.path).split('.')[0]
env.ValidateDialogXml(path.join("#build/dialogs", dlg), path.join("dialogs", dlg))
else:
print("Note: Skipping XML dialog validation since no validator tool was found.")