-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathbuild.sh
123 lines (110 loc) · 3.36 KB
/
build.sh
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/bin/bash
set -e
set -o pipefail
BUILD_FOLDER="$(pwd)/build"
BUILD_SIMULATOR_FOLDER="$(pwd)/build_simulator"
TOOLS_FOLDER="$(pwd)/tools"
MAKE_OAT_FILE_PATH="${TOOLS_FOLDER}/ota_file_maker"
MAKE_PADDING_FILE_PATH="${TOOLS_FOLDER}/padding_bin_file"
ASTYLE_PATH="${TOOLS_FOLDER}/AStyle.sh"
PACK_PATH="$(pwd)/pack.sh"
LANGUAGE_PATH="$(pwd)/src/ui/lv_i18n"
LANGUAGE_SCRIPT="python3 data_loader.py"
RUST_C_PATH="$(pwd)/rust/rust_c"
declare -A build_options=(
["log"]=false
["copy"]=false
["production"]=false
["screen"]=false
["debug"]=false
["format"]=false
["release"]=false
["rebuild"]=false
["btc_only"]=false
["cypherpunk"]=false
["simulator"]=false
["language"]=false
["clean"]=false
)
for arg in "$@"; do
if [[ "$arg" == "format" ]]; then
pushd "$TOOLS_FOLDER"
echo "Formatting files..."
bash "$ASTYLE_PATH"
popd
else
echo "Building with option: $arg"
build_options["$arg"]=true
fi
done
echo "Building with options: ${build_options[@]}"
if [[ "${build_options[rebuild]}" == true ]]; then
if [[ -d "$BUILD_FOLDER" ]]; then
rm -rf "$BUILD_FOLDER"
fi
pushd "$RUST_C_PATH"
cargo clean
popd
fi
mkdir -p "$BUILD_FOLDER"
if [[ ! -f "$BUILD_FOLDER/padding_bin_file.py" ]]; then
cp "$MAKE_PADDING_FILE_PATH/padding_bin_file.py" "$BUILD_FOLDER/padding_bin_file.py"
fi
execute_build() {
if [[ "${build_options[language]}" == true ]]; then
pushd "$LANGUAGE_PATH"
$LANGUAGE_SCRIPT
popd
fi
cmake_parm=""
if [[ "${build_options[production]}" == true ]]; then
cmake_parm="${cmake_parm} -DBUILD_PRODUCTION=true"
fi
if [[ "${build_options[btc_only]}" == true ]]; then
cmake_parm="${cmake_parm} -DBTC_ONLY=true"
fi
if [[ "${build_options[cypherpunk]}" == true ]]; then
cmake_parm="${cmake_parm} -DCYBERPUNK=true"
fi
if [[ "${build_options[screen]}" == true ]]; then
cmake_parm="${cmake_parm} -DENABLE_SCREEN_SHOT=true"
fi
if [[ "${build_options[debug]}" == true ]]; then
cmake_parm="${cmake_parm} -DDEBUG_MEMORY=true"
fi
if [[ "${build_options[simulator]}" == true ]]; then
mkdir -p "$BUILD_SIMULATOR_FOLDER"
pushd "$BUILD_SIMULATOR_FOLDER"
cmake -G "Unix Makefiles" -DBUILD_TYPE=Simulator $cmake_parm ..
make -j16
popd
else
pushd "$BUILD_FOLDER"
cmake -G "Unix Makefiles" $cmake_parm ..
if [[ "${build_options[log]}" == true ]]; then
make -j16 > makefile.log 2>&1
else
make -j16
fi
python3 padding_bin_file.py mh1903.bin
popd
fi
if [[ "${build_options[copy]}" == true ]]; then
echo "Generating pillar.bin file..."
pushd "$MAKE_OAT_FILE_PATH"
echo "Generating OTA files..."
bash make_ota_file.sh "$(pwd)/build/pillar.bin"
bash make_ota_file.sh "$(pwd)/build/keystone3.bin"
bash make_ota_file.sh "F:/pillar.bin"
popd
elif [[ "${build_options[release]}" == true ]]; then
pushd "$MAKE_OAT_FILE_PATH"
echo "Generating release files..."
bash make_ota_file.sh "$(pwd)/build/pillar.bin"
bash make_ota_file.sh "$(pwd)/build/keystone3.bin"
popd
elif [[ "${build_options[simulator]}" == true ]]; then
./build/simulator.exe
fi
}
execute_build