from __future__ import print_function import os.path as path import subprocess Import("env platform data_dir install_dir") # Data env.Install(data_dir, Dir("cursors")) env.Install(data_dir, Dir("dialogs")) env.Install(data_dir, Dir("fonts")) env.Install(data_dir, Dir("graphics")) env.Install(data_dir, Dir("sounds")) env.Install(data_dir, Dir("strings")) env.Install(path.join(data_dir, "shaders"), Glob("#src/tools/mask.*")) # Scenarios if str(platform) == "darwin": scen_gfx = Glob("Blades of Exile Scenarios/*.meg") elif str(platform) == "win32": scen_gfx = Glob("Blades of Exile Scenarios/*.BMP") env.Install(path.join(install_dir, "Blades of Exile Scenarios"), Glob("Blades of Exile Scenarios/*.exs") + scen_gfx) env.Install(path.join(install_dir, "Blades of Exile Base"), Glob("Blades of Exile Bases/*.exs")) # Validate dialogs 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 xmllint_command = ('xmllint', '--nonet', '--noout', '--schema', '../schemas/dialog.xsd') if have_xmllint: # This is separate so that alternate xml validators could be used def validate_dialog(target, source, env): PIPE = subprocess.PIPE with open(target[0].abspath, 'w') as log: src_name = path.basename(source[0].path) cmd_line = xmllint_command + (src_name,) print(*cmd_line) p = subprocess.Popen(cmd_line, bufsize=1, stdin=PIPE, stdout=PIPE, stderr=PIPE, cwd=source[0].Dir('.').abspath ) out, err = p.communicate() print(err, end='') print(err, file=log) return p.returncode # We use these .log files as dummy targets, basically (though they also store the validation results) env.Append(BUILDERS={"ValidateDialogXml": Builder(action=validate_dialog,suffix='.log',src_suffix='.xml')}) 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.") # Assign custom icons if str(platform) == "darwin": def set_dir_icon(env, target, source): env.Command(target, source, action = [ Mkdir("build/rsrc/icons"), "sips -i $SOURCE --out build/rsrc/icons/${SOURCE.file}", "DeRez -only icns build/rsrc/icons/${SOURCE.file} > \ build/rsrc/icons/${SOURCE.filebase}.rsrc", "Rez -append build/rsrc/icons/${SOURCE.filebase}.rsrc -o $TARGET", "SetFile -a C ${TARGET.dir}", "chflags hidden $TARGET", ]) env.AddMethod(set_dir_icon, "SetDirIcon") icons = { '': 'boeresources.icns', 'dialogs/': 'boeresources.icns', 'strings/': 'boeresources.icns', 'cursors/': 'boegraphics.icns', 'graphics/': 'boegraphics.icns', 'sounds/': 'boesounds.icns', } for dir, icon in icons.items(): env.SetDirIcon( path.join("#build/Blades of Exile/data", dir, 'Icon\r'), path.join("icons/mac/", icon) )