Debian Codegraph @

platform/platform_builders.py

raw symbols SCIP
1 """Functions used to generate source files during build time"""
2
3 from pathlib import Path
4
5 import methods
6
7
8 def export_icon_builder(target, source, env):
9 src_path = Path(str(source[0]))
10 src_name = src_path.stem
11 platform = src_path.parent.parent.stem
12
13 with open(str(source[0]), "r", encoding="utf-8") as file:
14 svg = file.read()
15
16 with methods.generated_wrapper(str(target[0])) as file:
17 file.write(
18 f"""\
19 inline constexpr const char *_{platform}_{src_name}_svg = {methods.to_raw_cstring(svg)};
20 """
21 )
22
23
24 def register_platform_apis_builder(target, source, env):
25 platforms = source[0].read()
26 api_inc = "\n".join([f'#include "{p}/api/api.h"' for p in platforms])
27 api_reg = "\n\t".join([f"register_{p}_api();" for p in platforms])
28 api_unreg = "\n\t".join([f"unregister_{p}_api();" for p in platforms])
29 with methods.generated_wrapper(str(target[0])) as file:
30 file.write(
31 f"""\
32 #include "register_platform_apis.h"
33
34 {api_inc}
35
36 void register_platform_apis() {{
37 {api_reg}
38 }}
39
40 void unregister_platform_apis() {{
41 {api_unreg}
42 }}
43 """
44 )