Possible to use env name as a build_flag define?

I’m hoping to simplify my platformio.ini config and not have to hardcode build_flag variables. Is there a way I can extract the name of the selected environment at build time? For example:

[env:my_env_name]
platform = espressif8266
framework = arduino
build_flags = ‘-DPROJECT="$env"’

I’d like to use the environment name as the PROJECT define.

Please try -DPROJECT=$PIOENV

See platformio-core/platformio/builder/main.py at develop · platformio/platformio-core · GitHub

Thanks! To properly pass it as a string, I had to use:
'-DPROJECT="$PIOENV"'