Depend target on another target

I have created a custom target. I would like to build first one of the environments default targets and then run my custom target.
Now I need to do this in two steps:

  1. pio run -e l432_debug
  2. pio run -e l432_debug -t meta

I would like to have it in one step
pio run -e l432_debug -t debug -t meta

If I do something like the above I get:
*** Do not know how to make File target `debug’ (xxx/projects/bootloader/debug). Stop.

If I run only pio run -e l432_debug -t meta
only the meta target being run

It would be so cool to specify a target as dependency of another target
so if I run:
pio run -e l432_debug -t meta
the default project is also automatically being run
My platformio.ini
build_dir = build/
default_envs = l432_debug

custom_firmware_config = firmware/firmware.conf
platform = ststm32
board = nucleo_l432kc

lib_extra_dirs = lib/common

build_flags =
-I src/Core/Inc
-I src/Drivers/STM32L4xx_HAL_Driver/Inc
-I src/Drivers/STM32L4xx_HAL_Driver/Inc/Legacy
-I src/Drivers/CMSIS/Device/ST/STM32L4xx/Include
-I src/Drivers/CMSIS/Include
-I src/App
-I src/Loader
-I src/Loader/ARMCM4_STM32L4

-D STM32L432xx
-D STM32L4xx

extra_scripts =

board_build.ldscript = src/STM32L432KCUX_FLASH.ld

build_type = release

build_flags =
;-Os ; optimize for space

build_type = debug

debug_build_flags =
-Og -ggdb3 -g3 ; -O0 make the image bigger

how to do this? has the environments some kind of special target names??
But maybe I think wrong with wrong approach.
Thank you!

I don’t understand the concept of a target. What is the difference to an environment?
Where is the complete list of all possible targets? --list-targets just gives upload but from what I have collected from doc there are at least this broad used:
upload, monitor, build, envdump, clean + custom targets defined by user
Are there more targets??

some of them start a build like upload
some of them just run like envdump
why and how? and where is the source code for that in platformio core?

thank you!

ok I found the build target, but…

  • running pio run -t build -t meta
    invoke only compile stage of build target, it seems that the copy postscripts are run after meta target is complete, but I need this objcopy thing from build BEFORE meta.

  • what would be really really nice being able to do is this:
    pio run -t clean -t custom_target1 -t build -t custom_target2 -t custom_target3

  1. first running clean to delete everything
  2. then run custom_target1
    should run also a post or pre script configured for their environment
  3. running build compile everything
    also here are only the build post scripts run (is it possible at all to connect a post/pre command to target?
  4. running custom_target3, also with their post and pre scripts