Arduino precompilation flags

Hello - I’m new to using Platformio (through VS Code) as an alternative to the Arduino IDE.

I have a custom library that requires a platform.local.txt file to be used. It includes the following precompilation flag line:

compiler.cpp.extra_flags=-DBOARD=“{build.board}” -DLIGHTAPI -DWITH_OPTICAL -DWITH_BLE -DWITH_STRESS -DWITH_CHR -fpermissive

After a bunch of searching, I think I need to do one of the following:

Do I just need add the platform.local.txt file to:

.platformio/packages/framework

Or do I need to somehow add these precompilation flags to the platform.ini file?
I’ve seen some examples of adding flags here, but by the line in the platform.txt file, its specified to a certain file.

Or something else?

Any help greatly appreciated!

No. PlatformIO reimplements the build system in SCons, to which you can feed your compile flags using e.g. Redirecting... (You also have access to certain environment variables). The platform.txt (and any platform.local.txt) is completely ignored on PlatformIO.

You can e.g. do

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
build_flags =
   -DBOARD=\"$BOARD\"
   -DLIGHTAPI
   -DWITH_OPTICAL
   -DWITH_BLE
   -DWITH_STRESS
   -DWITH_CHR
   -fpermissive

Will make inject -DBOARD=\"esp32dev\" and the other flags.

(And even without defining BOARD, there are already enough identifiying macros for the board in the build process by default: -DARDUINO_VARIANT=\"esp32\" "-DARDUINO_BOARD=\"Espressif ESP32 Dev Module\"" for board = esp32dev).

Thanks so much! This worked perfect.