summaryrefslogtreecommitdiffstats
path: root/platform_methods.py
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2023-06-19 11:28:22 +0200
committerRémi Verschelde <rverschelde@gmail.com>2023-06-20 13:16:37 +0200
commit90446fe9f381eaaa86caed2facc09ee1cf5fb52b (patch)
tree85267ecf27753199491359ba31bbeb00507758be /platform_methods.py
parentdbe8712d4eda555829283624df7c79faa4bc02ea (diff)
downloadredot-engine-90446fe9f381eaaa86caed2facc09ee1cf5fb52b.tar.gz
SCons: Move platform logo/run icon to `export` folder
Follow-up to #75932. Since these icons are only used by the export plugin, it makes sense to move them and generate the headers there. The whole `detect.is_active()` logic seems to be a leftover from before times, as far back as 1.0-stable it already wasn't used for anything. So I'm removing it and moving the export icon generation to `platform_methods`, where it makes more sense.
Diffstat (limited to 'platform_methods.py')
-rw-r--r--platform_methods.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/platform_methods.py b/platform_methods.py
index ed0ab980d0..8b2c62ad4a 100644
--- a/platform_methods.py
+++ b/platform_methods.py
@@ -110,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)