platformio/platformio-core

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

Open

#5,237 创建于 2025年8月26日

在 GitHub 查看
 (1 评论) (0 反应) (0 负责人)Python (7,329 star) (791 fork)batch import
build systemhelp wanted

描述

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.

贡献者指南