-
Notifications
You must be signed in to change notification settings - Fork 19
/
build.sh
executable file
·109 lines (103 loc) · 2.89 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
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
105
106
107
108
109
#!/usr/bin/env bash
set -euo pipefail
OUTPUT_NAME=${1:-./output}
# Build and test the solutions
pushd exercise-solutions
cargo test
cargo test --examples
cargo fmt --check
pushd connected-mailbox
cargo test
cargo fmt --check
popd
pushd multi-threaded-mailbox
cargo test
cargo fmt --check
popd
popd
pushd qemu-code
pushd uart-driver
# Build from source because armv8r-none-eabihf isn't Tier 2
RUSTC_BOOTSTRAP=1 cargo build -Zbuild-std=core
popd
popd
pushd nrf52-code
pushd boards/dk
cargo build --target=thumbv7em-none-eabihf
cargo fmt --check
popd
pushd boards/dk-solution
cargo build --target=thumbv7em-none-eabihf
cargo fmt --check
popd
pushd boards/dongle
cargo build --target=thumbv7em-none-eabihf
cargo fmt --check
popd
pushd radio-app
cargo build --target=thumbv7em-none-eabihf --release
cargo fmt --check
popd
for i in usb-lib-solutions/*; do
pushd $i
cargo build --target=thumbv7em-none-eabihf --release
cargo fmt --check
cargo test
popd
done
pushd usb-lib
cargo build --target=thumbv7em-none-eabihf --release
cargo fmt --check
popd
pushd usb-app
cargo build --target=thumbv7em-none-eabihf --release
cargo fmt --check
popd
pushd usb-app-solutions
cargo build --target=thumbv7em-none-eabihf --release
cargo fmt --check
popd
pushd consts
cargo build
cargo fmt --check
popd
pushd puzzle-fw
cargo build --target=thumbv7em-none-eabihf --release
cargo fmt --check
popd
pushd loopback-fw
cargo build --target=thumbv7em-none-eabihf --release
cargo fmt --check
popd
popd
# Only build the templates (they will panic at run-time due to the use of todo!)
pushd exercise-templates
cargo build
cargo fmt --check
popd
pushd exercise-book
mdbook test
mdbook build
popd
rm -rf "${OUTPUT_NAME}"
mkdir -p "${OUTPUT_NAME}"
mkdir -p "${OUTPUT_NAME}/exercise-book"
# Note: the use of the html subdirectory here is deliberate.
# a) it allows the book to be provided as PDF in the future
# b) it ensures the `../../exercise-solutions` links in the markdown also work
# when loaded from this output folder. The `../..` comes about
# because the Markdown book source lives in the `src` subfolder and so you
# have to go up one extra level. Adding an extra level in the output
# is easier than re-writing all the links at build time.
mv ./exercise-book/book "${OUTPUT_NAME}/exercise-book/html"
cp -r ./exercise-templates "${OUTPUT_NAME}/"
cp -r ./exercise-solutions "${OUTPUT_NAME}/"
cp -r ./nrf52-code "${OUTPUT_NAME}/"
cp -r ./qemu-code "${OUTPUT_NAME}/"
cp -r ./xtask "${OUTPUT_NAME}/"
cp -r ./.cargo "${OUTPUT_NAME}/"
cp -r ./tools "${OUTPUT_NAME}/"
cp ./nrf52-code/puzzle-fw/target/thumbv7em-none-eabihf/release/puzzle-fw "${OUTPUT_NAME}/nrf52-code/boards/dongle-fw/puzzle-fw"
cp ./nrf52-code/loopback-fw/target/thumbv7em-none-eabihf/release/loopback-fw "${OUTPUT_NAME}/nrf52-code/boards/dongle-fw/loopback-fw"
find "${OUTPUT_NAME}" -name target -type d -print0 | xargs -0 rm -rf
zip -r "${OUTPUT_NAME}.zip" "${OUTPUT_NAME}"