Is it possible to use #define values in platform.ini

Hi,
I am looking for a way to use a #define in my platform.ini, Is it possible to use it or am I wishful here?

I have the following configuration I use in my platform.ini

[env]
platform = espressif8266
framework = arduino
build_flags = 
	-I"C:/My Data/OneDrive/Circuits/home_automation/include"
lib_deps = jwrw/ESP_EEPROM@^2.1.1

[env:balconydoor_ota]
board = esp12e ; common boards: d1_mini , esp01 , esp01_1m , esp12e
upload_port = 192.168.XX.XX
upload_protocol = espota
monitor_port = COM4
monitor_speed = 115200
build_flags = 
	${env.build_flags}
	-DDEVICE=3

I already have the IP address of the device to which I have to upload in a header file. This is used in my C++ code

#define IP_espnow_sensor IPAddress(192,168,XX,XX) // generic IP address for any espnow sensor being used in OTA mode

The issue here is that , this way I have defined the IP address in two places (once in platform.ini and another in my header file) and any change has to be made in both places. Can I instead provide a dynamic value for upload_port, something like :

[env:balconydoor_ota]
board = esp12e ; common boards: d1_mini , esp01 , esp01_1m , esp12e
upload_port = IP_espnow_sensor
upload_protocol = espota
monitor_port = COM4
monitor_speed = 115200
build_flags = 
	${env.build_flags}
	-DDEVICE=3

You can transport values from the .ini file into the build system as macros using advanced scripting.

As a start-off

Import("env")
# may or may not need env.AutodetectUploadPort()
upload_port = env["UPLOAD_PORT"]
# transform string / hostname into IP format..
# make available as macro
env.Append(CPPDEFINES=[(IP_espnow_sensor_ADDR, upload_port])

Also see here.

ok seems interesting, havent used advanced scripting as yet. Will give it a try. Thank you for your help