-
Notifications
You must be signed in to change notification settings - Fork 21
/
test-build-examples.sh
executable file
·72 lines (61 loc) · 1.48 KB
/
test-build-examples.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
#!/bin/bash
set -eu
_step_counter=0
: ${TEST_DIR:="$(pwd)/build_examples"}
: ${EXAMPLES_DIR:="$(pwd)/_examples"}
step() {
_step_counter=$(( _step_counter + 1 ))
printf '\n\033[1;36m%d) %s\033[0m\n' $_step_counter "$@" >&2 # bold cyan
}
step 'Prepare'
rm -rf "$TEST_DIR"
echo "$TEST_DIR"
mkdir -p "$TEST_DIR"
cd "$TEST_DIR"
mkdir sdk
cd sdk
cp -r ../../bcl bcl
cp -r ../../twr twr
cp -r ../../lib lib
cp -r ../../fonts fonts
cp -r ../../stm stm
cp -r ../../toolchain toolchain
cp -r ../../tools tools
cp -r ../../sys sys
cp -r ../../CMakeLists.txt CMakeLists.txt
cd ..
echo """
cmake_minimum_required(VERSION 3.20.0)
# Setup project name and languages
project(firmware LANGUAGES C ASM)
add_subdirectory(sdk)
# If you need to add some source files to the project add them to the 'src' folder and update CMakeLists there
add_subdirectory(src)
""" > CMakeLists.txt
for dir in $EXAMPLES_DIR/*/
do
rm -rf src
rm -rf obj/debug/
rm -rf out/debug/
dir=${dir%*/}
step "Test ${dir##*/}"
cp -r $dir src
echo """
# List any additional sources here
target_sources(
\${CMAKE_PROJECT_NAME}
PUBLIC
application.c
)
# If you added some folder with header files you need to list them here
target_include_directories(
\${CMAKE_PROJECT_NAME}
PUBLIC
\${CMAKE_CURRENT_SOURCE_DIR}
)
""" > src/CMakeLists.txt
cmake -B obj/debug . -G Ninja -DCMAKE_TOOLCHAIN_FILE=sdk/toolchain/toolchain.cmake -DTYPE=debug
ninja -C obj/debug
done
step 'Clean'
rm -rf "$TEST_DIR"