I got it. It's not quite as clean as I would like, but it seems to work:
extra script ("mystorm.py"):
Import("env")
env.Depends("$BUILD_DIR/src/bitstream.o", "$BUILD_DIR/../icestorm/hardware.bin")
# The latter half could possibly be:
# "$PROJECTPIOENVS_DIR/icestorm/hardware.bin"
# but I haven't tested it.
platformio.ini:
Once again, remove ,bitmap.o
from the end of the build_flags
line in the [env:nucleo_l476rg]
section.
From: build_flags = -Wl,--no-warn-mismatch,bitmap.o
To: build_flags = -Wl,--no-warn-mismatch
And then add extra_script = mystorm.py
to the [env:nucleo_l476rg]
section.
This has a lot less moving parts than my earlier proposed mechanism.
EDIT: still uses the assembly file listed before, and you can still delete the bitmap related files in the root of the project directory.