-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpre-commit.hook
More file actions
executable file
·37 lines (33 loc) · 1.24 KB
/
pre-commit.hook
File metadata and controls
executable file
·37 lines (33 loc) · 1.24 KB
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
33
34
35
36
37
#!/bin/env python3
import sys
import os
import shutil
import gzip
shutil.rmtree("encodings-output", ignore_errors=True)
os.mkdir("encodings-output")
files = [i for i in os.listdir(".") if i.endswith(".enc")]
for file in files:
os.system(f"git add {file}")
with open(file, "rb") as f:
with open(os.path.join("encodings-output", file), "wb") as fo:
fo.write(gzip.compress(f.read()))
with open(os.path.join("encodings-output", "xorg_font_encodings.txt"), "w") as f:
f.write("# stub for soong target based on all encodings")
with open(os.path.join("encodings-output", "Android.bp"), "w") as out:
out.write("// AUTOGENERATED BY PRE-COMMIT HOOK\n\n")
for file in files:
out.write("prebuilt_usr_share {\n")
out.write(f" name: \"{file}\",\n")
out.write(f" src: \"{file}\",\n")
out.write(" relative_install_path: \"fonts/x11/encodings/\",\n")
out.write("}\n\n")
out.write("prebuilt_usr_share {\n")
out.write(f" name: \"xorg_font_encodings\",\n")
out.write(" src: \"xorg_font_encodings.txt\",\n")
out.write(" relative_install_path: \"fonts/x11/encodings/\",\n")
out.write(" required: [\n")
for file in files:
out.write(f" \"{file}\",\n")
out.write(" ],\n")
out.write("}\n\n")
os.system("git add encodings-output")