platformio/platformio-core

extra_script global defines not working

Open

#5 146 ouverte le 4 mai 2025

Voir sur GitHub
 (2 commentaires) (0 réactions) (0 assignés)Python (791 forks)batch import
LDFhelp wanted

Métriques du dépôt

Stars
 (7 329 stars)
Métriques de merge PR
 (Aucune PR mergée en 30 j)

Description

I am trying to add a global define to a project build extrascript like this:

global_env = DefaultEnvironment()
global_env.Append(CPPDEFINES=[("USBCON", 1),("HAL_PCD_MODULE_ENABLED",1),'USBCON'])
global_env.Append(CCFLAGS=["-D USBCON"])
print("<<<<<GLOBAL ENV DEFINES>>>>>")
print(global_env.get('CPPDEFINES'))
print("<<<<<GLOBAL ENV FLAGS>>>>>")
print(global_env.get('CCFLAGS'))

as per the example here: https://docs.platformio.org/en/latest/manifests/library-json/fields/build/extrascript.html

But defines and flags are not added, if i verbose build they are present in the log, but not present in the build command, build output:

CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/genericSTM32F401CD.html
PLATFORM: ST STM32 (19.1.0) > STM32F401CD (96k RAM. 384k Flash)
HARDWARE: STM32F401CDU6 84MHz, 96KB RAM, 384KB Flash
DEBUG: Current (stlink) External (blackmagic, jlink, stlink)
PACKAGES:
 - framework-arduinoststm32 @ 4.21001.0 (2.10.1)
 - framework-cmsis @ 2.50900.0 (5.9.0)
 - toolchain-gccarmnoneeabi @ 1.120301.0 (12.3.1)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
<<<<<GLOBAL ENV DEFINES>>>>>
deque([('PLATFORMIO', 60118), 'STM32F4', 'STM32F401xE', 'STM32F4xx', ('USBD_VID', '0x05f3'), ('USBD_PID', '0x00D2'), ('USB_MANUFACTURER_STRING', 'STR(RailDriver)'), ('USB_PRODUCT_STRING', 'STR(RailDriver)'), 'STM32F4xx', ('ARDUINO', 10808), 'ARDUINO_ARCH_STM32', 'NDEBUG', 'ARDUINO_GENERIC_F401CDUX', ('BOARD_NAME', '\\"GENERIC_F401CDUX\\"'), 'HAL_UART_MODULE_ENABLED', 'USE_HAL_DRIVER', 'USE_FULL_LL_DRIVER', ('VARIANT_H', '\\"variant_generic.h\\"'), ('VECT_TAB_OFFSET', '0x0'), ('USBCON', 1), ('HAL_PCD_MODULE_ENABLED', 1), 'USBCON'])
<<<<<GLOBAL ENV FLAGS>>>>>
-mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard -Os -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -D USBCON
Found 15 compatible libraries
Scanning dependencies...
Dependency Graph
|-- USBLibrarySTM32 @ 0.3.0 (License: LGPL-3.0-or-later, Path: D:\Source\GitHub\USBLibrarySTM32\examples\SerialUSB\.pio\libdeps\bluepill_f401\USBLibrarySTM32)
Building in release mode
arm-none-eabi-g++ -o .pio\build\bluepill_f401\src\main.cpp.o -c -std=gnu++17 -fno-threadsafe-statics -fno-rtti -fno-exceptions -fno-use-cxa-atexit -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard -Os -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -DPLATFORMIO=60118 -DSTM32F4 -DSTM32F401xE -DSTM32F4xx -DUSBD_VID=0x05f3 -DUSBD_PID=0x00D2 -DUSB_MANUFACTURER_STRING=STR(RailDriver) -DUSB_PRODUCT_STRING=STR(RailDriver) -DSTM32F4xx -DARDUINO=10808 -DARDUINO_ARCH_STM32 -DNDEBUG -DARDUINO_GENERIC_F401CDUX -DBOARD_NAME=\"GENERIC_F401CDUX\" -DHAL_UART_MODULE_ENABLED -DUSE_HAL_DRIVER -DUSE_FULL_LL_DRIVER -DVARIANT_H=\"variant_generic.h\" -DVECT_TAB_OFFSET=0x0 -Iinclude -Isrc -I.pio\libdeps\bluepill_f401\USBLibrarySTM32\include -I.pio\libdeps\bluepill_f401\USBLibrarySTM32\src -IC:\Users\Levi\.platformio\packages\framework-arduinoststm32\cores\arduino\avr -IC:\Users\Levi\.platformio\packages\framework-arduinoststm32\cores\arduino\stm32 -IC:\Users\Levi\.platformio\packages\framework-arduinoststm32\libraries\SrcWrapper\inc -IC:\Users\Levi\.platformio\packages\framework-arduinoststm32\libraries\SrcWrapper\inc\LL -IC:\Users\Levi\.platformio\packages\framework-arduinoststm32\libraries\USBDevice\inc -IC:\Users\Levi\.platformio\packages\framework-arduinoststm32\libraries\VirtIO\inc -IC:\Users\Levi\.platformio\packages\framework-arduinoststm32\system\Drivers\STM32F4xx_HAL_Driver\Inc -IC:\Users\Levi\.platformio\packages\framework-arduinoststm32\system\Drivers\STM32F4xx_HAL_Driver\Src -IC:\Users\Levi\.platformio\packages\framework-arduinoststm32\system\STM32F4xx -IC:\Users\Levi\.platformio\packages\framework-arduinoststm32\system\Middlewares\ST\STM32_USB_Device_Library\Core\Inc -IC:\Users\Levi\.platformio\packages\framework-arduinoststm32\system\Middlewares\ST\STM32_USB_Device_Library\Core\Src -IC:\Users\Levi\.platformio\packages\framework-arduinoststm32\system\Middlewares\OpenAMP -IC:\Users\Levi\.platformio\packages\framework-arduinoststm32\system\Middlewares\OpenAMP\open-amp\lib\include -IC:\Users\Levi\.platformio\packages\framework-arduinoststm32\system\Middlewares\OpenAMP\libmetal\lib\include -IC:\Users\Levi\.platformio\packages\framework-arduinoststm32\system\Middlewares\OpenAMP\virtual_driver -IC:\Users\Levi\.platformio\packages\framework-cmsis\CMSIS\Core\Include -IC:\Users\Levi\.platformio\packages\framework-arduinoststm32\system\Drivers\CMSIS\Device\ST\STM32F4xx\Include -IC:\Users\Levi\.platformio\packages\framework-arduinoststm32\system\Drivers\CMSIS\Device\ST\STM32F4xx\Source\Templates\gcc -IC:\Users\Levi\.platformio\packages\framework-cmsis\CMSIS\DSP\Include -IC:\Users\Levi\.platformio\packages\framework-cmsis\CMSIS\DSP\PrivateInclude -IC:\Users\Levi\.platformio\packages\framework-arduinoststm32\cores\arduino -IC:\Users\Levi\.platformio\packages\framework-arduinoststm32\variants\STM32F4xx\F401CC(F-U-Y)_F401C(B-D-E)(U-Y) src\main.cpp
(then the build fails cause the defines are missing)

Am i missing something? I followed the example almost literally but neither the flags or the defines are showing up?

Guide contributeur