Last active
November 16, 2025 20:38
-
-
Save geky/31f79a3be0abfdbb2020f17140c4d4bb to your computer and use it in GitHub Desktop.
Watch littlefs cross-compiled thumb sizes easily
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # some flags: | |
| # -k - run in watch mode | |
| # -d - show diff | |
| # -c - cat (don't buffer) | |
| set -eu -o pipefail | |
| # run in watch mode? | |
| if [[ "$@" == *-k* ]] | |
| then | |
| ./scripts/watch.py \ | |
| $([[ "$@" == *-c* ]] && echo -c || echo -n5) \ | |
| -K lfs3.h -K lfs3_util.h \ | |
| -K lfs3.c -K lfs3_util.c \ | |
| $0 $(echo "$@" | sed 's/-k//') | |
| exit | |
| fi | |
| # compile for thumb | |
| BUILDDIR=thumb \ | |
| CC='arm-linux-gnueabi-gcc -mthumb --static -Wno-stringop-overflow' \ | |
| CFLAGS='-DLFS3_NO_LOG -DLFS3_NO_ASSERT' \ | |
| make clean build \ | |
| thumb/lfs3.code.csv \ | |
| thumb/lfs3.data.csv \ | |
| thumb/lfs3.stack.csv \ | |
| thumb/lfs3.ctx.csv | |
| # success? | |
| if [ $? -eq 0 ] | |
| then | |
| # keep last three builds | |
| cp thumb/liblfs3{.2,.3}.a || true | |
| cp thumb/lfs3{.2,.3}.o || true | |
| cp thumb/lfs3_util{.2,.3}.o || true | |
| cp thumb/lfs3{.2,.3}.ci || true | |
| cp thumb/lfs3_util{.2,.3}.ci || true | |
| cp thumb/lfs3.code{.2,.3}.csv || true | |
| cp thumb/lfs3.data{.2,.3}.csv || true | |
| cp thumb/lfs3.stack{.2,.3}.csv || true | |
| cp thumb/lfs3.ctx{.2,.3}.csv || true | |
| cp thumb/liblfs3{.1,.2}.a || true | |
| cp thumb/lfs3{.1,.2}.o || true | |
| cp thumb/lfs3_util{.1,.2}.o || true | |
| cp thumb/lfs3{.1,.2}.ci || true | |
| cp thumb/lfs3_util{.1,.2}.ci || true | |
| cp thumb/lfs3.code{.1,.2}.csv || true | |
| cp thumb/lfs3.data{.1,.2}.csv || true | |
| cp thumb/lfs3.stack{.1,.2}.csv || true | |
| cp thumb/lfs3.ctx{.1,.2}.csv || true | |
| cp thumb/liblfs3{,.1}.a | |
| cp thumb/lfs3{,.1}.o | |
| cp thumb/lfs3_util{,.1}.o | |
| cp thumb/lfs3{,.1}.ci | |
| cp thumb/lfs3_util{,.1}.ci | |
| cp thumb/lfs3.code{,.1}.csv | |
| cp thumb/lfs3.data{,.1}.csv | |
| cp thumb/lfs3.stack{,.1}.csv | |
| cp thumb/lfs3.ctx{,.1}.csv | |
| if git diff --exit-code --quiet | |
| then | |
| cp thumb/liblfs3{,.c}.a | |
| cp thumb/lfs3{,.c}.o | |
| cp thumb/lfs3_util{,.c}.o | |
| cp thumb/lfs3{,.c}.ci | |
| cp thumb/lfs3_util{,.c}.ci | |
| cp thumb/lfs3.code{,.c}.csv | |
| cp thumb/lfs3.data{,.c}.csv | |
| cp thumb/lfs3.stack{,.c}.csv | |
| cp thumb/lfs3.ctx{,.c}.csv | |
| fi | |
| ./scripts/csv.py \ | |
| <(./scripts/csv.py \ | |
| -bi=0 -bbuild='commit:' -o- \ | |
| thumb/lfs3.code.c.csv -fcode=code_size \ | |
| thumb/lfs3.data.c.csv -fdata=data_size \ | |
| thumb/lfs3.stack.c.csv -fstack='max(stack_limit)' \ | |
| thumb/lfs3.ctx.c.csv -fctx='max(ctx_size)' \ | |
| || true) \ | |
| <(./scripts/csv.py \ | |
| -bi=1 -bbuild='prev~2:' -o- \ | |
| thumb/lfs3.code.3.csv -fcode=code_size \ | |
| thumb/lfs3.data.3.csv -fdata=data_size \ | |
| thumb/lfs3.stack.3.csv -fstack='max(stack_limit)' \ | |
| thumb/lfs3.ctx.3.csv -fctx='max(ctx_size)' \ | |
| || true) \ | |
| <(./scripts/csv.py \ | |
| -bi=2 -bbuild='prev~1:' -o- \ | |
| thumb/lfs3.code.2.csv -fcode=code_size \ | |
| thumb/lfs3.data.2.csv -fdata=data_size \ | |
| thumb/lfs3.stack.2.csv -fstack='max(stack_limit)' \ | |
| thumb/lfs3.ctx.2.csv -fctx='max(ctx_size)' \ | |
| || true) \ | |
| <(./scripts/csv.py \ | |
| -bi=3 -bbuild='current:' -o- \ | |
| thumb/lfs3.code.csv -fcode=code_size \ | |
| thumb/lfs3.data.csv -fdata=data_size \ | |
| thumb/lfs3.stack.csv -fstack='max(stack_limit)' \ | |
| thumb/lfs3.ctx.csv -fctx='max(ctx_size)' ) \ | |
| -Si -bbuild -fcode -fdata -fstack -fctx -Q \ | |
| $([[ "$@" == *-d* ]] && echo -ccommit:) | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment