Skip to content

Make scan_includes more robust, or switch to rgbasm -M -MC #1253

@Rangi42

Description

@Rangi42

We use scan_includes to recursively list dependencies for our .asm files. Historically this has been because rgbasm -M was (a) slow and (b) did not usefully handle dependecies which did not yet exist (e.g. INCBIN "not-yet-generated.2bpp").

However, scan_includes has its own problems. It does not handle \ line continuations, """multi-line strings""", or /* block comments /*. It does not handle READFILE dependencies. It also does not handle indirect dependencies that depend on macro or interpolation expansion (e.g. INCLUDE "file{d:num}.asm", or tileset Foo, foo where MACRO tileset does \1GFX:: INCBIN "gfx/tilesets/\2.2bpp").

RGBDS 0.9.4 introduced the -MC flag, which handles not-yet-existing dependencies the way we'd want. So I think it's worth testing again to see how well it performs. Even if scan_includes is still worth keeping for performance reasons, it could do moderately more complex parsing of the .asm to handle more syntax.

Some test cases:

; These are NOT dependencies

db """multi-line
INCBIN "no"
strings"""

/* block
INCBIN "no"
comments */

invoke_macro arg, \
INCBIN "no", \
arg

invoke_macro INCBIN "no"

; These ARE dependencies

def s equs READFILE("yes")

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions