Oberon RTK

build-clean

Delete generated build artefacts along the Astrobe library search path

Name

build-clean – delete generated build artefacts along the Astrobe library search path

Synopsis

build-clean astrobe_folder config_file source_file [--deep]

Description

build-clean walks the library search path defined in an Astrobe .ini configuration file and deletes generated build artefacts (object files, listings, debug data, etc.) from each directory on the path, plus the source file's own directory.

The tool's positional-argument shape mirrors AstrobeBuild, so it slots into a build script as a parallel call – typically before the next build that needs a clean slate.

The primary use case is the Secure/Non-secure build chain on STM32, where shared library modules must be recompiled between the S and NS builds: each side uses a different BASE module, and without an inter-build clean, AstrobeLink reports "wrong version" errors on the second build. RP2350 S/NS programs do not need this step because both sides use the same BASE; the tool is nonetheless general and can be used for any cold-rebuild scenario.

There is no dependency checking and no consistency checking. The tool deletes by extension, with a small exclusion list. AstrobeBuild handles dependency-driven recompilation on the next build.

Lib Search Path Resolution

The tool reads LibPathName0, LibPathName1, … entries from the .ini file. For each entry:

  1. Substitution variables of the form %Name% (eg., %AstrobeRP2350%, %AstrobeRP2040%) are replaced verbatim with the astrobe_folder argument. This matches the way AstrobeBuild uses the astrobe_folder argument to expand the same tokens in .ini lib search paths.

  2. Relative paths are resolved against the source file's parent directory.

  3. Absolute paths are used as given.

Paths that resolve to non-existent directories are silently skipped. Duplicates (different .ini entries that resolve to the same physical directory) are deduplicated. The source file's parent directory is always added to the cleanup list, regardless of whether it appears on the search path.

Each directory is walked non-recursively: sub-directories are not entered.

Options

astrobe_folder
Parent directory used as the substitution value for %AstrobeRP2350%, %AstrobeRP2040%, etc. tokens in the lib search paths. Same value passed to AstrobeBuild, typically held in the RTK_ASTROBE_FOLDER_2350 or RTK_ASTROBE_FOLDER_2040 environment variable (see Environment Variables).
config_file
Path to the Astrobe .ini configuration file – the same file passed to AstrobeBuild for the build that needs cleaning.
source_file
Path to the program source module (.mod). The file's parent directory is added to the cleanup list and is also used as the base for resolving relative search paths from the .ini. The file itself is not opened.
--deep
Also delete .smb (symbol) files. The default mode preserves .smb files because they often remain valid across rebuilds of the same source; deep mode is for full cold-rebuild scenarios.

File Extensions

Default mode – files with these extensions are deleted:

.arm, .map, .lst, .drf, .ref, .s, .asm, .uf2, .alst

With --deep – additionally:

.smb

Always preserved:

boot2.bin, FPU.smb, FPU.arm, FPU.lst, MAU.smb, MAU.arm, MAU.lst

The boot2.bin exclusion is the RP2040 stage-2 boot loader.

These lists are hard-wired in the tool.

Examples

Clean before an S build in a Secure/Non-secure script:

python -m build-clean "%RTK_ASTROBE_FOLDER_2350%" sec\v31-stm32u585-iot-secure-s.ini sec\S.mod

Same with deep clean (also removes .smb):

python -m build-clean "%RTK_ASTROBE_FOLDER_2350%" sec\v31-stm32u585-iot-secure-s.ini sec\S.mod --deep

In a build script that has already set the variables:

python -m build-clean "%ASTROBE_FOLDER%" %S_INI% %S_MOD% %DEEP%

(where DEEP is either empty or --deep.)

Diagnostics

The tool exits with status 0 on success and status 1 on any error. The principal error condition is:

  • config file not found

Warnings (non-fatal) are printed to standard error for files that match a clean extension but cannot be deleted (eg., open in another process, permission denied). The tool continues with the remaining files in that directory and the remaining directories.

On completion the tool prints a summary line:

build-clean: deleted N file(s)

Compatibility

Developed and tested with Astrobe for RP2350 version 10 in the context of STM32U585 and STM32H573 Secure/Non-secure builds. The .ini file format is the Astrobe IDE format; LibPathName* keys with optional %Name% substitution variables are recognised.

Notes

The cleanup is by extension only – there is no dependency graph, no source-modified-time check, no symbol comparison. After build-clean, AstrobeBuild will recompile every module that no longer has a fresh .arm (ie., everything just deleted).

The .lst files are deleted by default because they are regenerated by AstrobeBuild on every recompile, but they are also consumed by gen-secure, gen-rdb, and make-elf. If build-clean is run without a subsequent build, downstream tools will fail to find their input listing files.

The two-level deletion (default vs --deep) reflects a typical build pattern: between S and NS builds the .smb files of unchanged modules can usually be reused, saving recompilation; for a full cold rebuild they are removed too.

See Also

make-elf, gen-secure, gen-rdb, sec-epilogue, Environment Variables

Last updated: 8 May 2026