-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·68 lines (59 loc) · 1.34 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
67
68
#!/bin/bash
NAME=$(basename $(realpath .))
MODE=
TARGET=cortex-m3
FEATURES="--features olimex-p207"
ARG=""
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
--release)
MODE="release"
ARG+="--release"
;;
--target)
TARGET="$2"
shift
;;
--features)
FEATURES="--features $2"
case $2 in
arduino-*)
TARGET=avr-atmel-none
;;
olimex-p207)
TARGET=cortex-m3
;;
*)
echo "unknown board"
exit 1
;;
esac
shift
;;
*)
ARG+=$key
;;
esac
shift
done
echo $MODE $TARGET $FEATURES $ARG
if [ -z $MODE ]; then
MODE=debug
fi
if [ $TARGET == "avr-atmel-none" ]; then
export XARGO_RUST_SRC=~/Documents/Code/Rust/avr-rust/src
rustup default avr-atmel-none
else
rustup default nightly-x86_64-unknown-linux-gnu
fi
#set -x
RUST_TARGET_PATH=. xargo build --target $TARGET $FEATURES $ARG
if [[ $? -eq 0 ]]; then
arm-none-eabi-objcopy target/$TARGET/$MODE/$NAME -O binary target/$TARGET/$MODE/$NAME.bin
arm-none-eabi-objcopy target/$TARGET/$MODE/$NAME -O ihex target/$TARGET/$MODE/$NAME.ihex
arm-none-eabi-objdump -d target/$TARGET/$MODE/$NAME | cargo demangle > target/$TARGET/$MODE/$NAME.disassemble.txt
arm-none-eabi-nm -lSn target/$TARGET/$MODE/$NAME | cargo demangle > target/$TARGET/$MODE/$NAME.symbolTable.txt
arm-none-eabi-size --format=SysV target/$TARGET/$MODE/$NAME > target/$TARGET/$MODE/$NAME.memListSummary.txt
fi
#set +x