-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathupdate.sh
executable file
·46 lines (35 loc) · 1.37 KB
/
update.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
#!/usr/bin/env bash
# Path to `svd`/`svdtools`
SVDTOOLS="${SVDTOOLS:-svdtools}"
set -ex
cargo install --version 0.32.0 svd2rust --locked
cargo install --version 0.12.1 form --locked
rustup component add rustfmt
if [ "$SVDTOOLS" == "svdtools" ]; then
cargo install --version 0.3.20 svdtools --locked
else
python3 -mvenv --clear .venv
source .venv/bin/activate
pip3 install --upgrade "svdtools==0.1.25"
fi
$SVDTOOLS patch svd/rp2040.yaml
if [ "$SVDTOOLS" != "svdtools" ]; then
deactivate
fi
rm -rf src
mkdir src
svd2rust -i svd/rp2040.svd.patched --reexport-core-peripherals --reexport-interrupt --ident-formats-theme legacy
form -i lib.rs -o src
rm lib.rs
cargo fmt
# Original svd has \n (two chars) in it, which gets converted to "\n" by svd2rust
# If we convert them to newline characters in the SVD, they don't turn up in markdown so docs suffers
# So, convert \n to [spc] [spc] [newline], then strip the spaces out if there are consecutive [newlines]
# This means that by the time we're in markdown \n\n becomes new paragraph, and \n becomes a new line
if [ "$(uname)" == "Darwin" ]; then
find src -name '*.rs' -exec sed -i '' -e 's/\\n/ \n/g' -e 's/\n \n/\n\n/g' {} \;
else
find src -name '*.rs' -exec sed -i -e 's/\\n/ \n/g' -e 's/\n \n/\n\n/g' {} \;
fi
# Sort specified fields alphanumerically for easier consumption in docs.rs
./sortFieldsAlphaNum.sh