Pass include directories to gcc
This commit is contained in:
parent
370dba4a2c
commit
d4c5bafa19
|
|
@ -19,7 +19,7 @@ aes_xts = []
|
|||
|
||||
[build-dependencies]
|
||||
pkg-config = "0.2.1"
|
||||
gcc = "0.1"
|
||||
gcc = "0.2"
|
||||
|
||||
[target.le32-unknown-nacl.dependencies]
|
||||
libressl-pnacl-sys = "2.1.0"
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
#![feature(env)]
|
||||
#![feature(env, path)]
|
||||
|
||||
extern crate "pkg-config" as pkg_config;
|
||||
extern crate gcc;
|
||||
|
||||
use std::env;
|
||||
use std::default::Default;
|
||||
|
||||
fn main() {
|
||||
let target = env::var("TARGET").unwrap();
|
||||
|
|
@ -21,18 +20,18 @@ fn main() {
|
|||
if target.contains("win32") || target.contains("win64") || target.contains("windows") {
|
||||
println!("cargo:rustc-flags=-l crypto -l ssl -l gdi32 -l wsock32");
|
||||
// going to assume the user has a new version of openssl
|
||||
build_old_openssl_shim(false);
|
||||
build_old_openssl_shim(false, vec![]);
|
||||
return;
|
||||
}
|
||||
|
||||
if pkg_config::Config::new().atleast_version("1.0.0").find("openssl").is_ok() {
|
||||
build_old_openssl_shim(false);
|
||||
build_old_openssl_shim(false, vec![]);
|
||||
return;
|
||||
}
|
||||
|
||||
let err = match pkg_config::find_library("openssl") {
|
||||
Ok(..) => {
|
||||
build_old_openssl_shim(true);
|
||||
Ok(info) => {
|
||||
build_old_openssl_shim(true, info.include_paths);
|
||||
return;
|
||||
}
|
||||
Err(err) => err,
|
||||
|
|
@ -42,22 +41,25 @@ fn main() {
|
|||
if target.contains("bsd") {
|
||||
println!("cargo:rustc-flags=-l crypto -l ssl");
|
||||
// going to assume the base system includes a new version of openssl
|
||||
build_old_openssl_shim(false);
|
||||
build_old_openssl_shim(false, vec![]);
|
||||
return;
|
||||
}
|
||||
|
||||
panic!("unable to find openssl: {}", err);
|
||||
}
|
||||
|
||||
fn build_old_openssl_shim(is_old: bool) {
|
||||
let mut config: gcc::Config = Default::default();
|
||||
fn build_old_openssl_shim(is_old: bool, include_paths: Vec<Path>) {
|
||||
let mut config = gcc::Config::new();
|
||||
|
||||
for path in include_paths {
|
||||
config.include(path);
|
||||
}
|
||||
if is_old {
|
||||
config.definitions.push(("OLD_OPENSSL".to_string(), None));
|
||||
config.define("OLD_OPENSSL", None);
|
||||
}
|
||||
|
||||
gcc::compile_library("libold_openssl_shim.a",
|
||||
&config,
|
||||
&["src/old_openssl_shim.c"]);
|
||||
config.file("src/old_openssl_shim.c")
|
||||
.compile("libold_openssl_shim.a");
|
||||
|
||||
let out_dir = env::var("OUT_DIR").unwrap();
|
||||
println!("cargo:rustc-flags=-L native={} -l old_openssl_shim:static", out_dir);
|
||||
|
|
|
|||
Loading…
Reference in New Issue