To test for cargo features you'd usually use if cfg!(feature = "zlib-ng-compat") { ... } instead of accessing the environment variable, but since this environment variable could also be set from outside of cargo I'm generating cargo:rerun-if-env-changed= output to let cargo know it needs to rebuild if they're changed
I'm adding a LIBGIT2_NO_VENDOR environment variable, this variable is supposed to deny vendoring even if the cargo feature libgit2-sys/vendored is enabled by any crate. If the system libgit2 is not present or not compatible it errors the build to let the maintainer know something needs to be fixed. This option would be especially useful for Linux package maintainers who always want to link the system library to avoid "shadow copies" of libgit2 embedded in binaries that are not known to the security team.
This does the following things:
if cfg!(feature = "zlib-ng-compat") { ... }
instead of accessing the environment variable, but since this environment variable could also be set from outside of cargo I'm generatingcargo:rerun-if-env-changed=
output to let cargo know it needs to rebuild if they're changedLIBGIT2_NO_VENDOR
environment variable, this variable is supposed to deny vendoring even if the cargo featurelibgit2-sys/vendored
is enabled by any crate. If the system libgit2 is not present or not compatible it errors the build to let the maintainer know something needs to be fixed. This option would be especially useful for Linux package maintainers who always want to link the system library to avoid "shadow copies" of libgit2 embedded in binaries that are not known to the security team.The
LIBGIT2_NO_VENDOR
variable is analogous toOPENSSL_NO_VENDOR
in openssl-sys: https://github.com/sfackler/rust-openssl/pull/1253There's currently no
Error
struct in the build.rs so I'm using aResult<(), ()>
, if you prefer anything else just let me know.