Closed twistedfall closed 5 years ago
This is quite specific as it only works for modules and for the feature expression.
Are you having a specific problem that cpp_build fails because of an unexisting module?
Maybe we could have some attribute so that cpp_build ignore some part of the code?
Supporting #[cfg ...] everywhere could also be an option, but one probably should develop some advanced config parsing. I believe some other crates might be doing that like cbindgen and the like.
True. I've thought about implementing it for any #[cfg], but I don't have that much free time atm. In my case I have 3 similar module trees aimed at 3 different major version of the ffi'ed library (opencv). And only one of those trees is actually imported based on #[cfg(feature)]. When all of them are parsed by rust-cpp
I'm getting function redefinition errors because a lot of function are the same across those module trees.
Maybe we could have some attribute so that cpp_build ignore some part of the code?
Well, that's basically what #[cfg]'s are :)
The function redefinition is actually another problem caused by the hashes being equal, this also happens when they are in the same file. I guess this could be solved by generating only one function per hash.
Regarding your change: I guess it make sens to integrate it if it solve your needs. Have you thought about documenting this feature? That only simple variant of cfg are understood.
The function redefinition is actually another problem caused by the hashes being equal
Yeah, I've run into that too, solved by just renaming the captured variables.
Have you thought about documenting this feature?
Let me do that, I'm going to put it in the cpp/src/lib.rs
module level doc comment, that what you expect, right?
right, the module level doc seems like the best place
Or maybe it should be in the cpp_build documentation.
Well, I've checked that first, but cpp_build
module documentation refers a reader to cpp
doc
I've update the module docs for cpp
module
Thanks for the patch. The documentation looked good.
Only simple straight-forward #[cfg]'s with only "feature" are supported, no complex conditions are allowed