-
Notifications
You must be signed in to change notification settings - Fork 2.1k
tools/mkconstfs2: Make templates configurable. #9565
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
Conversation
The template strings to build the file can now be provided in an INI files. This allows reusing the script for other purposes other than doing constfs filesystems.
BTW, at some point one starts to wonder if using a generic template library makes more sense, but i'd rather not add more dependencies if it can be avoided. |
Generally I like the idea of separating the templates from the tool, but I think it was easier to read without all the escaping that is needed now. Thinking about lua, why not embed the lua modules as all other files (e.g. within constfs, but not restricted to it) and then simply use those files? Why is this different handling needed in the first place? |
The escaping is necessary if one wants to preserve whitespaces. The other formats supported in python's standards library (JSON, CSV, etc) need even more escaping. Hacking my own format is in my opinion not a good idea. The last option is to separate each chunk in its individual file.
I guess now it's not specific to constfs anymore, it is more of a mutant
Is there any advantage on writing super-thin wrappers vs just calling the tool with the required command when one needs to?
I don't need a file, just a text buffer and a table listing all the buffers. I don't want the code to depend on VFS+consfs, and I don't want module loading to have to go through fs functions and loads of layers when its not needed. |
To clarify my point, in a makefile I prefer to have
rather than
And then having to go to lua-specific-wrapper.sh to see what it does. |
ack
Not really, but at some (not purely objective) point, separating should be preferred. Nobody want's almighty
Right direction, but not really self-explaining. Though, I can't really come up with a better name atm.
agree |
I was looking at #10308. It embeds a SSL certificate in the application, as a C array. I think it could benefit from the template-enabled mkconstfs2. Can we reactivate this PR? What do I have to do? |
I think just proper naming and file location for the script should do. |
Changed the name of the tool and document the template.
CI failed because of unrelated error so I re-triggered CI-build |
I don't understand this. The old mkconstfs could take a folder and just recursively add all files in that folder and create a constfs with it. I understand that that's a little unflexible (though it would probably totally alright for our use case to create a tree on the fly in /tmp, just copying every file to it's intended position). Why not just extend this so mkconstfs can accept a list of files and maybe target positions within the generated constfs? I mean, "[, <target position relative to constfs root]" tuples. What on earth is the use case for implementing templating in this? "arrays of embedded lua modules", what's that? |
citing from the contribution description
I think it in general it can be argued that the script is not strictly necessary to have in the riot tree, but it makes using constfs much easier and doesn't really hurt. |
How? I think it is actually important for tools in the RIOT tree to more than "don't really hurt".
What's wrong with xxd for generating plain arrays from files? Guys, I'm not picking on this PR, I just skim it and I really don't know what you are using this for other than a super high level description. Usually I do know how and for what tools in RIOT are used, so I'm just asking for a full use-case. |
By providing a simple interface to make files available to riot code without having to deal with details on how to format what.
True. For me the reasoning was that there are different situations requiring to embed file contents directly to the code which may be formatted differently -> so factoring out the template (while keeping it simple) sounds valuable.
Nothing, I agree. Actually that's a bad example - I just looked up how the arrays are formatted in the referenced PR and I'd prefer using just xxd for that. I don't have a strong opinion on this, maybe @jcarrano can elaborate on the lua use-case. |
That is make-unfriendly. By having an explicit list of files rebuilds can be handled better.
In the case of Lua, I don't want to have to pull in VFS and constf just to be able to load a script when the user types
Once I implemented that, and fixed command line argument parsing, and made it so that the output is not constfs specific, and fixed the name mangling (mkconstfs can generate colliding and even invalid names) there would not have been much left of the original file. Because of that and because I don't know who else may be using that script, I made a new one. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want me to ignore this issue, please mark it with the "State: don't stale" label. Thank you for your contributions. |
Contribution description
The template strings to build the file can now be provided via a INI file. This allows reusing the script for other purposes other than doing constfs filesystems.
I'm planning on using it to generate arrays of embedded lua modules. This is a configuration that does that: