The C ABI of librsvg exports a few uint_t
variables like rsvg_major_version
, rsvg_minor_version
, etc.
We are in the process of moving this to Rust so that the entire librsvg.so
can be built with cargo-c
(right now all the code in the library is in Rust, and is wrapped by stub functions in C. Those variables are also in C files).
Ideally those version numbers would be defined once, in the configure.ac
script, and propagated down to a generated versions.rs
source file. (Commentary: librsvg is fine with not letting cargo build
run standalone for the C library; we need to do some postprocessing for it anyway, which is not cargo-c's business.)
I see two options:
- Set some VERSION_MAJOR, VERSION_MINOR environment variables in the build scripts. Have a
build.rs
pick these up and generate aversions.rs
in the build directory, which is later included somewhere in the library. - Have a
versions.rs.in
onto which the build scripts do textual substitution to generateversions.rs
in the source directory.
I suppose (1) is the "conventionally build.rs way", and (2) is the "keep the existing build scripts mostly unchanged".
Has anyone had to do something similar to this? Any preferred approaches? Thanks!