| 1 | extern crate pkg_config; |
| 2 | use std::error::Error; |
| 3 | |
| 4 | #[cfg(feature = "vendored")] |
| 5 | mod build_vendored; |
| 6 | |
| 7 | fn main() -> Result<(), Box<dyn Error>> { |
| 8 | // Invalidate the built crate whenever these files change |
| 9 | println!("cargo:rerun-if-changed=build.rs"); |
| 10 | println!("cargo:rerun-if-changed=build_vendored.rs"); |
| 11 | |
| 12 | // See https://github.com/joshtriplett/metadeps/issues/9 for why we don't use |
| 13 | // metadeps here, but instead keep this manually in sync with Cargo.toml. |
| 14 | #[cfg(not(feature = "vendored"))] |
| 15 | if let Err(e) = pkg_config::Config::new().atleast_version("1.6").probe("dbus-1") { |
| 16 | eprintln!("pkg_config failed: {}", e); |
| 17 | eprintln!( |
| 18 | "One possible solution is to check whether packages\n\ |
| 19 | 'libdbus-1-dev' and 'pkg-config' are installed:\n\ |
| 20 | On Ubuntu:\n\ |
| 21 | sudo apt install libdbus-1-dev pkg-config\n\ |
| 22 | On Fedora:\n\ |
| 23 | sudo dnf install dbus-devel pkgconf-pkg-config\n" |
| 24 | ); |
| 25 | panic!(); |
| 26 | } |
| 27 | |
| 28 | #[cfg(feature = "vendored")] |
| 29 | build_vendored::build_libdbus()?; |
| 30 | Ok(()) |
| 31 | } |