From b63f25c550cc1ecb56a4c52f9e8a9004b09a5d7f Mon Sep 17 00:00:00 2001 From: Nathan Fiedler Date: Sun, 16 Oct 2016 11:00:06 -0700 Subject: [PATCH] Enforce MagickWand version in build.rs It is very easy to overlook the version of MagickWand mentioned in the README, so make sure the build system enforces it. Fixes #19 cargo test passes --- CHANGELOG.md | 4 ++++ Cargo.toml | 2 +- README.md | 2 ++ build.rs | 27 ++++++++++++++++++++++++++- 4 files changed, 33 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d99e28a..61fdf37 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## [0.6.1] - 2016-10-16 +### Changed +- MagickWand version enforced in `build.rs` script at build time. + ## [0.6.0] - 2016-09-20 ### Changed - Update to 0.19.0 version of rust-bindgen; rebuilds are much faster. diff --git a/Cargo.toml b/Cargo.toml index fec9725..ec0624c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "magick_rust" -version = "0.5.2" +version = "0.6.1" authors = ["Nathan Fiedler "] description = "Selection of Rust bindings for the ImageMagick library." homepage = "https://github.com/nlfiedler/magick-rust" diff --git a/README.md b/README.md index fd5cb2b..8a3131c 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,8 @@ A somewhat safe Rust interface to the [ImageMagick](http://www.imagemagick.org/) * Rust (~latest release) * Cargo (~latest release) * ImageMagick (version 6.9) + - [Homebrew](http://brew.sh) and [FreeBSD](https://www.freebsd.org) provide this version + - Linux may require building ImageMagick from source * Clang (version 3.5 or higher) - Or whatever version is dictated by rust-bindgen * [rust-bindgen](https://github.com/Yamakaky/rust-bindgen) (version 0.19 or higher) diff --git a/build.rs b/build.rs index 95d90e4..a760c16 100644 --- a/build.rs +++ b/build.rs @@ -45,7 +45,7 @@ fn run_bindgen(out_dir: String, bindings_path_str: &str) { .arg("--exists") .arg("MagickWand") .status().unwrap().success() { - panic!("MagickWand library must be installed") + panic!("MagickWand library must be installed"); } // Get the compiler flags for the MagickWand library. @@ -116,7 +116,32 @@ fn run_bindgen(out_dir: String, bindings_path_str: &str) { std::fs::remove_file(&gen_h_path).expect("could not remove header file"); } +fn assert_mw_version() { + // + // So far there is only 6.9 and then 7.x, so comparing to 6.10 should + // work for now. Such a release may very well work, but we will have to + // look at that when the time comes. + // + if !Command::new("pkg-config") + .arg("--atleast-version=6.9") + .arg("MagickWand") + .status().unwrap().success() { + panic!("MagickWand version must be at least 6.9"); + } + if !Command::new("pkg-config") + .arg("--max-version=6.10") + .arg("MagickWand") + .status().unwrap().success() { + panic!("MagickWand version must be no higher than 6.9"); + } +} + fn main() { + // + // Assert that the appropriate version of MagickWand is installed, + // since we are very dependent on the particulars of MagickWand. + // + assert_mw_version(); // // If the MagickWand bindings are missing, generate them using // rust-bindgen.