From 59b2c3fd7948ff0442625778483d9101e14107ea Mon Sep 17 00:00:00 2001 From: Thorsten Blum Date: Sun, 4 Feb 2024 18:14:43 +0100 Subject: [PATCH] Refactor --- README.md | 2 +- build.rs | 14 ++++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 1926569..941fe14 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ The safe Rust bindings to `libeditorconfig`, built on top of this `editorconfig- ## Dependencies -To use this crate, `pkg-config` and `libeditorconfig >=0.12.5 <1.0.0` must be installed. For example, on Debian or Ubuntu you could use `apt install pkg-config libeditorconfig-dev` and on macOS `brew install pkg-config editorconfig` to install the dependencies. +To use this crate, `pkg-config` and `libeditorconfig >= 0.12.5` must be installed. For example, on Debian or Ubuntu you could use `apt install pkg-config libeditorconfig-dev` and on macOS `brew install pkg-config editorconfig` to install the dependencies. You can check if `pkg-config` can find the library and which version is installed with: diff --git a/build.rs b/build.rs index 87afcde..df13556 100644 --- a/build.rs +++ b/build.rs @@ -1,4 +1,4 @@ -// This build script currently assumes that `libeditorconfig >=0.12.5 <1.0.0` is +// This build script currently assumes that `libeditorconfig >= 0.12.5` is // installed and that `pkg-config` can find it. use pkg_config::{Config, Library}; @@ -8,25 +8,23 @@ const LIBRARY_NAME: &str = "editorconfig"; // Technically libeditorconfig v0.12.2 already supports pkg-config: // https://github.com/editorconfig/editorconfig-core-c/releases/tag/v0.12.2 const MIN_VERSION: &str = "0.12.5"; -const MAX_VERSION: &str = "1.0.0"; fn main() { if let Ok(lib) = Config::new() - .range_version(MIN_VERSION..MAX_VERSION) + .atleast_version(MIN_VERSION) .probe(LIBRARY_NAME) { if cfg!(feature = "buildtime-bindgen") { gen_bindings(lib); } } else { - eprintln!( - "Unable to find lib {} >= {} < {}", - LIBRARY_NAME, MIN_VERSION, MAX_VERSION - ); + eprintln!("Unable to find lib {} >= {}", LIBRARY_NAME, MIN_VERSION); } } fn gen_bindings(lib: Library) { + use std::{env, path::PathBuf}; + let include_paths = lib .include_paths .iter() @@ -40,7 +38,7 @@ fn gen_bindings(lib: Library) { .expect("Failed to generate bindings"); // Write auto-generated bindings to `$OUT_DIR/bindings.rs` - let out_path = std::path::PathBuf::from(std::env::var("OUT_DIR").unwrap()); + let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); bindings .write_to_file(out_path.join("bindings.rs")) .expect("Failed to write bindings");