KWARC / rust-libxml

Rust wrapper for libxml2
https://crates.io/crates/libxml
MIT License
76 stars 38 forks source link

FreeBSD instructions #130

Closed rudolphfroger closed 8 months ago

rudolphfroger commented 8 months ago

Hi,

Here are FreeBSD instructions for in the README.md:

$ pkg install libxml2
$ LIBXML2=/usr/local/lib/libxml2.so cargo build

Btw, it would be nice if the crate could be build without setting an environment variable. Removing the panic!("Could not find libxml2.") from build.rs enables this on FreeBSD.

dginev commented 8 months ago

I am not a FreeBSD user so I may be missing something obvious. The ENV variable is only needed when the actual attempt at finding libxml2.so fails. For unix systems we have an actual attempt to find it via pkg_config:

https://github.com/KWARC/rust-libxml/blob/23804509dacb93dc5b9df76d1155fc41fb2cd349/build.rs#L31-L36

Is this not workable on FreeBSD? If so, what is a usual alternative? Or do we need to add , target_os = "freebsd" to the cfg enumeration?

rudolphfroger commented 8 months ago

I've tried using pkg_config but that won't work either. But the build-system on itself is already capable of finding libxml2 on its own, so I there's no need to do anything special in build.rs.

I just got a report van a colleague that his Linux system also needs the LIBXML2 environment variable before he got it working. I think many systems would build the crate fine without the current panic! in build.rs.

rudolphfroger commented 8 months ago

After some more fiddling around, I found out that I need to install the pkgconf package on FreeBSD, which provides pkg-config. So the instructions for FreeBSD actually are:

$ pkg install libxml2 pkgconf
$ cargo build

It would be nice if you could add that to the README.md

dginev commented 8 months ago

Thank you for contributing this @rudolphfroger !