Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: depend on external_program #13877

Open
klokik opened this issue Nov 6, 2024 · 3 comments
Open

Feature request: depend on external_program #13877

klokik opened this issue Nov 6, 2024 · 3 comments

Comments

@klokik
Copy link
Contributor

klokik commented Nov 6, 2024

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
Copy link
Member

dcbaker commented Nov 6, 2024

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 #12287 at one point (now very out of date), but that didn't really move forward.

@dcbaker
Copy link
Member

dcbaker commented Nov 6, 2024

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

@klokik
Copy link
Contributor Author

klokik commented Nov 6, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants