-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
interpreter: add depend_files
kwarg to run_command()
#15016
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
base: master
Are you sure you want to change the base?
Conversation
run_command() already treats all file paths in argv as build-def dependencies. Unfortunately, it does not allow the user to specify such dependencies manually. Add `depend_files` to allow manually adding build-def dependencies, rather than requiring users to stash them into the argument array, even if unused, just to get the same behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
configure_file() provides a depfile
kwarg instead, and expects the command being run to output the files it ends up using.
@@ -833,6 +834,9 @@ def run_command_impl(self, | |||
else: | |||
raise InterpreterException(overridden_msg.format(a.name, cmd.description())) | |||
|
|||
for f in kwargs['depend_files']: | |||
self.add_build_def_file(f) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the kwarg is part of func_run_command
I don't know why it's being read+used in the totally different run_command_impl
, but it is the cause of the CI failures.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func_run_command()
just forwards to run_command_impl()
, and the latter shares the type-definition of the kwargs
argument.
I think the CI failure is because this should read:
for f in kwargs.get('depend_files', []):
self.add_build_def_file(f)
I wonder, though, why this didn't trigger errors in my local tests. I used:
./run_project_tests.py --only "common/33 run program"
And this worked fine. Hmm. But maybe I am missing something here. How exactly would you adjust func_run_command()
to support the option?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I got this right, then func_run_command()
properly fills in the default value in kwargs
, and as such I get an empty depend_files
when called via run_command()
in meson build files. However, there are 2 other users of the actual implementation of func_run_command()
, which is run_command_impl()
, and those do not fill in defaults but pass kwargs manually (and explicitly specify all kwargs).
Do you prefer to update explicit users to specify all options, or should I use the kwargs.get(..., [])
style?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I already told you what I want, but I can explain the distinction between the two and why your analysis doesn't apply in this case. Sorry for not elucidating earlier.
We have two functions:
- a DSL entry-point with functionality relevant to the DSL
- a backend refactoring function so that we can share the logic for "spawn a command" in various places where this is relevant
Most of the logic for the former (technically before this PR, all of it) needs to be forwarded regardless, because it tunes the details of the command spawning itself. It isn't work that occurs independently beforehand. Even though other uses don't necessarily need to control these details, run_command_impl
must somehow accept knobs for e.g. env, and it could be done via a dict kwarg or via separate arguments but we happened to use this.
depend_files is unnecessary to expose to run_command_impl, it can live wholly inside of func_run_command which means avoiding unnecessary complexity inside other internal callers of run_command_impl.
Does that mean you prefer the
I don't care too much. Would you prefer if it was |
There are advantages and disadvantages to each. But don't you already need a script if you're doing globbing? |
run_command() already treats all file paths in argv as build-def dependencies. Unfortunately, it does not allow the user to specify such dependencies manually. Add
depend_files
to allow manually adding build-def dependencies, rather than requiring users to stash them into the argument array, even if unused, just to get the same behavior.