I have multiple toolchains in my build, since my products include both native host tools as well as firmware targets.
I have a host toolchain that I use for host compilation but also for actions that generate files: bin2c kinds of things, protoc kinds of things, etc.
I enforce that the current_toolchain is equal to my host toolchain, so that I don't waste build time doing identical work across multiple toolchains.
These generated files are then added to static library "sources" lists.
When there's only one toolchain, it's very easy to just do this:
======
my_action("foo") {
sources = [ "blah.foo" ] # outputs "${target_gen_dir}/blah.c"
}
static_library("bar") {
sources = [ "bar.c" ] + get_target_outputs(":foo")
deps = [ ":foo" ]
}
=======
Moving to multiple toolchains like this angers GN:
======
if (current_toolchain == my_host_toolchain) {
my_action("foo") {
sources = [ "blah.foo" ] # outputs "${target_gen_dir}/blah.c"
}
}
static_library("bar") {
sources = [ "bar.c" ] + get_target_outputs(":foo(${my_host_toolchain})")
deps = [ ":foo(${my_host_toolchain)" ]
}
======
get_target_outputs() does not appear to work across toolchains, even in the same BUILD.gn file.
Ideally it would be nice for leaf builds to not have to worry about the names + extensions of the files generated by "my_action"; those are pleasantly handled by get_target_outputs. That doesn't seem possible in this case, though.
Are there any elegant ways to handle this? My inclination is to just create a list containing the inputs, and explicitly transform that into the outputs manually to match the action i'm invoking, but that feels a bit clunky.
Thanks,
Charles