j9 icon indicating copy to clipboard operation
j9 copied to clipboard

Allow linking against system-provided libjq

Open tranzystorekk opened this issue 1 year ago • 3 comments

Distributions that provide jq typically also offer development packages that can be discovered by using pkg-config. Adding optional pkg-config configuration to j9-sys would be a welcome step towards easier packaging of jnv without having to build a vendored libjq version.

tranzystorekk avatar Mar 22 '24 23:03 tranzystorekk

I've drafted the necessary changes to make this happen, I can make a PR if you are interested: https://github.com/tranzystorekk/j9/commit/1d760e48bbaae717e7a95196418787f04bcfaa6c

tranzystorekk avatar Mar 23 '24 10:03 tranzystorekk

@tranzystorekk Wow, thanks for your suggestions. Please let me ask.

  • Is this a mechanism that allows skipping the build of libjq by referring to an already installed libjq?
  • Is the choice between using it or not controlled by the LIBJQ_NO_VENDOR environment variable?

ynqa avatar Mar 27 '24 03:03 ynqa

  • Is this a mechanism that allows skipping the build of libjq by referring to an already installed libjq?

Yes, as long as pkg-config is installed (so only on unix platforms) and the jq installation contains the libjq.pc configuration file (typically provided on distros by development subpackages like jq-devel).

  • Is the choice between using it or not controlled by the LIBJQ_NO_VENDOR environment variable?

LIBJQ_NO_VENDOR=1 forces j9-sys to use the system version or fail to build otherwise, this is useful for distro packages that need to ensure they're using the system provided version. With LIBJQ_NO_VENDOR=0 or unset, we try to grab the system version first, and fallback to vendored if not found (or if pkg-config is unavailable).

Typically similar -sys crates also expose a vendored feature that if enabled always select the vendored version even if system is available, but I wanted to make a minimal proposal first.

The pkg-config crate also has its own set of config variables to control its behavior: https://docs.rs/pkg-config/latest/pkg_config/#environment-variables

tranzystorekk avatar Mar 27 '24 05:03 tranzystorekk

Closing as jnv has picked the jaq route instead.

tranzystorekk avatar Oct 13 '24 20:10 tranzystorekk