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

Renaming the C library? #83

Open
pcwalton opened this issue Jun 24, 2020 · 10 comments
Open

Renaming the C library? #83

pcwalton opened this issue Jun 24, 2020 · 10 comments
Labels
D-Medium A task that takes 4 hours to complete enhancement New feature or request

Comments

@pcwalton
Copy link

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?

@lu-zero
Copy link
Owner

lu-zero commented Jun 24, 2020

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?

@lu-zero lu-zero added D-Medium A task that takes 4 hours to complete enhancement New feature or request labels Jun 24, 2020
@pcwalton
Copy link
Author

Sounds great!

@lu-zero
Copy link
Owner

lu-zero commented Jun 24, 2020

I'm not clear on how it would work though :) you can poke me on riot or zulip if you prefer.

@anholt
Copy link

anholt commented Feb 4, 2021

I think this was done in:

commit e74097065577ee4d212ddb985f7927c20b37d631
Author: Sebastian Dröge <sebastian@centricular.com>
Date:   Mon Aug 24 21:17:14 2020 +0300

    Add configuration for library name and version

@lu-zero
Copy link
Owner

lu-zero commented Feb 4, 2021

It does, I think we can close the issue now.

@cschwan
Copy link

cschwan commented Feb 14, 2021

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

@lu-zero
Copy link
Owner

lu-zero commented Feb 15, 2021

Could you please open a new issue? It looks like there is a bug in the implementation.

@lu-zero
Copy link
Owner

lu-zero commented Feb 15, 2021

@sdroege probably we should add a test for it.

@cschwan
Copy link

cschwan commented Feb 15, 2021

Here you go: #166.

@sdroege
Copy link
Sponsor Contributor

sdroege commented Feb 15, 2021

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
D-Medium A task that takes 4 hours to complete enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants