Skip to content
0.2.0-dev Download ZIP
33 lines ·930 B Raw
1"""Functions used to generate source files during build time"""
2
3import os
4
5import methods
6
7
8# See also `editor/icons/editor_icons_builders.py`.
9def make_default_theme_icons_action(target, source, env):
10 icons_names = []
11 icons_raw = []
12
13 for src in map(str, source):
14 with open(src, encoding="utf-8", newline="\n") as file:
15 icons_raw.append(methods.to_raw_cstring(file.read()))
16
17 name = os.path.splitext(os.path.basename(src))[0]
18 icons_names.append(f'"{name}"')
19
20 icons_names_str = ",\n\t".join(icons_names)
21 icons_raw_str = ",\n\t".join(icons_raw)
22
23 with methods.generated_wrapper(str(target[0])) as file:
24 file.write(f"""\
25inline constexpr int default_theme_icons_count = {len(icons_names)};
26inline constexpr const char *default_theme_icons_sources[] = {{
27 {icons_raw_str}
28}};
29
30inline constexpr const char *default_theme_icons_names[] = {{
31 {icons_names_str}
32}};
33""")