| 1 |
"""Functions used to generate source files during build time""" |
| 2 |
|
| 3 |
import os |
| 4 |
|
| 5 |
import methods |
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
def 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"""\ |
| 25 |
#include "modules/modules_enabled.gen.h" |
| 26 |
|
| 27 |
inline constexpr int default_theme_icons_count = {len(icons_names)}; |
| 28 |
inline constexpr const char *default_theme_icons_sources[] = {{ |
| 29 |
{icons_raw_str} |
| 30 |
}}; |
| 31 |
|
| 32 |
inline constexpr const char *default_theme_icons_names[] = {{ |
| 33 |
{icons_names_str} |
| 34 |
}}; |
| 35 |
""") |