-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate_device.py
65 lines (50 loc) · 1.48 KB
/
generate_device.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import sys
import os
def create_one_device(name: str):
print("Creating structure for", name)
print("mkdir =>", name)
os.mkdir(name)
print("chdir =>", name)
os.chdir(name)
# Create common recovery/-> recovery/ symlink
def symlink(src: str, dest: str):
print(f"symlink {src} => {dest}")
os.symlink(src, dest)
symlink("../exynos7885-common/recovery", "recovery")
def create_and_write(filename: str, content: str):
print(f"Creating {filename}")
with open(filename, "w") as f:
f.write(f"# Generated by {__file__}")
f.write(content)
# Create product makefile
create_and_write(
f"twrp_{name}.mk",
f"""
$(call inherit-product, device/samsung/exynos7885-common/twrp_common.mk)
## Device identifier. This must come after all inclusions
PRODUCT_NAME := twrp_{name}
PRODUCT_DEVICE := {name}
PRODUCT_MODEL := Galaxy {name.capitalize()}""",
)
create_and_write(
f"BoardConfig.mk",
f"""
include device/samsung/exynos7885-common/BoardConfigCommon.mk
""",
)
create_and_write(
"AndroidProducts.mk",
f"""
PRODUCT_MAKEFILES := $(LOCAL_DIR)/twrp_{name}.mk
""",
)
print("chdir =>", "..")
os.chdir('..')
def main():
if len(sys.argv) < 2:
print("Usage: python create_twrp_device.py <device_names>...")
sys.exit(1)
for device in sys.argv[1:]:
create_one_device(device)
if __name__ == "__main__":
main()