-
Notifications
You must be signed in to change notification settings - Fork 33
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
Multiple inventories to generate multiple outputs. #102
Comments
I'm not sure I fully understand your use case, but are "namespaces" what you are looking for? You can put items into namespaces and at generation time use that to filter. The C# backend has best support for that right now. Which backend do you use? |
I'm actually using C and C# with a probable use of the Python in the near future. I'll look into the namespaces in a little while and see if that does the trick. But to be more detailed in the explanation, take the following C outline of a simple (but annoying) case: -- u128_t.h because most of the target languages don't have u128. -- a more specialized header doing something specific. These are both in the same crate at the moment but they are in separate inventories. But, if I generate the headers at this time I get u128_t defined in both. Is that more understandable. |
Yes, if I understand that correctly this should be what namespaces address, have a look at the Unfortunately their support in the backends varies, C being the worst. Depending on what you specifically want to achieve you might get away by applying an inventory filter when writing headers, and adding an explicit |
Well, I ended up in a meeting so haven't looked at the namespaces yet but you did mention two things I haven't seen in the docs yet so hopefully you could point towards them. The "inventory filter" and adding an explicit 'include' bits. That would work just fine for the simple case that I have but I never saw them while spelunking the documentation. (NOTE: found the filter, was looking in the backend side for it..) |
So, after poking around, the filter + explicit include seemed like the best solution for my purposes. Only problem was that while internally when using C I don't allow headers in .h files, the externally visible files should be self contained for ease of use. So, after poking about in the C generator I could not find anything which allowed me to control additional includes. So, I present for your perusal: PR #103 Let me know if there is anything you would like changed. It seems to accomplish what I need though and all the tests passed. |
Looks good! |
I'm wondering if there is anyway to have exclusion lists during generation and insert "include"/"using"/"import"s etc in the output? The specific intention is that I want to generate multiple files from a crate rather than a single bulk header. One file would be a support type used in the other files but currently the support type gets generated in all generated files. I haven't run across any way to tell interoptopus to insert an include/using/import statement during generation nor a way to tell it not to generate something referenced just because it has a CType implementation (i.e. it was generated by an other inventory). Have I missed something here?
I'm currently using CBindgen which allows this in an annoying way, I have a whole slew of little crates which I generate as individual files and of course tweak all the toml's to exclude the things I don't want in each. With the inventory approach here, it seemed like I could do this without all the annoyances, except the above?
The text was updated successfully, but these errors were encountered: