webkit2gtk-sys 0.13.0

Rust binding for webkit-gtk library
Documentation
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

#[cfg(not(feature = "dox"))]
extern crate pkg_config;

#[cfg(not(feature = "dox"))]
use pkg_config::{Config, Error};
#[cfg(not(feature = "dox"))]
use std::env;
#[cfg(not(feature = "dox"))]
use std::io::prelude::*;
#[cfg(not(feature = "dox"))]
use std::io;
#[cfg(not(feature = "dox"))]
use std::process;

#[cfg(feature = "dox")]
fn main() {} // prevent linking libraries to avoid documentation failure

#[cfg(not(feature = "dox"))]
fn main() {
    if let Err(s) = find() {
        let _ = writeln!(io::stderr(), "{}", s);
        process::exit(1);
    }
}

#[cfg(not(feature = "dox"))]
fn find() -> Result<(), Error> {
    let package_name = "webkit2gtk-4.0";
    let shared_libs = ["webkit2gtk-4.0", "javascriptcoregtk-4.0"];
    let version = if cfg!(feature = "v2_28") {
        "2.28"
    } else if cfg!(feature = "v2_26") {
        "2.26"
    } else if cfg!(feature = "v2_24") {
        "2.24"
    } else if cfg!(feature = "v2_22") {
        "2.22"
    } else if cfg!(feature = "v2_20") {
        "2.20"
    } else if cfg!(feature = "v2_18") {
        "2.18"
    } else if cfg!(feature = "v2_16") {
        "2.16"
    } else if cfg!(feature = "v2_14") {
        "2.14"
    } else if cfg!(feature = "v2_12") {
        "2.12"
    } else if cfg!(feature = "v2_10") {
        "2.10"
    } else if cfg!(feature = "v2_8") {
        "2.8"
    } else if cfg!(feature = "v2_6") {
        "2.6"
    } else {
        "2.4"
    };

    if let Ok(inc_dir) = env::var("GTK_INCLUDE_DIR") {
        println!("cargo:include={}", inc_dir);
    }
    if let Ok(lib_dir) = env::var("GTK_LIB_DIR") {
        for lib_ in shared_libs.iter() {
            println!("cargo:rustc-link-lib=dylib={}", lib_);
        }
        println!("cargo:rustc-link-search=native={}", lib_dir);
        return Ok(())
    }

    let target = env::var("TARGET").expect("TARGET environment variable doesn't exist");
    let hardcode_shared_libs = target.contains("windows");

    let mut config = Config::new();
    config.atleast_version(version);
    config.print_system_libs(false);
    if hardcode_shared_libs {
        config.cargo_metadata(false);
    }
    match config.probe(package_name) {
        Ok(library) => {
            if let Ok(paths) = std::env::join_paths(library.include_paths) {
                println!("cargo:include={}", paths.to_string_lossy());
            }
            if hardcode_shared_libs {
                for lib_ in shared_libs.iter() {
                    println!("cargo:rustc-link-lib=dylib={}", lib_);
                }
                for path in library.link_paths.iter() {
                    println!("cargo:rustc-link-search=native={}",
                             path.to_str().expect("library path doesn't exist"));
                }
            }
            Ok(())
        }
        Err(Error::EnvNoPkgConfig(_)) | Err(Error::Command { .. }) => {
            for lib_ in shared_libs.iter() {
                println!("cargo:rustc-link-lib=dylib={}", lib_);
            }
            Ok(())
        }
        Err(err) => Err(err),
    }
}