mesonbuild / meson

The Meson Build System
http://mesonbuild.com
Apache License 2.0
5.64k stars 1.64k forks source link

Feature request: depend on `external_program` #13877

Open klokik opened 2 weeks ago

klokik commented 2 weeks ago

One can put an external_program returned by the find_program() as a dependency for the custom target only if the program is an executable target that is a part of the built (so it is likely an exe not an external_program). Unfortunately, you cannot depend on the program found in the PATH.

Moreover, I didn't see a clean solution for determining where the program is coming from that covers all the cases. It would be nice to unify the experience and always put the program into the list of dependencies.

Note: it is about the case not covered by auto-added dependencies in the list of the command parameters. Consider the following example:

protoc = find_program('protoc')
grpc_cpp_plugin = find_program('grpc_cpp_plugin')

proto_generated_sources = custom_target('my-proto-gen-sources',
  input: proto_files,
  output: proto_generated_output_names,
  command: [protoc,
    '--proto_path=@CURRENT_SOURCE_DIR@',
    '--plugin=protoc-gen-grpc=' + grpc_cpp_plugin.full_path(), # this cannot be used to auto add a dependency
    '--grpc_out=@OUTDIR@', '--cpp_out=@OUTDIR@',
    '@INPUT@'],
  depends: [is_grpc_internal ? grpc_cpp_plugin : []], # how to determine `is_grpc_internal` is not clear
)
dcbaker commented 2 weeks ago

This is a well known issue that we've talked about how to handle it, because we don't want to add it to depends, we want to handle it correctly via command.

I had proposed https://github.com/mesonbuild/meson/pull/12287 at one point (now very out of date), but that didn't really move forward.

dcbaker commented 2 weeks ago

Generally, whenever .full_path() is getting called, that's a code smell.

klokik commented 2 weeks ago

Will handling it via command lead to removal of the depends parameter?

So far, I find this behavior being inconsistent.