-
Notifications
You must be signed in to change notification settings - Fork 487
/
Copy pathbuild.sh
66 lines (58 loc) · 1.38 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
#!/bin/bash
# Set error handling
set -e
# Function to display usage
show_usage() {
echo "Usage: ./build.sh [option]"
echo "Options:"
echo " build - Only compile library and examples"
echo " test - Only compile and run tests"
echo " all - Build everything and run tests (default)"
}
# Function to compile for a specific board
compile_for_board() {
local fqbn=$1
local sketch=$2
echo "📦 Compiling $sketch for $fqbn..."
arduino-cli compile --fqbn $fqbn "$sketch" --library .
}
# Function to build library and examples
build() {
echo "🔨 Building library and examples..."
# Compile all examples
echo "🔍 Compiling examples..."
for example in examples/*/*.ino; do
if [ -f "$example" ]; then
echo "Building example: $example"
compile_for_board "arduino:avr:uno" "$example"
fi
done
}
# Function to run tests
run_tests() {
echo "🧪 Running tests..."
for test in test/*/*.ino; do
if [ -f "$test" ]; then
echo "Running test: $test"
compile_for_board "arduino:avr:uno" "$test"
fi
done
}
# Main execution
case "${1:-all}" in
"build")
build
;;
"test")
run_tests
;;
"all")
build
run_tests
;;
*)
show_usage
exit 1
;;
esac
echo "✅ Process completed!"