-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.sh
62 lines (44 loc) · 1.5 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
#!/bin/bash -e
echo "Building the project in Linux environment"
# select architecture
: ${ARCHITECTURE:=stm32}
# select to create eclipse project files
: ${ECLIPSE_IDE:=false}
# select to clean previous builds
: ${CLEANBUILD:=false}
# Compile objects in parallel, the -jN flag in make
: ${PARALLEL:=$(expr $(getconf _NPROCESSORS_ONLN) + 1)}
# Current working directory
: ${WORKING_DIR:=$(pwd)}
# default generator
: ${IDE_GENERATOR:="Unix Makefiles"}
# cmake scripts folder
: ${SCRIPTS_CMAKE:=${WORKING_DIR}/cmake}
# select cmake toolchain
: ${CMAKE_TOOLCHAIN:=TOOLCHAIN_arm_none_eabi_cortex_m4.cmake}
if [ ${ECLIPSE_IDE} == true ]; then
IDE_GENERATOR="Eclipse CDT4 - Unix Makefiles"
fi
BUILD_ARCH_DIR=${WORKING_DIR}/build-${ARCHITECTURE}
if [ ${ARCHITECTURE} == "stm32" ]; then
CMAKE_FLAGS="${CMAKE_FLAGS} -DCMAKE_TOOLCHAIN_FILE=${SCRIPTS_CMAKE}/${CMAKE_TOOLCHAIN}"
else
>&2 echo "*** Error: Architecture '${ARCHITECTURE}' unknown."
exit 1
fi
if [ ${CLEANBUILD} == true ]; then
echo "- removing build directory: ${BUILD_ARCH_DIR}"
rm -rf ${BUILD_ARCH_DIR}
fi
echo "--- Pre-cmake ---"
echo "architecture : ${ARCHITECTURE}"
echo "distclean : ${CLEANBUILD}"
echo "parallel : ${PARALLEL}"
echo "cmake flags : ${CMAKE_FLAGS}"
echo "cmake scripts : ${SCRIPTS_CMAKE}"
echo "IDE generator : ${IDE_GENERATOR}"
#cd src
# setup cmake
cmake -G"${IDE_GENERATOR}" -H. -B${BUILD_ARCH_DIR} ${CMAKE_FLAGS}
# build
make -C ${BUILD_ARCH_DIR} -j${PARALLEL} --no-print-directory