diff options
Diffstat (limited to 'platform_methods.py')
-rw-r--r-- | platform_methods.py | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/platform_methods.py b/platform_methods.py index 1a2520794c..8b2c62ad4a 100644 --- a/platform_methods.py +++ b/platform_methods.py @@ -14,7 +14,6 @@ JSON_SERIALIZABLE_TYPES = (bool, int, float, str) def run_in_subprocess(builder_function): @functools.wraps(builder_function) def wrapper(target, source, env): - # Convert SCons Node instances to absolute paths target = [node.srcnode().abspath for node in target] source = [node.srcnode().abspath for node in source] @@ -111,3 +110,33 @@ def detect_arch(): print("Unsupported CPU architecture: " + host_machine) print("Falling back to x86_64.") return "x86_64" + + +def generate_export_icons(platform_path, platform_name): + """ + Generate headers for logo and run icon for the export plugin. + """ + export_path = platform_path + "/export" + svg_names = [] + if os.path.isfile(export_path + "/logo.svg"): + svg_names.append("logo") + if os.path.isfile(export_path + "/run_icon.svg"): + svg_names.append("run_icon") + + for name in svg_names: + svgf = open(export_path + "/" + name + ".svg", "rb") + b = svgf.read(1) + svg_str = " /* AUTOGENERATED FILE, DO NOT EDIT */ \n" + svg_str += " static const char *_" + platform_name + "_" + name + '_svg = "' + while len(b) == 1: + svg_str += "\\" + hex(ord(b))[1:] + b = svgf.read(1) + + svg_str += '";\n' + + svgf.close() + + # NOTE: It is safe to generate this file here, since this is still executed serially. + wf = export_path + "/" + name + "_svg.gen.h" + with open(wf, "w") as svgw: + svgw.write(svg_str) |