-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.sh
executable file
·76 lines (68 loc) · 1.94 KB
/
configure.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
#!/bin/sh
SCRIPT_DIR="$( cd "$(dirname "$0")" ; pwd -P )"
HELP=false
PROJECT_NAME=
BOARD=
for i in "$@"
do
case $i in
-h|--help)
HELP=true
;;
-n=*|--name=*)
PROJECT_NAME="${i#*=}"
;;
-b=*|--board=*)
BOARD="${i#*=}"
;;
*)
echo "${0##*/} - Unknown option $i"
exit 1
;;
esac
done
if $HELP; then
echo "Usage: ${0##*/} [-h|--help] [-r|--rebuild]"
echo ""
echo "Options:"
echo "-h | --help Display this message"
echo "-n=project_name | --name=project_name Set the project name in CMakeFileList.txt and flash.sh."
echo "-b=pico|picow | --board=pico|picow Specify the board to be used, no board type uses the repository default."
exit 0
fi
#
# Check if we have a project name.
#
if [ -z "$PROJECT_NAME" ]; then
echo "No project name specified, using default name 'PicoApp'."
PROJECT_NAME='PicoApp'
fi
#
# See if we have a board type.
#
if [ -z "$BOARD" ]; then
echo "No board type specified, using repository default (pico)."
BOARD=pico
fi
CMAKE_FLAGS=
if [ "$BOARD" = "pico" ]; then
echo "Using Raspberry Pi Pico board."
CMAKE_FLAGS="-DPICO_BOARD=pico"
elif [ "$BOARD" = "picow" ]; then
echo "Using Raspberry Pi Pico W (WiFi and Bluetooth) board."
CMAKE_FLAGS="-DPICO_BOARD=pico_w"
else
echo "Unknown board type $BOARD."
exit 1
fi
cp -f $SCRIPT_DIR/templates/$BOARD/CMakeLists.txt $SCRIPT_DIR/CMakeLists.txt
cp -f $SCRIPT_DIR/templates/$BOARD/main.cpp $SCRIPT_DIR/src/main.cpp
#
# Change the project and binary file names in CMakeLists.txt, flash.sh and VS Code launch.json files.
#
sed -i.bak "s/projectname/$PROJECT_NAME/g" $SCRIPT_DIR/CMakeLists.txt
sed -i.bak "s/projectname/$PROJECT_NAME/g" $SCRIPT_DIR/flash.sh
sed -i.bak "s/projectname/$PROJECT_NAME/g" $SCRIPT_DIR/.vscode/launch.json
rm $SCRIPT_DIR/*.bak
rm $SCRIPT_DIR/.vscode/*.bak
cmake $CMAKE_FLAGS -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -S . -B $SCRIPT_DIR/build