summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2025-02-26 16:02:06 -0700
committerLuke T. Shumaker <lukeshu@lukeshu.com>2025-02-26 16:15:32 -0700
commitf3ee711bbd8526e0df8bb5f2ea28fc90a41a58f3 (patch)
treee3e5d4f4baf8f65b98dd962a29b4cdc0ac122ac8
parentb208a19331ee52445b48f0e3418437832dadd843 (diff)
Integrate lint-bin into `make lint`
-rw-r--r--GNUmakefile4
-rwxr-xr-xbuild-aux/lint-bin23
2 files changed, 24 insertions, 3 deletions
diff --git a/GNUmakefile b/GNUmakefile
index 65639e4..0913aec 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -104,7 +104,9 @@ build-aux/venv: build-aux/requirements.txt
# `lint` ###########
lint:
- $(MAKE) -k INNER=t $(patsubst sources_%,lint/%,$(filter sources_%,$(.VARIABLES)))
+ $(MAKE) -k INNER=t $(patsubst sources_%,lint/%,$(filter sources_%,$(.VARIABLES))) lint/bin
+lint/bin: build build-aux/lint-bin
+ ./build-aux/lint-bin $(foreach t,$(build_types),build/rp2040-$t/cmd/sbc_harness/sbc_harness.elf)
lint/sh lint/bash: lint/%:
shellcheck $(sources_$*)
lint/python3: lint/%: build-aux/venv
diff --git a/build-aux/lint-bin b/build-aux/lint-bin
index 85f9015..7584714 100755
--- a/build-aux/lint-bin
+++ b/build-aux/lint-bin
@@ -7,6 +7,20 @@
set -euE -o pipefail
shopt -s extglob
+# There are several exisi files we can use:
+#
+# Binaries:
+# - ${elf} : firmware image with debug symbols and relocationd data
+# - ${elf%.elf}.bin : raw firmware image
+# - ${elf%.elf}.hex : .bin as Intel HEX
+# - ${elf%.elf}.uf2 : .bin as USB Flashing Format (UF2)
+#
+# Textual info:
+# - ${elf%.elf}.dis : `objdump --section-headers ${elf}; objdump --disassemble ${elf}; picotool coprodis --quiet ${elf}`
+# - ${elf}.map : `ld --print-map` info
+
+# Input is `ld --print-map` format.
+#
# Output is a series of lines in the format "symbol location size
# source". Whitespace may seem silly.
objdump_globals() {
@@ -57,8 +71,13 @@ lint_globals() {
}
main() {
- echo 'Global variables:'
- lint_globals 'build/rp2040-Release/cmd/sbc_harness/sbc_harness.elf.map' | sed 's/^/ /'
+ local elf
+ for elf in "$@"; do
+ {
+ echo 'Global variables:'
+ lint_globals "${elf}.map" | sed 's/^/ /'
+ } > "${elf%.elf}.lint.globals"
+ done
}
main "$@"