Skip to content

Undefines in build_flags don't work if there's a space after -U #5237

@aveao

Description

@aveao

I'm on PlatformIO 6.1.18 on Linux, latest version at the time. This is a bug report.

When using -U in build_flags and running a build with --verbose, they're shown in the opening line:

Processing WHY2025_badge_companion_radio_ble (extends: WHY2025_badge; build_flags: -w [...] -D LORA_TX_POWER=27, -U LORA_TX_POWER, -D MAX_CONTACTS=100, [...])

but when gcc is being called, only -U is given to gcc (which incidentally also breaks my build):

[...] -DARDUINO_PARTITION_default_8MB -U -I.pio/libdeps/WHY2025_badge_companion_rad[...]

I confirmed this by sneaking in some print debugging to platformio/builder/tools/piobuild.py's ProcessFlags:

    ]                                                                                                                                                                                                                
    print("undefines found", undefines)                                                                                                                                                                              
    if undefines:

outputs:

undefines found ['-U']

Removing the space workarounds the issue, but including a space is in the default examples of both gcc and platformio, so I think it's confusing:

I think this is something that is also a problem for other flags normally, but ParseFlagsExtended explicitly fixes it for those classified as CPPDEFINES through use of functions like Util.is_Sequence.

I think scons.ParseFlags does not explicitly support -U (like it does -D) and as such is falling back to CCFLAGS for it, the corrective code on ParseFlagsExtended for CPPDEFINES isn't fixing it. Could be escalated to scons, or could be solved in ParseFlagsExtended the same way CPPDEFINES are fixed.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions