d script revamping

This commit is contained in:
Dario Nieuwenhuis 2021-07-05 02:08:38 +02:00
parent 923958119a
commit ffa42e2361

47
d
View File

@ -9,22 +9,25 @@ for i in jq wget svd git; do
command -v "$i" &>/dev/null || die "Missing the command line tool '$i'" command -v "$i" &>/dev/null || die "Missing the command line tool '$i'"
done done
case "$1" in CMD=$1
download_all) shift
./d download_mcufinder
./d download_svd case "$CMD" in
./d download_headers download-all)
./d download_cubedb ./d download-mcufinder
./d download-svd
./d download-headers
./d download-cubedb
;; ;;
download_mcufinder) download-mcufinder)
mkdir -p sources/mcufinder mkdir -p sources/mcufinder
wget http://stmcufinder.com/API/getFiles.php -O sources/mcufinder/files.json wget http://stmcufinder.com/API/getFiles.php -O sources/mcufinder/files.json
wget http://stmcufinder.com/API/getMCUsForMCUFinderPC.php -O sources/mcufinder/mcus.json wget http://stmcufinder.com/API/getMCUsForMCUFinderPC.php -O sources/mcufinder/mcus.json
;; ;;
download_pdf) download-pdf)
jq -r .Files[].URL < sources/mcufinder/files.json | wget -P sources/pdf/ -N -i - jq -r .Files[].URL < sources/mcufinder/files.json | wget -P sources/pdf/ -N -i -
;; ;;
download_svd) download-svd)
rm -rf ./sources/git/stm32-rs rm -rf ./sources/git/stm32-rs
git clone --depth 1 https://github.com/stm32-rs/stm32-rs.git ./sources/git/stm32-rs git clone --depth 1 https://github.com/stm32-rs/stm32-rs.git ./sources/git/stm32-rs
(cd ./sources/git/stm32-rs; make svdformat) (cd ./sources/git/stm32-rs; make svdformat)
@ -34,7 +37,7 @@ case "$1" in
cp $f sources/svd/$base.svd cp $f sources/svd/$base.svd
done done
;; ;;
download_headers) download-headers)
for f in F0 F1 F2 F3 F4 F7 H7 L0 L1 L4 L5 G0 G4 WB WL; do for f in F0 F1 F2 F3 F4 F7 H7 L0 L1 L4 L5 G0 G4 WB WL; do
rm -rf ./sources/git/STM32Cube$f rm -rf ./sources/git/STM32Cube$f
git clone --depth 1 https://github.com/STMicroelectronics/STM32Cube$f sources/git/STM32Cube$f git clone --depth 1 https://github.com/STMicroelectronics/STM32Cube$f sources/git/STM32Cube$f
@ -46,27 +49,31 @@ case "$1" in
rm sources/headers/system_*.h rm sources/headers/system_*.h
rm sources/headers/partition_*.h rm sources/headers/partition_*.h
;; ;;
download_cubedb) download-cubedb)
rm -rf sources/cubedb rm -rf sources/cubedb
git clone --depth 1 https://github.com/embassy-rs/stm32cube-database.git sources/cubedb git clone --depth 1 https://github.com/embassy-rs/stm32cube-database.git sources/cubedb
;; ;;
extract_all) install-chiptool)
peri=$2 cargo install --git https://github.com/embassy-rs/chiptool
mkdir -p tmp/$peri ;;
extract-all)
peri=$1
shift
echo $@
cargo build --release --manifest-path ../svd2rust/Cargo.toml rm -rf tmp/$peri
mkdir -p tmp/$peri
for f in `ls sources/svd`; do for f in `ls sources/svd`; do
f=${f#"stm32"} f=${f#"stm32"}
f=${f%".svd"} f=${f%".svd"}
echo -n processing $f ... echo -n processing $f ...
RUST_LOG=info ../svd2rust/target/release/svd4rust extract-peripheral --svd sources/svd/stm32$f.svd --transform transform.yaml --peripheral $peri > tmp/$peri/$f.yaml 2> tmp/$peri/$f.yaml.out if chiptool extract-peripheral --svd sources/svd/stm32$f.svd --peripheral $peri $@ > tmp/$peri/$f.yaml 2> tmp/$peri/$f.err; then
if [ $? -ne 0 ]; then rm tmp/$peri/$f.err
echo OK
else
rm tmp/$peri/$f.yaml rm tmp/$peri/$f.yaml
echo FAIL echo FAIL
else
rm tmp/$peri/$f.yaml.out
echo OK
fi fi
done done
;; ;;