-
Notifications
You must be signed in to change notification settings - Fork 15
/
build.sh
executable file
·69 lines (59 loc) · 1.16 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
#!/usr/bin/env bash
set -euo pipefail
source ./targets.sh
usage() {
echo "Usage: build.sh [target]"
usage_target
}
if ! check_target "$@"; then
usage
exit 64
fi
declare -r TARGET="${1}"
check_buildroot() {
if [[ -n ${TOOLCHAIN:-} ]] && [[ -d $TOOLCHAIN ]]; then
return
elif ! [[ -d $BUILDROOT ]]; then
echo "Please set the BUILDROOT or TOOLCHAIN environment variable"
exit 1
fi
TOOLCHAIN="${BUILDROOT}/output/host/"
}
make_buildroot() {
if [[ -z ${BUILDROOT:-} ]]; then
return
fi
cd "$BUILDROOT"
local -a deps=(toolchain sdl sdl_image)
if [[ "$TARGET" == retrofw ]]; then
deps+=(freetype)
else
deps+=(sdl_ttf sdl_gfx)
fi
if (( ${#deps[@]} )); then
make "${deps[@]}" BR2_JLEVEL=0
fi
cd -
}
build() {
mkdir -p "build-$TARGET"
cd "build-$TARGET"
cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DTARGET_PLATFORM="$TARGET" \
-DCMAKE_TOOLCHAIN_FILE="${TOOLCHAIN}/usr/share/buildroot/toolchainfile.cmake" \
-DRES_DIR=""
cmake --build . -j $(getconf _NPROCESSORS_ONLN)
cd -
}
package_opk() {
./package-opk.sh "$TARGET"
}
main() {
check_buildroot
set -x
make_buildroot
build
package_opk
}
main