cargo-c
cargo-c copied to clipboard
Renaming the C library?
I'm switching Pathfinder to use cargo-c
. Pathfinder is built as a series of small crates: to that end, the C bindings are under pathfinder_c
. I'd like to have cargo-c
rename the resulting library from pathfinder_c
to pathfinder
. Is this something you'd like to support?
In the roadmap I already planned to add customization through package.metadata.capi
entries in Cargo.toml
and I'm already overriding the library section in code.
I'm not against to support it, how would it work for you?
Sounds great!
I'm not clear on how it would work though :) you can poke me on riot or zulip if you prefer.
I think this was done in:
commit e74097065577ee4d212ddb985f7927c20b37d631
Author: Sebastian Dröge <[email protected]>
Date: Mon Aug 24 21:17:14 2020 +0300
Add configuration for library name and version
It does, I think we can close the issue now.
Is it possible that this feature isn't working quite yet, at least not as written in the README? In my case I can only rename the header using package.metadata.capi.header
in Cargo.toml
. If I try to use
[package]
name = "a"
[package.metadata.capi.library]
name = "b"
to rename the library I get
Compiling a v0.1.0 (/tmp/mwe)
Finished dev [unoptimized + debuginfo] target(s) in 0.08s
Building pkg-config file
Building pkg-config file
Building header file using cbindgen
Error: CliError { error: Some(Cannot copy /tmp/a/target/./debug/libb.so to /tmp/a/target/./debug/libb.so.0.1.0.
Caused by:
No such file or directory (os error 2)), exit_code: 101 }
It seems the first path is wrong.
Finally package.metadata.capi.pkg_config
seems to be ignored. The content of the *.pc
seems to be correct though:
prefix=/usr/local
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
Name: b
Description:
Version: 0.1.0
Libs: -L${libdir} -lb
Cflags: -I${includedir}/a
Libs.private: -lgcc_s -lutil -lrt -lpthread -lm -ldl -lc
The complete MWE is here: https://gist.github.com/cschwan/0cb317b682541ed6962dcab65cda1b7a
Could you please open a new issue? It looks like there is a bug in the implementation.
@sdroege probably we should add a test for it.
Here you go: https://github.com/lu-zero/cargo-c/issues/166.
@sdroege probably we should add a test for it.
Indeed. I don't use the library renaming feature myself, only the versioning overriding of the library so I didn't notice this not working.