Skip to content
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

Split between main and -sys crates #51

Open
SpaceManiac opened this issue Jul 8, 2016 · 2 comments
Open

Split between main and -sys crates #51

SpaceManiac opened this issue Jul 8, 2016 · 2 comments

Comments

@SpaceManiac
Copy link
Contributor

SpaceManiac commented Jul 8, 2016

Rust conventions prescribe a crate boundary between raw FFI bindings (the ffi module, the buildscript, and the generated glue) and a higher-level (even if it still has some unsafe) Rust wrapper. The advantages of such a configuration are primarily:

  • Alternative high-level wrappers can re-use the same -sys crate, which can act as a central, definitive logic for finding a library on the system or otherwise linking to it.
  • Complex dependency trees which involve multiple crates, or incompatible versions of crates which want to rely on bindings, can commonly depend on a -sys crate rather than conflicting.
  • Cargo's mechanism for overriding external dependencies can be more easily used without interfering with the high-level wrappers.

See, for example, the hlua crate, which bundles a lua52-sys crate: https://github.com/tomaka/hlua
(This -sys crate also bundles its Lua source without requiring a secondary download, a good idea IMO, but that is another issue.) Actually, maybe some collaboration with tomaka is warranted, given that this other crate also specifies links = "lua".

There isn't really any urgent need for this, but I wanted to get some discussion started.

@jcmoyer
Copy link
Owner

jcmoyer commented Jul 8, 2016

I've been aware of this convention for a while, but I haven't had the time (or motivation honestly) to split the low level bits out of the library. I agree it would be a nice thing to do though, if for no other reason than to be following standard guidelines.

@ruabmbua
Copy link

It would be useful, if for example someone wanted to implement a luajit backend for the crate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants