summaryrefslogtreecommitdiffstats
path: root/editor/icons
diff options
context:
space:
mode:
authorThaddeus Crews <repiteo@outlook.com>2024-07-31 14:15:56 -0500
committerThaddeus Crews <repiteo@outlook.com>2024-07-31 14:22:04 -0500
commit01637056405df47b072bf9b3aee5a34d9dff35e8 (patch)
tree4052d2fa3f2598564c771199dff9f3d7339c5ea7 /editor/icons
parent1d57b81d2610f8c104fcead874995a583274d12d (diff)
downloadredot-engine-01637056405df47b072bf9b3aee5a34d9dff35e8.tar.gz
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")