summaryrefslogtreecommitdiffstats
path: root/editor/icons
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2024-08-28 00:12:47 +0200
committerRémi Verschelde <rverschelde@gmail.com>2024-08-28 00:12:47 +0200
commitdb24ed4eadf233f75cb1ebbf7552d396fb8b4b80 (patch)
tree4c5c22ddcc3013c0d8c19e2637e3f2dd299a10aa /editor/icons
parent78935cad953e7e99a86eed4556fb3459da62b6dc (diff)
parent01637056405df47b072bf9b3aee5a34d9dff35e8 (diff)
downloadredot-engine-db24ed4eadf233f75cb1ebbf7552d396fb8b4b80.tar.gz
Merge pull request #94995 from Repiteo/scons/raw-cstrings
SCons: Add method to generate raw cstrings
Diffstat (limited to 'editor/icons')
-rw-r--r--editor/icons/editor_icons_builders.py20
1 files changed, 5 insertions, 15 deletions
diff --git a/editor/icons/editor_icons_builders.py b/editor/icons/editor_icons_builders.py
index 5cc67ca3ad..d3e8953483 100644
--- a/editor/icons/editor_icons_builders.py
+++ b/editor/icons/editor_icons_builders.py
@@ -3,6 +3,8 @@
import os
from io import StringIO
+from methods import to_raw_cstring
+
# See also `scene/theme/icons/default_theme_icons_builders.py`.
def make_editor_icons_action(target, source, env):
@@ -10,21 +12,9 @@ def make_editor_icons_action(target, source, env):
svg_icons = source
with StringIO() as icons_string, StringIO() as s:
- for f in svg_icons:
- fname = str(f)
-
- icons_string.write('\t"')
-
- with open(fname, "rb") as svgf:
- b = svgf.read(1)
- while len(b) == 1:
- icons_string.write("\\" + str(hex(ord(b)))[1:])
- b = svgf.read(1)
-
- icons_string.write('"')
- if fname != svg_icons[-1]:
- icons_string.write(",")
- icons_string.write("\n")
+ for svg in svg_icons:
+ with open(str(svg), "r") as svgf:
+ icons_string.write("\t%s,\n" % to_raw_cstring(svgf.read()))
s.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
s.write("#ifndef _EDITOR_ICONS_H\n")