lu-zero/cargo-c

Wrong header version information

fmartinsons opened this issue · 0 comments

Hello,

first , thanks for this awesome project, it is really good work !

My use case combine cargo-c for lib/header/pkg-config generation and cargo-deb for easy debian package generation.

And I came accross a conflict on naming between the cargo/rust world and debian policy:

  • My crate name contains dash, e.g package.name="my-crate-name" in Cargo.toml
  • Cargo internally transform this for the crate name to contains only underscore, so one can use my_crate_name::*; in the code
  • cargo-c , with default settings, will generate lib based on that that will be (on ubuntu) libmy_crate_name.so
  • cargo deb will also generate the debian package as (for example) my_crate_name_0.1.0_amd64.deb which will not be valid as debian policy forbid use of underscore in the name: https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-source

So I choose to customize header/lib/pkg-config generation with the cargo-c specific settings:

[package.metadata.capi.library]
name = "my-crate-name"

[package.metadata.capi.header]
name = "my-crate-name"'

[package.metadata.capi.pkg_config]
filename = "my-crate-name"

But this settings lead to invalid header generation for version info:

#define MY-CRATE-NAME_MAJOR 0
#define MY-CRATE-NAME_MINOR 1
#define MY-CRATE_NAME_PATCH 0

I think it should be pretty easy to correct here by simply replacing every possible dash with underscore.

What do you think ?

For the moment , I simply choose to keep the header name non modified and stick with crate name but it hurts my feeling to see all this naming differences in the generated artifacts ;)

By the way I use cargo-c 0.9.18+cargo-0.69