From 2eccf1e91ba2403679fc33f59c4e92163318cdae Mon Sep 17 00:00:00 2001 From: Nathan Fiedler Date: Thu, 20 Oct 2016 08:49:24 -0700 Subject: [PATCH] Ensure pkg-config present when generating bindings Not all systems have pkg-config installed by default. cargo test passes --- CHANGELOG.md | 4 ++++ Cargo.toml | 2 +- README.md | 1 + build.rs | 21 +++++++++++++-------- docs/Development_Setup.md | 1 + vagrant/freebsd10/fabfile.py | 1 + vagrant/ubuntu14/fabfile.py | 5 +++-- 7 files changed, 24 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 61fdf37..58463bf 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.2] - 2016-10-20 +### Changed +- Presence of `pkg-config` checked in `build.rs` script at build time. + ## [0.6.1] - 2016-10-16 ### Changed - MagickWand version enforced in `build.rs` script at build time. diff --git a/Cargo.toml b/Cargo.toml index ec0624c..68159a6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "magick_rust" -version = "0.6.1" +version = "0.6.2" 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 8a3131c..8447009 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ A somewhat safe Rust interface to the [ImageMagick](http://www.imagemagick.org/) - Or whatever version is dictated by rust-bindgen * [rust-bindgen](https://github.com/Yamakaky/rust-bindgen) (version 0.19 or higher) - This will be installed automatically if it is missing. +* Must have `pkg-config` in order to link with MagickWand. See the `docs/Development_Setup.md` file for details particular to each platform. diff --git a/build.rs b/build.rs index a760c16..d4d7a67 100644 --- a/build.rs +++ b/build.rs @@ -40,14 +40,6 @@ fn run_bindgen(out_dir: String, bindings_path_str: &str) { .status().expect("cargo install bindgen"); } - // Check that MagickWand is installed before proceeding. - if !Command::new("pkg-config") - .arg("--exists") - .arg("MagickWand") - .status().unwrap().success() { - panic!("MagickWand library must be installed"); - } - // Get the compiler flags for the MagickWand library. let mw_cflags_output = Command::new("pkg-config") .arg("--cflags") @@ -117,6 +109,19 @@ fn run_bindgen(out_dir: String, bindings_path_str: &str) { } fn assert_mw_version() { + // This build script depeneds heavily on the pkg-config utility. + if !Command::new("which") + .arg("pkg-config") + .status().unwrap().success() { + panic!("Cannot find pkg-config, see the README"); + } + // Check that MagickWand is installed before proceeding. + if !Command::new("pkg-config") + .arg("--exists") + .arg("MagickWand") + .status().unwrap().success() { + panic!("MagickWand library must be installed"); + } // // 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 diff --git a/docs/Development_Setup.md b/docs/Development_Setup.md index 89a0a3e..efbb69e 100644 --- a/docs/Development_Setup.md +++ b/docs/Development_Setup.md @@ -14,6 +14,7 @@ $ xcode-select --install $ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" $ brew install rust $ brew install imagemagick +$ brew install pkg-config ``` Then build in the usual manner, as shown in the `README.md` file (i.e. `cargo build` and `cargo test`). diff --git a/vagrant/freebsd10/fabfile.py b/vagrant/freebsd10/fabfile.py index abae061..0c24709 100644 --- a/vagrant/freebsd10/fabfile.py +++ b/vagrant/freebsd10/fabfile.py @@ -40,6 +40,7 @@ def all(): sudo("pkg install -q -y rust") sudo("pkg install -q -y cargo") sudo("pkg install -q -y ImageMagick-nox11") + sudo("pkg install pkgconf") sudo("pkg install -q -y clang-devel") # set LIBCLANG_PATH so rustc can find libclang.so in its hidden place # (using the append operation results in 'Unmatched ".' error) diff --git a/vagrant/ubuntu14/fabfile.py b/vagrant/ubuntu14/fabfile.py index 4242962..91ab173 100644 --- a/vagrant/ubuntu14/fabfile.py +++ b/vagrant/ubuntu14/fabfile.py @@ -35,7 +35,8 @@ else: @task def all(): """Install everything needed to build magick-rust.""" - run('sudo apt-get -q -y install git') + sudo('apt-get -q -y install git') + sudo('apt-get install pkg-config') # the rustc and cargo packages are fairly old, so build from source run('wget -q https://static.rust-lang.org/rustup.sh') run('chmod +x rustup.sh') @@ -49,7 +50,7 @@ def all(): run('make') sudo('make install') run('rm -rf ImageMagick*') - run('sudo apt-get -q -y install clang libclang-dev') + sudo('apt-get -q -y install clang libclang-dev') # set LIBCLANG_PATH so rustc can find libclang.so in its hidden place # (using the append operation results in 'Unmatched ".' error) run("echo 'export LIBCLANG_PATH=/usr/lib/llvm-3.8/lib' >> .bashrc")