-
Notifications
You must be signed in to change notification settings - Fork 1
/
wmake
executable file
·104 lines (89 loc) · 2.06 KB
/
wmake
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/bin/bash
#!/usr/bin/env bash
set -o errexit
trap 'echo "Aborting due to errexit on line $LINENO. Exit code: $?" >&2' ERR
set -o errtrace
set -o pipefail
DEFAULT_IFS="${IFS}"
SAFER_IFS=$'\n\t'
IFS="${SAFER_IFS}"
_ME=$(basename "${0}")
_print_help() {
cat <<HEREDOC
__ .__
__ _ _______ _/ |_ ___________| | ____ ____ ______
\\ \\/ \\/ /\\__ \\\\ __\\/ __ \\_ __ \\ | / _ \\ / _ \\\\____ \\
\\ / / __ \\| | \\ ___/| | \\/ |_( <_> | <_> ) |_> >
\\/\\_/ (____ /__| \\___ >__| |____/\\____/ \\____/| __/
\\/ \\/ |__|
The Embedded C++ code base builder
HEREDOC
}
_build(){
mkdir -p cmake-build-debug
cd cmake-build-debug
echo "Running CMake"
cmake ..
echo "Running Make"
make
echo "Project Built"
cd ..
}
_clean(){
if [ -d "cmake-build-debug" ] ; then
cd cmake-build-debug
make clean
fi
}
_reset() {
rm -rf cmake-build-debug
}
_run() {
./cmake-build-debug/unit
}
_test() {
_build
_run
}
_extract() {
cp .wio/build/targets/tests/tests.elf build/tests.elf
cp .wio/build/targets/tests/tests.hex build/tests.hex
}
_upload() {
wio run --port /dev/ttyACM0 && wcosa monitor
}
_simple() {
root_dir=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
root_dir_name=$(basename "$root_dir")
cd "$root_dir"
if [ "$1" == 'build' ] ; then
echo "Building project"
_build
elif [ "$1" == 'clean' ] ; then
echo "Cleaning project"
_clean
elif [ "$1" == 'reset' ] ; then
echo "Resetting project"
_reset
elif [ "$1" == 'run' ] ; then
_run
elif [ "$1" == 'test' ] ; then
_test
elif [ "$1" == 'extract' ] ; then
_extract
elif [ "$1" == 'upload' ] ; then
_upload
else
_print_help
fi
}
_main() {
# Avoid complex option parsing when only one program option is expected.
if [[ "${1:-}" =~ ^-h|--help$ ]] || [ $# -lt "1" ]
then
_print_help
else
_simple "$@"
fi
}
_main "$@"