pw_python_action and python_runner.py support expressions like TARGET_FILE and TARGET_OBJECTS that resolve GN labels to output files. In GN, toolchains are free to name and place outputs anywhere they like. There is no mechanism in GN to resolve a compiled target to its outputs. You could guess that an output file would be e.g. "$target_gen_dir/$target_name.elf", but a toolchain might decide to nest the output under a "bin/" directory or use a different extension.
GN projects that control their own toolchains can predict output file locations. Pigweed needs to work with toolchains defined by external projects, so there is no way to predict output file locations.
python_runner.py's label resolution expressions are similar in purpose to CMake's generator expressions. They are evaluated by parsing GN's Ninja output. This is not ideal, but is necessary for accurately finding output files for a label.
We would like to replace this feature with native GN features. Ideally there would be a function like get_target_outputs, but that works across build files and on targets for which the toolchain determines their outputs (source_set, static_library, etc.).
Description
pw_python_action and python_runner.py support expressions like TARGET_FILE and TARGET_OBJECTS that resolve GN labels to output files. In GN, toolchains are free to name and place outputs anywhere they like. There is no mechanism in GN to resolve a compiled target to its outputs. You could guess that an output file would be e.g. "$target_gen_dir/$target_name.elf", but a toolchain might decide to nest the output under a "bin/" directory or use a different extension.
GN projects that control their own toolchains can predict output file locations. Pigweed needs to work with toolchains defined by external projects, so there is no way to predict output file locations.
python_runner.py's label resolution expressions are similar in purpose to CMake's generator expressions. They are evaluated by parsing GN's Ninja output. This is not ideal, but is necessary for accurately finding output files for a label.
We would like to replace this feature with native GN features. Ideally there would be a function like get_target_outputs, but that works across build files and on targets for which the toolchain determines their outputs (source_set, static_library, etc.).