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
This commit is contained in:
Nathan Fiedler 2016-10-16 11:00:06 -07:00
parent cb40925af0
commit b63f25c550
4 changed files with 33 additions and 2 deletions

View file

@ -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.

View file

@ -1,6 +1,6 @@
[package]
name = "magick_rust"
version = "0.5.2"
version = "0.6.1"
authors = ["Nathan Fiedler <nathanfiedler@fastmail.fm>"]
description = "Selection of Rust bindings for the ImageMagick library."
homepage = "https://github.com/nlfiedler/magick-rust"

View file

@ -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)

View file

@ -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.