-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Wip/jehan/special case set4glib #6267
base: master
Are you sure you want to change the base?
Conversation
2023cbf
to
86cf829
Compare
With this PR, glib builds fine.
I don't think using a template is an acceptable solution for glib.
IMHO, we should provide a better recommended way in the deprecation warning. Probably by adding .write() or .verbatim(). |
That was the point. ;-)
Indeed not SQL injections, but C/C++/NASM injection just before build (so even harder to detect later on!).
If they absolutely want to keep all the normal defines and these random code in a single
(well… in this case, it's 2 files, but they just include Or they could generate 2 files and simply concat them in a single command. And probably other solutions. Anyway I can have a look at this |
Ok so I added a commit implementing a Why I have successfully tested with the glib code of course. Basically they could just change:
to:
I would provide a patch but I assume they'll want to stick to their current code until their minimum meson requirement becomes the next release. |
Regardless of anything else, plain |
If we must go with an api on the configuration_data() it should be very clear to be abstraction breaking. I've seen "verbatim" in a suggestion. Or maybe "raw". But i still feel like this does not belong into configuration_data() because that's a abstract dictionary like thing. There was the suggestion by tim to use a new kwarg (e.g. header or footer) on configation_file() which i think is a better place. Of course that means glib needs to have an additional variable that gets chunks appended to it. But that seems doable. |
I think it belongs to configuration_data, it's much more natural. Also configure_file could have a command instead of a configuration_data, in which case how do you handle the footer? That seems weird. |
69ee469
to
1aa26c3
Compare
Injecting complex custom code into config.h is also unclean and non-flexible, and feels like some ill legacy design. Clean and flexible would be a beautiful standalone dict of key-value pairs and nothing else. Adding special API to meson to do something unclean and non-flexible, simply because it is a lesser "evil" than manually maintaining a template, is not automatically the right choice. Although I guess it could be added anyway (I do however strongly caution people writing new projects from scratch to not fall into the trap of actually using it).
Nice, now who is being being uncooperative. :) If the append() method was not added, and glib still used the bug in 3 years from now, it would be infinitely reasonable to remove it from meson, and when glib complains, say in response "we begged you to fix it 3 years ago, we added angry deprecation messages to every single invocation of meson on the glib project, and you acknowledged it but refused on principle to do anything. Our hands are clean." I don't understand how "neener neener, we will never cooperate so suck it up" is supposed to be a helpful discussion point here. |
While an append() method is obviously more convenient to use due to being able to preserve the autogeneration nature of a configure_file without input files, I cannot see any technical reason for it to be impossible to define multiple blobs and have it be activated by a define which the configuration_data uses as a switch to activate the blob. It should be no different from having a single blob activated by the same switch. |
To be fair, I haven't seen GLib complain and saying they would not fix it or even that the bug was in meson, according to them. At least not in the GLib bug report whose link was given in an earlier comment. Was there an actual discussion about this problem with GLib devs on other channels (IRC for instance)? Or is it all just assumptions that they would not like it and we are just all acting on this whole assumption? Anyway, now I implemented this |
IDK, I thought @xclaesse was one of those. :p |
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.
Anyway, this is missing documentation that the API exists.
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 like this feature, I'm happy you did the work, it's always nicer to deprecate something with a better replacement. As for the naming, IMHO .append()
is nice and short.
Extra bonus point if we can have a unit test too :)
A possible alternative is to add a configure_file(input: ...
output: ...
configuration: ...
footer: '''This gets written at the end of the generated file,
line feeds and all.''') |
Sorry for the delay. Going trough this now again it seems reasonable (assuming GLib people are happy, which seems to be the case). Just some minor fixes:
With those changes, this should be ready to merge. |
Sorry all for lacks of answers (if one was needed, I have not re-read the thread). These last few months were a bit hectic and I just moved (like 2 days ago) to a new place hundreds of kms away. I hope things will settle soon, then if changes are needed on my patches, I'll do and apply them. |
Any update on this? |
Ping? |
Hmm, what ever ended up happening to this? |
Sorry I haven't re-looked at this for ever. I'll try to make some time. |
Looking through old issues, I stumbled across #1492 which asked for the ability to do prefix/suffix in configured files, and also suggested a potential alternative mechanism:
So at the very least the third commit in this patch series should be marked as fixing that issue... and I also wonder if maybe the |
1aa26c3
to
1762561
Compare
Codecov Report
@@ Coverage Diff @@
## master #6267 +/- ##
===========================================
- Coverage 68.82% 41.14% -27.69%
===========================================
Files 406 203 -203
Lines 88062 43617 -44445
Branches 19560 8962 -10598
===========================================
- Hits 60612 17945 -42667
- Misses 22871 23932 +1061
+ Partials 4579 1740 -2839
Continue to review full report at Codecov.
|
9b7dc47
to
0e3ae34
Compare
Hi all! I just reviewed my code, rebased it over changes in meson codebase these last years (files were moved around) and pushed to the branch. I also applied the various proposed changes in @dcbaker's review. As for @jpakkane's review, I also applied the changes (renaming and adding unit tests), though I'd like to add a quick note/question:
Personally I find the proposed alternative name Though I still applied the change, I wanted to raise this little point. Finally I made 2 more changes:
|
The reason I wanted that was to make sure how things get ordered. For example if you do something like:
Then it is unclear from just looking at that how those things are ordered in the final file. The two do very different things and thus it is typically worth it to make their APIs look different too. We might also need to add a corresponding Reading what I just wrote out actually uncovered a naming issue (the ones that are actually hard). Maybe "footer" is not a good name because the corresponding term for stuff at the top of the file is "header" which is a heavily loaded term. How do people feel about calling this method (Sorry for these delays, but naming is one of those things where you only have one chance to get it right so it pays to think about it a bit more deeply.) |
Ah I understand why you suggested the name change now.
Sure. It's long but much more meaningful than
No prob. I understand how these things are important too. ;-) |
@jpakkane Should I just rename to |
… with newlines." This reverts commit b33830f. We will simply add a special case when the multi-line value starts with a newline, together with a warning telling that such usage of set() is deprecated.
... code injection. GLib was using the bug of multi-line macro values (cf. mesonbuild#6179) as a feature for injecting code. This was definitely semantically wrong as the function is obviously meant for key-value setting. Also this can be dangerous allowing unexpected code injection. Anyway for backward compatibility, we will leave a special case when the value also **starts** directly with a newline (as in GLib case), yet accompanied with a message warning this is deprecated bug usage and should be fixed. In later versions of meson, this flexibility will likely be revoked.
This can be used to just append random data as-is to the generated configuration file, for instance if the basic #define creation is not enough for one's needs. The data is appended (after all key-value defines, if any), so that it is possible to make use of any of the said key-values. I.e. you could add #ifdef code using macros previously set on this configuration object.
…ut files. As suggested by @xclaesse during review.
The following tests were modified with data appended with append_raw_text: 'Configless.' and 'Substituted'. This way, we test appending data with the case where an input was given (variable substition) or not (typically header file creation).
0e3ae34
to
5303511
Compare
Ok once again I resolved all worries, got back to taking care of the original issue only, and also renamed once more the new method. It's now called Hopefully this should now be good for a merge. :-) P.S.: also rebased and force pushed to my branch. |
Test failure seems relevant:
|
Argh. I'll have to look when I can make the time again. If anyone has any relevant info/hint, feel welcome to tell. Because from my testing, I had no problems. |
The error is effectively the same one as this:
|
Hmmm… this error also exists on latest
As for In any case, looking at the pointed code inside
Yet it's indeed supposed to be a ConfigurationData object:
It's not something I changed. But maybe I am missing something, but it's much harder to understand if I can't try and run this test script myself, so I'd welcome hints on doing this. :-) |
The issue is that both these sites in git master have type violations, but before this PR nothing happened to use attributes which aren't present in a plain dict. It's a bug anyway because of the type violation, your PR just happened to expose it. The solution would be to add one commit to the beginning of this patch series that fixes the type violations by constructing a ConfigurationData for use instead of a dict. You can run the tests via |
Cf. #6259.
With these commits, we bring back the set() fix yet accepting exceptionally the special-case when the value starts with a newline (as is the case in GLib) while adding a big fat warning saying it's bad usage for the function.
This way, at least GLib won't break even with recent meson, still we warn them to fix their build eventually.