-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgen.py
32 lines (29 loc) · 854 Bytes
/
gen.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import os
template = """
gensrcs {
name: "libxcb_{1}_{2}",
tools: ["libxcb_c_client"],
srcs: ["{1}.xml"],
output_extension: "{3}",
cmd: "$(location libxcb_c_client) $(in) &&" +
"mv {1}.{3} $(out)",
export_include_dirs: ["."],
}
"""
def gen_template(name, header=False):
out = template
if header:
out = out.replace("{2}", "header")
out = out.replace("{3}", "h")
else:
out = out.replace("{2}", "source")
out = out.replace("{3}", "c")
out = out.replace("{1}", name)
return out
with open("src/Android.bp", "w") as f:
f.write("// GENERATED BY gen.py \n")
for proto in os.listdir("src"):
if proto.endswith(".xml"):
name = os.path.basename(proto)[:-4]
f.write(gen_template(name))
f.write(gen_template(name, header=True))