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

Decoupling this project from Cargo #922

Closed
dwlsalmeida opened this issue Jan 30, 2024 · 4 comments
Closed

Decoupling this project from Cargo #922

dwlsalmeida opened this issue Jan 30, 2024 · 4 comments

Comments

@dwlsalmeida
Copy link

Hi,

I was trying to use cbindgen in a meson project, and noticed that it is not possible currently.

Mainly, cbindgen expects to be able to call cargo expand, it also expects a Cargo.lock and to be able to call cargo metadata.

I wonder whether it is possible to decouple this project from Cargo, such that non-cargo projects can benefit from cbindgen like they do from bindgen itself.

Thoughts?

@dcbaker
Copy link

dcbaker commented Jan 30, 2024

Meson developer here, we likely can provide at least most of the data that cargo metadata does and pass that via the --metadata flag if that was what was required, thought the Cargo.lock is more problematic. cargo expand looks like it's just a wrapper around rustc anyway, so that should be fairly trivial to change, if that would be acceptable

@dwlsalmeida
Copy link
Author

@dcbaker turns out that this works: cbindgen --lang c -- lib.rs

@emilio
Copy link
Collaborator

emilio commented Apr 14, 2024

Yeah, cargo is only used to compute metadata, if you feed cbindgen the right files / metadata it should work without cargo.

Please reopen if there's anything more concrete to do here. We really don't want to re-implement the cargo crate graph resolution ourselves if we can help it :)

@emilio emilio closed this as completed Apr 14, 2024
@dwlsalmeida
Copy link
Author

Hi @emilio

I think what is missing is explaining that this project can be used without Cargo in the README file.

Currently, there is only this:

cbindgen --config cbindgen.toml --crate my_rust_library --output my_header.h

So it is not far-fetched to say that people may think that using Cargo is a pre-requisite to use cbindgen, which is not true.

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

No branches or pull requests

3 participants