-
-
Notifications
You must be signed in to change notification settings - Fork 26
/
ufbt.ps1
76 lines (65 loc) · 2.06 KB
/
ufbt.ps1
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
76
Push-Location $PSScriptRoot
$FW_CDEF = ""
if (('official-dev', 'off-dev', 'od').Contains($args[0])) {
$FW_CDEF = "TOTP_FIRMWARE_OFFICIAL_DEV"
}
elseif (('official-stable', 'off-stbl', 'os').Contains($args[0])) {
$FW_CDEF = "TOTP_FIRMWARE_OFFICIAL_STABLE"
}
elseif (('u', 'ul', 'unleashed', 'ud', 'uld', 'unleashed-dev').Contains($args[0])) {
$FW_CDEF = "TOTP_FIRMWARE_UNLEASHED"
}
elseif (('momentum-stable', 'mts', 'ms', 'momentum-dev', 'mtd', 'md').Contains($args[0])) {
$FW_CDEF = "TOTP_FIRMWARE_MOMENTUM"
}
else {
throw "Unable to recognize which firmware to use"
}
$i = 1
$args_ls = @()
$cpp_defines = @(
"/*",
"THIS FILE IS AUTOGENERATED BY UFBT WRAPPER APP",
"DO NOT EDIT\REMOVE\COMMIT IT",
"GO AWAY! LEAVE IT ALONE!",
"*/",
"#define TOTP_TARGET_FIRMWARE $FW_CDEF")
$run_cleanup = $false
while ($i -lt $args.Count) {
if ($args[$i] -eq '-D') {
$define = $args[$i + 1].Split('=')
if ($define.Length -gt 1) {
$cpp_defines += "#define $($define[0]) $($define[1])"
}
else {
$cpp_defines += "#define $($define[0])"
}
$i = $i + 2
}
elseif ($args[$i] -eq '--clean') {
$run_cleanup = $true
$i = $i + 1
}
else {
$args_ls += $args[$i]
$i = $i + 1
}
}
./ufbt-fm.ps1 use $args[0]
Push-Location totp
[System.IO.File]::WriteAllLines((Join-Path (Resolve-Path "config/app/") "ufbt_def.h"), $cpp_defines)
if ($run_cleanup) {
$ufbt_dist_dir = "dist"
if (Test-Path -PathType Container $ufbt_dist_dir) {
Remove-Item "$ufbt_dist_dir/*" -Recurse -Force
}
$ufbt_build_dir = Join-Path (Resolve-Path "~/") ".ufbt/build"
if (Test-Path -PathType Container $ufbt_build_dir) {
Remove-Item "$ufbt_build_dir/*" -Recurse -Force
}
}
$assets_py = Join-Path (Resolve-Path "~/") ".ufbt/current/scripts/assets.py"
(Get-Content $assets_py -Raw) -replace '"../targets/f7/api_symbols.csv"', '"../sdk_headers/f7_sdk/targets/f7/api_symbols.csv"' | Set-Content $assets_py -NoNewline
ufbt $args_ls
Pop-Location
Pop-Location