-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
rfe: extend run_target() to match run_command() #13206
Comments
Adding a .stdout() method to a run_target doesn't make much sense since a run_target would be executed by run_target doesn't produce output artifacts, it is used for creating "PHONY" targets such as |
But its return type doesn't seem to
|
I.e. |
That is because you can capture the stdout in one of two ways:
Both run_target and custom_target are compile rules, they are not run at all when meson is run and cannot return stdout in the meson.build file. run_command is different -- it is only run by meson, and it returns stdout to the meson.build file and cannot be re-evaluated by ninja. |
Yes, I understand what you say. |
I mean, why ninja can't be instructed |
I am not sure what you mean by that. Make can't do what you're saying either. Make does mix setup and compile in the same action though: T = $(shell run_command ...)
custom_target1:
some_cmd -e $(T) Then, Make converts the command block, replacing variables computed during the setup pass, into a shell script, and executes it with the replacement T. But make can't do that with two compile rules since each one is run inside its own new shell. This doesn't work: custom_target1:
T=$$(some_cmd1)
custom_target2: custom_target1
some_cmd2 -e $$(T) You can still do what make allows, with meson too. But the setup stage isn't run every time, so the value of T will be the same every time you run ninja. If you want it to change without having to rerun meson each time, you could have |
No, the problem is, I really need to
This is possible with
which would be an advantage over |
The assignment to You can have command: ['sh, '-c', 'T=$(cat custom_target1.out); some_cmd -e "$T";'] meson will produce a build rule that runs the entire sh command for you, including reading the "captured to a file" output of the first custom target so it can be passed as an argument to the current build rule. This isn't performed at setup time. |
Yes, something like this can work, |
So if there is nothing to improve on |
Why it takes 7 parameters, is because |
You can probably just use: command: [find_program('wrapper.sh'), t1.full_path(), '@INPUT@', '@OUTPUT@']
Someone would have to define what that syntax would look like for meson, and how it would perform that wrapping. I worry that it is the kind of feature request easier to ask for than to implement... |
You can just pass the find_program itself, no need for full_path(). Using full_path() is only really useful when the relative path that meson writes to the ninja file is "wrong" for the shell script because the shell script internally does a |
Ok, first let me point out that what
This example replaces As for not passing full_path() - thanks,
I think this can look like this:
As was pointed out,
If ninja doesn't support that natively, then |
Currently it seems impossible to run
some command at build time, and
capture its output.
It would be good to add the
capture
arg to
run_target()
(similar to the oneof
run_command()
), and add anstdout()
method to the class returned by
run_target()
.The text was updated successfully, but these errors were encountered: