-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathbuild.sh
executable file
·70 lines (58 loc) · 1.4 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
#!/bin/sh
# USAGE:
# build.sh <platform> <dist-suffix>
# Provide one of the following as argument to adjust platform
# pico (default)
# pico2
FLAVOR=pico
DIST_SUFFIX=
if [ $# -gt 0 ]; then
FLAVOR=$1
shift
fi
if [ $# -gt 0 ]; then
DIST_SUFFIX="-$1"
shift
fi
BUILD_DIR="build-${FLAVOR}"
DIST_DIR="./dist"
GCC="/usr/bin/arm-none-eabi-gcc"
GPP="/usr/bin/arm-none-eabi-g++"
# Force the elf and uf2 binary files to always be regenerated on build
# (this is so old uf2 files don't pile up in dist directory)
rm ${BUILD_DIR}/src/*/*/*.elf
rm ${BUILD_DIR}/src/*/*/*.uf2
cmake \
--no-warn-unused-cli \
-DPICO_BOARD=${FLAVOR} \
-DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE \
-DCMAKE_BUILD_TYPE:STRING=Release \
-DCMAKE_C_COMPILER:FILEPATH=${GCC} \
-DCMAKE_CXX_COMPILER:FILEPATH=${GPP} \
-DDREAMCAST_CONTROLLER_USB_PICO_TEST:BOOL=FALSE \
-S. \
-B./${BUILD_DIR} \
-G "Unix Makefiles" \
STATUS=$?
if [ $STATUS -ne 0 ]; then
echo "CMake returned error exit code: ${STATUS}"
echo "Exiting"
exit $STATUS
fi
cmake \
--build ${BUILD_DIR} \
--config Release \
--target all \
-j 10 \
STATUS=$?
if [ $STATUS -ne 0 ]; then
echo "CMake returned error exit code: ${STATUS}"
echo "Exiting"
exit $STATUS
fi
mkdir -p ${DIST_DIR}
for file in ${BUILD_DIR}/src/*/*/*.uf2
do
filename=$(basename $file)
cp -v -- "$file" "${DIST_DIR}/${filename%.uf2}${DIST_SUFFIX}.uf2"
done