-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSConstruct
More file actions
75 lines (69 loc) · 2.77 KB
/
Copy pathSConstruct
File metadata and controls
75 lines (69 loc) · 2.77 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
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
66
67
68
69
70
71
72
73
74
75
from pathlib import Path
import os
import platform
import shutil
import sys
arch = platform.machine()
homebrew_toolchain = "/opt/homebrew/bin"
has_homebrew_aarch64 = os.path.exists(os.path.join(homebrew_toolchain, "aarch64-linux-gnu-gcc"))
version = "v0.0.3"
static_lib = "static_lib"
update = False
if "CardputerZero" in os.environ:
if not os.path.exists("build/config/config_tmp.mk"):
os.makedirs("build/config", exist_ok=True)
with open("build/config/config_tmp.mk", "w") as f:
f.write("CONFIG_V9_5_LV_USE_LINUX_FBDEV=y\n")
f.write("CONFIG_V9_5_LV_USE_EVDEV=y\n")
f.write("CONFIG_V9_5_LV_DRAW_SW_ASM_NEON=y\n")
f.write("CONFIG_V9_5_LV_USE_DRAW_SW_ASM=1\n")
if has_homebrew_aarch64:
f.write(f'CONFIG_TOOLCHAIN_PATH="{homebrew_toolchain}"\n')
f.write('CONFIG_TOOLCHAIN_PREFIX="aarch64-linux-gnu-"\n')
f.write(f'''CONFIG_TOOLCHAIN_SYSROOT="{os.path.join(sys.path[0], static_lib)}"\n''')
elif arch != "aarch64":
if not os.path.exists("build/config/config_tmp.mk"):
os.makedirs("build/config", exist_ok=True)
with open("build/config/config_tmp.mk", "w") as f:
f.write("CONFIG_V9_5_LV_USE_SDL=y\n")
else:
if not os.path.exists("build/config/config_tmp.mk"):
os.makedirs("build/config", exist_ok=True)
with open("build/config/config_tmp.mk", "w") as f:
f.write("CONFIG_V9_5_LV_USE_LINUX_FBDEV=y\n")
f.write("CONFIG_V9_5_LV_USE_EVDEV=y\n")
f.write("CONFIG_V9_5_LV_DRAW_SW_ASM_NEON=y\n")
f.write("CONFIG_V9_5_LV_USE_DRAW_SW_ASM=1\n")
local_path = Path(os.getcwd())
sdk_candidates = [
local_path.parent.parent / "SDK",
local_path.parent.parent / "Launcher" / "SDK",
]
sdk_path = next((path for path in sdk_candidates if path.exists()), sdk_candidates[0])
os.environ["SDK_PATH"] = str(sdk_path)
os.environ["EXT_COMPONENTS_PATH"] = str(sdk_path.parent / "ext_components")
env = SConscript(
str(sdk_path / "tools" / "scons" / "project.py"),
variant_dir=os.getcwd(),
duplicate=0,
)
if "CardputerZero" in os.environ:
if not os.path.exists(static_lib):
update = True
else:
try:
with open(str(Path(static_lib) / "version"), "r") as f:
if version != f.read().strip():
update = True
except Exception:
update = True
if update:
with open(env["PROJECT_TOOL_S"]) as f:
exec(f.read())
down_url = "https://github.com/dianjixz/M5CardputerZero-UserDemo/releases/download/{}/sdk_bsp.tar.gz".format(
version
)
down_path = check_wget_down(down_url, "static_lib_{}.tar.gz".format(version))
if os.path.exists(static_lib):
shutil.rmtree(static_lib)
shutil.move(down_path, static_lib)