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

Explanation for configuration? #422

Closed
phlummox opened this issue Nov 3, 2024 · 1 comment · Fixed by #423
Closed

Explanation for configuration? #422

phlummox opened this issue Nov 3, 2024 · 1 comment · Fixed by #423

Comments

@phlummox
Copy link

phlummox commented Nov 3, 2024

So, I see that the README gives a tl;dr of what needs to be done to use cargo-c.

Compared to how simple it is to get started with cbindgen, there seem to be a lot of steps (and dependencies) required, and I wonder if it might be worth explaining to end-users why cargo-c is configured this way.

To generate headers with cbindgen requires very little ceremony at all. As long as you can get the executable from somewhere, you can just invoke it from within a rust project, and it will output a header file. You don't actually need to write a cbindgen.toml file (though it's often handy to do so), and you don't need to alter your project in any way if you don't want to (other than making sure there are at least some #[no_mangle] pub functions or constants).

So why does cargo-c require that we create a capi.rs – why can't it just use the same functions etc. that cbindgen uses? Why does cargo-c require adding #[cfg(feature="capi")] to the project? Why does it require* creation of a cbindgen.toml file, when cbdingden itself doesn't?

* Or maybe it's just a suggestion, the README isn't clear. It says "Remember to add a cbindgen.toml", but doesn't make clear whether this is a requirement or only useful to do.

I may also have a misunderstanding of what cargo-c is doing, but it also seems odd to me that it should require OpenSSL headers or git as prerequisites. If its job is to "produce and install a correct pkg-config file, a static library and a dynamic library, and a C header" – the main addition over what cargo and cbindgen can already do seems to be generation of a .pc file, and that's just a text generation task, isn't it? Why should cargo-c need access to git or OpenSSL for that? No doubt there are good reasons, but it might be helpful to make them clear. A simple .pc generator like this one doesn't require access to git tooling or OpenSSL headers, so why does cargo-c?

@lu-zero
Copy link
Owner

lu-zero commented Nov 3, 2024

cargo-c depends on cargo as a crate, so all the cargo's dependencies have to be satisfied.

The TL;DR aims at giving a good setup, it is not a set of requirements.

The very minimal requirement is to have a capi feature in Cargo.toml and that's all :)

I'll clarify the readme soon.

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

Successfully merging a pull request may close this issue.

2 participants