-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
custom_target: Ambiguous target when input and output is the same file #6070
Comments
I wouldn't call the move workaround "dirty" because it's trying to do what should have happened in the first place :-) To be bullet-proof I'm afraid you need not just one move but two... Let's say there's a failure somewhere near the in-place operation. You fix the problem and run "ninja" again. Now how do you expect any build system to know whether As long as this is a single step from Meson's perspective, completely hiding the
+1
+1 I assume you meant combining
In GNU binutils, Modifying files in place is just the worst idea from an automated build perspective, hopefully just something from an other age. |
I call it dirty because you have to use another tool (bash in this case) to chain your actual actions. Maybe bash is not present in the system. The most correct way is propably to use Python since Meson runs with Python. Of course the syntax is really cumbersome then.
Thanks, nice catch.
Eh, yes.
Partly. Without
I completely agree with you. Nevertheless, such tools exist. |
Interesting example I just root-caused:
|
BTW thanks for this typo, it's perfect: https://github.com/mesonbuild/meson/issues?q=runlib :-) |
I think we should allow custom_target() with no output that internally creates a dummy file. This would basically be the same as run_target() but that can be used as dependency. I've been needing that elsewhere too, would that fix the problem here? |
It would except when the user wants to control the output name. It would also be confusing: some non-experts would likely assume the change is performed in place when reading the code. |
After thinking a bit more, I think this is the sort of user interface I would like best:
It would behave like this for each input:
Thumb this comment up if you like this too. UPDATE/PS: interestingly, meson already has a "soft" dependency on strip:
|
I would call |
Thanks, I edited the comment.
Good catch, thanks! Of course there is; most examples above do accept multiple files. I made another (naive?) edition.
I kept the existing |
I guess there is no use-case where some inputs are inplace and some are not? In your example above, we have to assume that input[i] maps to output[i], right? I find that a bit "fragile" but that's probably good enough. Just thowing (crazy) idea, what about having a dictionary: my_stripped_exes = custom_target('stripped exes',
input : ['some_other_file'], # optional
output : ['some_other_output'], # optional
inplace : {'fat1.exe': 'stripped1.exe', 'fat2.exe': 'stripped2.exe'},
command : ['strip', ... ],
) In that proposal, |
If there is anything (that... crazy), I don't think meson should specialise so much for it. A wrapper should be inserted and present something saner to meson = the usual layer of indirection "fix".
Yes.
Right, you could have a very long list and say skip a beat by mistake. You'd have to skip the same number of beats in both lists though. After you do, I think the next build steps would most likely fail in some spectacular and obvious way.
Assuming it's mutually exclusive with regular Somewhat related and fixed in 0.53: |
I bit scary that both lists must be sync and could be hard to discover if 2 elements are just swapped in one list but not the other. But again in practice it's probably not that bad.
Yes, having a key with same value than one of the input (or value/output) would be an error.
In the end it's still @jpakkane who needs to approve API changes, but as far as I'm concerned the use-case seems legit to me. |
BTW: https://github.com/mesonbuild/meson/issues?q=is%3Aopen+sort%3Areactions-%2B1 |
Some commands (in my case
runlib
, other examples:sed -i
,strip
) process a file just changing an existing file without writing to a new output file. Some of them allow to specify writing in a new file, others do not.In the latter case
custom_target
is not usable anymore because the filename/target is ambiguous. The dirty workaround is to provide a script or callbash -c
that does an additionalmv
afterwards. However, can this be done in meson?Possible solutions:
fake_output
argument and when set meson performs an additionalmv
.runlib
target can be skipped entirely.The text was updated successfully, but these errors were encountered: