Merge pull request #963 from alexcrichton/vendored
Support builds of OpenSSL from vendored source (take 2)
This commit is contained in:
commit
aba29697d3
|
|
@ -1,9 +1,9 @@
|
||||||
restore_registry: &RESTORE_REGISTRY
|
restore_registry: &RESTORE_REGISTRY
|
||||||
restore_cache:
|
restore_cache:
|
||||||
key: registry-3
|
key: registry-4
|
||||||
save_registry: &SAVE_REGISTRY
|
save_registry: &SAVE_REGISTRY
|
||||||
save_cache:
|
save_cache:
|
||||||
key: registry-3-{{ .BuildNum }}
|
key: registry-4-{{ .BuildNum }}
|
||||||
paths:
|
paths:
|
||||||
- /usr/local/cargo/registry/index
|
- /usr/local/cargo/registry/index
|
||||||
openssl_key: &OPENSSL_KEY
|
openssl_key: &OPENSSL_KEY
|
||||||
|
|
@ -38,14 +38,14 @@ job: &JOB
|
||||||
- run: apt-get remove -y libssl-dev
|
- run: apt-get remove -y libssl-dev
|
||||||
- run: ./test/add_target.sh
|
- run: ./test/add_target.sh
|
||||||
- *RESTORE_REGISTRY
|
- *RESTORE_REGISTRY
|
||||||
- run: cargo generate-lockfile
|
- run: cargo generate-lockfile --verbose
|
||||||
- *SAVE_REGISTRY
|
- *SAVE_REGISTRY
|
||||||
- run: echo "${LIBRARY}-${VERSION}-${TARGET}" > ~/lib_key
|
- run: echo "${LIBRARY}-${VERSION}-${TARGET}" > ~/lib_key
|
||||||
- *RESTORE_OPENSSL
|
- *RESTORE_OPENSSL
|
||||||
- run: ./test/build_openssl.sh
|
- run: ./test/build_openssl.sh
|
||||||
- *SAVE_OPENSSL
|
- *SAVE_OPENSSL
|
||||||
- *RESTORE_DEPS
|
- *RESTORE_DEPS
|
||||||
- run: cargo run --manifest-path=systest/Cargo.toml --target $TARGET
|
- run: cargo run --manifest-path=systest/Cargo.toml --target $TARGET --features "$FEATURES"
|
||||||
- run: |
|
- run: |
|
||||||
ulimit -c unlimited
|
ulimit -c unlimited
|
||||||
export PATH=$OPENSSL_DIR/bin:$PATH
|
export PATH=$OPENSSL_DIR/bin:$PATH
|
||||||
|
|
@ -55,6 +55,7 @@ job: &JOB
|
||||||
cargo test \
|
cargo test \
|
||||||
--manifest-path=openssl/Cargo.toml \
|
--manifest-path=openssl/Cargo.toml \
|
||||||
--target $TARGET \
|
--target $TARGET \
|
||||||
|
--features "$FEATURES" \
|
||||||
$TEST_ARGS
|
$TEST_ARGS
|
||||||
- run:
|
- run:
|
||||||
command: |
|
command: |
|
||||||
|
|
@ -69,9 +70,6 @@ job: &JOB
|
||||||
macos_job: &MACOS_JOB
|
macos_job: &MACOS_JOB
|
||||||
macos:
|
macos:
|
||||||
xcode: "9.0"
|
xcode: "9.0"
|
||||||
environment:
|
|
||||||
RUSTUP_HOME: /usr/local/rustup
|
|
||||||
CARGO_HOME: /usr/local/cargo
|
|
||||||
steps:
|
steps:
|
||||||
- checkout
|
- checkout
|
||||||
- run: sudo mkdir /opt
|
- run: sudo mkdir /opt
|
||||||
|
|
@ -83,12 +81,18 @@ macos_job: &MACOS_JOB
|
||||||
- *SAVE_REGISTRY
|
- *SAVE_REGISTRY
|
||||||
- run: echo "homebrew-x86_64-apple-darwin" > ~/lib_key
|
- run: echo "homebrew-x86_64-apple-darwin" > ~/lib_key
|
||||||
- *RESTORE_DEPS
|
- *RESTORE_DEPS
|
||||||
- run: cargo run --manifest-path=systest/Cargo.toml
|
- run: cargo run --manifest-path=systest/Cargo.toml --features "$FEATURES"
|
||||||
- run: |
|
- run: |
|
||||||
PATH=/usr/local/opt/openssl/bin:$PATH
|
PATH=/usr/local/opt/openssl/bin:$PATH
|
||||||
cargo test --manifest-path=openssl/Cargo.toml
|
cargo test --manifest-path=openssl/Cargo.toml --features "$FEATURES"
|
||||||
- *SAVE_DEPS
|
- *SAVE_DEPS
|
||||||
|
macos_env: &MACOS_ENV
|
||||||
|
RUSTUP_HOME: /usr/local/rustup
|
||||||
|
CARGO_HOME: /usr/local/cargo
|
||||||
|
|
||||||
|
vendored: &VENDORED
|
||||||
|
FEATURES: vendored
|
||||||
|
LIBRARY: ""
|
||||||
openssl_111: &OPENSSL_111
|
openssl_111: &OPENSSL_111
|
||||||
LIBRARY: openssl
|
LIBRARY: openssl
|
||||||
VERSION: 1.1.1-pre8
|
VERSION: 1.1.1-pre8
|
||||||
|
|
@ -110,6 +114,8 @@ libressl_270: &LIBRESSL_272
|
||||||
|
|
||||||
x86_64: &X86_64
|
x86_64: &X86_64
|
||||||
TARGET: x86_64-unknown-linux-gnu
|
TARGET: x86_64-unknown-linux-gnu
|
||||||
|
musl: &MUSL
|
||||||
|
TARGET: x86_64-unknown-linux-musl
|
||||||
i686: &I686
|
i686: &I686
|
||||||
TARGET: i686-unknown-linux-gnu
|
TARGET: i686-unknown-linux-gnu
|
||||||
armhf: &ARMHF
|
armhf: &ARMHF
|
||||||
|
|
@ -127,6 +133,16 @@ base: &BASE
|
||||||
|
|
||||||
version: 2
|
version: 2
|
||||||
jobs:
|
jobs:
|
||||||
|
musl-vendored:
|
||||||
|
<<: *JOB
|
||||||
|
docker:
|
||||||
|
- image: rust:1.21.0
|
||||||
|
environment:
|
||||||
|
<<: [*VENDORED, *MUSL, *BASE]
|
||||||
|
x86_64-vendored:
|
||||||
|
<<: *JOB
|
||||||
|
environment:
|
||||||
|
<<: [*VENDORED, *X86_64, *BASE]
|
||||||
x86_64-openssl-1.1.1:
|
x86_64-openssl-1.1.1:
|
||||||
<<: *JOB
|
<<: *JOB
|
||||||
environment:
|
environment:
|
||||||
|
|
@ -143,6 +159,10 @@ jobs:
|
||||||
<<: *JOB
|
<<: *JOB
|
||||||
environment:
|
environment:
|
||||||
<<: [*OPENSSL_101, *X86_64, *BASE]
|
<<: [*OPENSSL_101, *X86_64, *BASE]
|
||||||
|
i686-vendored:
|
||||||
|
<<: *JOB
|
||||||
|
environment:
|
||||||
|
<<: [*VENDORED, *I686, *BASE]
|
||||||
i686-openssl-1.1.1:
|
i686-openssl-1.1.1:
|
||||||
<<: *JOB
|
<<: *JOB
|
||||||
environment:
|
environment:
|
||||||
|
|
@ -155,6 +175,10 @@ jobs:
|
||||||
<<: *JOB
|
<<: *JOB
|
||||||
environment:
|
environment:
|
||||||
<<: [*OPENSSL_102, *I686, *BASE]
|
<<: [*OPENSSL_102, *I686, *BASE]
|
||||||
|
armhf-vendored:
|
||||||
|
<<: *JOB
|
||||||
|
environment:
|
||||||
|
<<: [*VENDORED, *ARMHF, *BASE]
|
||||||
armhf-openssl-1.1.1:
|
armhf-openssl-1.1.1:
|
||||||
<<: *JOB
|
<<: *JOB
|
||||||
environment:
|
environment:
|
||||||
|
|
@ -177,20 +201,31 @@ jobs:
|
||||||
<<: [*LIBRESSL_272, *X86_64, *BASE]
|
<<: [*LIBRESSL_272, *X86_64, *BASE]
|
||||||
macos:
|
macos:
|
||||||
<<: *MACOS_JOB
|
<<: *MACOS_JOB
|
||||||
|
environment:
|
||||||
|
<<: [*MACOS_ENV]
|
||||||
|
macos-vendored:
|
||||||
|
<<: *MACOS_JOB
|
||||||
|
environment:
|
||||||
|
<<: [*VENDORED, *MACOS_ENV]
|
||||||
workflows:
|
workflows:
|
||||||
version: 2
|
version: 2
|
||||||
tests:
|
tests:
|
||||||
jobs:
|
jobs:
|
||||||
|
- musl-vendored
|
||||||
|
- x86_64-vendored
|
||||||
- x86_64-openssl-1.1.1
|
- x86_64-openssl-1.1.1
|
||||||
- x86_64-openssl-1.1.0
|
- x86_64-openssl-1.1.0
|
||||||
- x86_64-openssl-1.0.2
|
- x86_64-openssl-1.0.2
|
||||||
- x86_64-openssl-1.0.1
|
- x86_64-openssl-1.0.1
|
||||||
|
- i686-vendored
|
||||||
- i686-openssl-1.1.1
|
- i686-openssl-1.1.1
|
||||||
- i686-openssl-1.1.0
|
- i686-openssl-1.1.0
|
||||||
- i686-openssl-1.0.2
|
- i686-openssl-1.0.2
|
||||||
|
- armhf-vendored
|
||||||
- armhf-openssl-1.1.1
|
- armhf-openssl-1.1.1
|
||||||
- armhf-openssl-1.1.0
|
- armhf-openssl-1.1.0
|
||||||
- armhf-openssl-1.0.2
|
- armhf-openssl-1.0.2
|
||||||
- x86_64-libressl-2.5.0
|
- x86_64-libressl-2.5.0
|
||||||
- x86_64-libressl-2.7.2
|
- x86_64-libressl-2.7.2
|
||||||
- macos
|
- macos
|
||||||
|
- macos-vendored
|
||||||
|
|
|
||||||
|
|
@ -11,12 +11,16 @@ categories = ["cryptography", "external-ffi-bindings"]
|
||||||
links = "openssl"
|
links = "openssl"
|
||||||
build = "build/main.rs"
|
build = "build/main.rs"
|
||||||
|
|
||||||
|
[features]
|
||||||
|
vendored = ['openssl-src']
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
libc = "0.2"
|
libc = "0.2"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
pkg-config = "0.3.9"
|
pkg-config = "0.3.9"
|
||||||
cc = "1.0"
|
cc = "1.0"
|
||||||
|
openssl-src = { version = "110.0.4", optional = true }
|
||||||
|
|
||||||
[target.'cfg(target_env = "msvc")'.build-dependencies]
|
[target.'cfg(target_env = "msvc")'.build-dependencies]
|
||||||
vcpkg = "0.2"
|
vcpkg = "0.2"
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@ extern crate cc;
|
||||||
extern crate pkg_config;
|
extern crate pkg_config;
|
||||||
#[cfg(target_env = "msvc")]
|
#[cfg(target_env = "msvc")]
|
||||||
extern crate vcpkg;
|
extern crate vcpkg;
|
||||||
|
#[cfg(feature = "vendored")]
|
||||||
|
extern crate openssl_src;
|
||||||
|
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use std::env;
|
use std::env;
|
||||||
|
|
@ -9,7 +11,6 @@ use std::ffi::OsString;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::{BufWriter, Write};
|
use std::io::{BufWriter, Write};
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::process::Command;
|
|
||||||
|
|
||||||
mod cfgs;
|
mod cfgs;
|
||||||
|
|
||||||
|
|
@ -52,18 +53,7 @@ fn env(name: &str) -> Option<OsString> {
|
||||||
fn main() {
|
fn main() {
|
||||||
let target = env::var("TARGET").unwrap();
|
let target = env::var("TARGET").unwrap();
|
||||||
|
|
||||||
let lib_dir = env("OPENSSL_LIB_DIR").map(PathBuf::from);
|
let (lib_dir, include_dir) = imp::get_openssl(&target);
|
||||||
let include_dir = env("OPENSSL_INCLUDE_DIR").map(PathBuf::from);
|
|
||||||
|
|
||||||
let (lib_dir, include_dir) = if lib_dir.is_none() || include_dir.is_none() {
|
|
||||||
let openssl_dir = env("OPENSSL_DIR").unwrap_or_else(|| find_openssl_dir(&target));
|
|
||||||
let openssl_dir = Path::new(&openssl_dir);
|
|
||||||
let lib_dir = lib_dir.unwrap_or_else(|| openssl_dir.join("lib"));
|
|
||||||
let include_dir = include_dir.unwrap_or_else(|| openssl_dir.join("include"));
|
|
||||||
(lib_dir, include_dir)
|
|
||||||
} else {
|
|
||||||
(lib_dir.unwrap(), include_dir.unwrap())
|
|
||||||
};
|
|
||||||
|
|
||||||
if !Path::new(&lib_dir).exists() {
|
if !Path::new(&lib_dir).exists() {
|
||||||
panic!(
|
panic!(
|
||||||
|
|
@ -110,48 +100,83 @@ fn main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn find_openssl_dir(target: &str) -> OsString {
|
#[cfg(feature = "vendored")]
|
||||||
let host = env::var("HOST").unwrap();
|
mod imp {
|
||||||
|
use std::path::PathBuf;
|
||||||
|
use openssl_src;
|
||||||
|
|
||||||
if host == target && target.contains("apple-darwin") {
|
pub fn get_openssl(_target: &str) -> (PathBuf, PathBuf) {
|
||||||
// Check up default Homebrew installation location first
|
let artifacts = openssl_src::Build::new().build();
|
||||||
// for quick resolution if possible.
|
(artifacts.lib_dir().to_path_buf(), artifacts.include_dir().to_path_buf())
|
||||||
let homebrew = Path::new("/usr/local/opt/openssl@1.1");
|
}
|
||||||
if homebrew.exists() {
|
}
|
||||||
return homebrew.to_path_buf().into();
|
|
||||||
}
|
#[cfg(not(feature = "vendored"))]
|
||||||
let homebrew = Path::new("/usr/local/opt/openssl");
|
mod imp {
|
||||||
if homebrew.exists() {
|
use pkg_config;
|
||||||
return homebrew.to_path_buf().into();
|
use std::path::{Path, PathBuf};
|
||||||
}
|
use std::ffi::OsString;
|
||||||
// Calling `brew --prefix <package>` command usually slow and
|
use std::process::{self, Command};
|
||||||
// takes seconds, and will be used only as a last resort.
|
|
||||||
let output = execute_command_and_get_output("brew", &["--prefix", "openssl@1.1"]);
|
use super::env;
|
||||||
if let Some(ref output) = output {
|
|
||||||
let homebrew = Path::new(&output);
|
pub fn get_openssl(target: &str) -> (PathBuf, PathBuf) {
|
||||||
if homebrew.exists() {
|
let lib_dir = env("OPENSSL_LIB_DIR").map(PathBuf::from);
|
||||||
return homebrew.to_path_buf().into();
|
let include_dir = env("OPENSSL_INCLUDE_DIR").map(PathBuf::from);
|
||||||
}
|
|
||||||
}
|
if lib_dir.is_none() || include_dir.is_none() {
|
||||||
let output = execute_command_and_get_output("brew", &["--prefix", "openssl"]);
|
let openssl_dir = env("OPENSSL_DIR").unwrap_or_else(|| find_openssl_dir(&target));
|
||||||
if let Some(ref output) = output {
|
let openssl_dir = Path::new(&openssl_dir);
|
||||||
let homebrew = Path::new(&output);
|
let lib_dir = lib_dir.unwrap_or_else(|| openssl_dir.join("lib"));
|
||||||
if homebrew.exists() {
|
let include_dir = include_dir.unwrap_or_else(|| openssl_dir.join("include"));
|
||||||
return homebrew.to_path_buf().into();
|
(lib_dir, include_dir)
|
||||||
}
|
} else {
|
||||||
|
(lib_dir.unwrap(), include_dir.unwrap())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try_pkg_config();
|
fn find_openssl_dir(target: &str) -> OsString {
|
||||||
try_vcpkg();
|
let host = env::var("HOST").unwrap();
|
||||||
|
|
||||||
// FreeBSD ships with OpenSSL but doesn't include a pkg-config file :(
|
if host == target && target.contains("apple-darwin") {
|
||||||
if host == target && target.contains("freebsd") {
|
// Check up default Homebrew installation location first
|
||||||
return OsString::from("/usr");
|
// for quick resolution if possible.
|
||||||
}
|
let homebrew = Path::new("/usr/local/opt/openssl@1.1");
|
||||||
|
if homebrew.exists() {
|
||||||
|
return homebrew.to_path_buf().into();
|
||||||
|
}
|
||||||
|
let homebrew = Path::new("/usr/local/opt/openssl");
|
||||||
|
if homebrew.exists() {
|
||||||
|
return homebrew.to_path_buf().into();
|
||||||
|
}
|
||||||
|
// Calling `brew --prefix <package>` command usually slow and
|
||||||
|
// takes seconds, and will be used only as a last resort.
|
||||||
|
let output = execute_command_and_get_output("brew", &["--prefix", "openssl@1.1"]);
|
||||||
|
if let Some(ref output) = output {
|
||||||
|
let homebrew = Path::new(&output);
|
||||||
|
if homebrew.exists() {
|
||||||
|
return homebrew.to_path_buf().into();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let output = execute_command_and_get_output("brew", &["--prefix", "openssl"]);
|
||||||
|
if let Some(ref output) = output {
|
||||||
|
let homebrew = Path::new(&output);
|
||||||
|
if homebrew.exists() {
|
||||||
|
return homebrew.to_path_buf().into();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let mut msg = format!(
|
try_pkg_config();
|
||||||
"
|
try_vcpkg();
|
||||||
|
|
||||||
|
// FreeBSD ships with OpenSSL but doesn't include a pkg-config file :(
|
||||||
|
if host == target && target.contains("freebsd") {
|
||||||
|
return OsString::from("/usr");
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut msg = format!(
|
||||||
|
"
|
||||||
|
|
||||||
Could not find directory of OpenSSL installation, and this `-sys` crate cannot
|
Could not find directory of OpenSSL installation, and this `-sys` crate cannot
|
||||||
proceed without this knowledge. If OpenSSL is installed and this crate had
|
proceed without this knowledge. If OpenSSL is installed and this crate had
|
||||||
|
|
@ -170,16 +195,16 @@ and include information about your system as well as this message.
|
||||||
openssl-sys = {}
|
openssl-sys = {}
|
||||||
|
|
||||||
",
|
",
|
||||||
host,
|
host,
|
||||||
target,
|
target,
|
||||||
env!("CARGO_PKG_VERSION")
|
env!("CARGO_PKG_VERSION")
|
||||||
);
|
);
|
||||||
|
|
||||||
if host.contains("apple-darwin") && target.contains("apple-darwin") {
|
if host.contains("apple-darwin") && target.contains("apple-darwin") {
|
||||||
let system = Path::new("/usr/lib/libssl.0.9.8.dylib");
|
let system = Path::new("/usr/lib/libssl.0.9.8.dylib");
|
||||||
if system.exists() {
|
if system.exists() {
|
||||||
msg.push_str(&format!(
|
msg.push_str(&format!(
|
||||||
"
|
"
|
||||||
|
|
||||||
It looks like you're compiling on macOS, where the system contains a version of
|
It looks like you're compiling on macOS, where the system contains a version of
|
||||||
OpenSSL 0.9.8. This crate no longer supports OpenSSL 0.9.8.
|
OpenSSL 0.9.8. This crate no longer supports OpenSSL 0.9.8.
|
||||||
|
|
@ -191,27 +216,27 @@ install the `openssl` package, or as a maintainer you can use the openssl-sys
|
||||||
Unfortunately though the compile cannot continue, so aborting.
|
Unfortunately though the compile cannot continue, so aborting.
|
||||||
|
|
||||||
"
|
"
|
||||||
));
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if host.contains("unknown-linux") && target.contains("unknown-linux-gnu") {
|
if host.contains("unknown-linux") && target.contains("unknown-linux-gnu") {
|
||||||
if Command::new("pkg-config").output().is_err() {
|
if Command::new("pkg-config").output().is_err() {
|
||||||
msg.push_str(&format!(
|
msg.push_str(&format!(
|
||||||
"
|
"
|
||||||
It looks like you're compiling on Linux and also targeting Linux. Currently this
|
It looks like you're compiling on Linux and also targeting Linux. Currently this
|
||||||
requires the `pkg-config` utility to find OpenSSL but unfortunately `pkg-config`
|
requires the `pkg-config` utility to find OpenSSL but unfortunately `pkg-config`
|
||||||
could not be found. If you have OpenSSL installed you can likely fix this by
|
could not be found. If you have OpenSSL installed you can likely fix this by
|
||||||
installing `pkg-config`.
|
installing `pkg-config`.
|
||||||
|
|
||||||
"
|
"
|
||||||
));
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if host.contains("windows") && target.contains("windows-gnu") {
|
if host.contains("windows") && target.contains("windows-gnu") {
|
||||||
msg.push_str(&format!(
|
msg.push_str(&format!(
|
||||||
"
|
"
|
||||||
It looks like you're compiling for MinGW but you may not have either OpenSSL or
|
It looks like you're compiling for MinGW but you may not have either OpenSSL or
|
||||||
pkg-config installed. You can install these two dependencies with:
|
pkg-config installed. You can install these two dependencies with:
|
||||||
|
|
||||||
|
|
@ -220,12 +245,12 @@ pkg-config installed. You can install these two dependencies with:
|
||||||
and try building this crate again.
|
and try building this crate again.
|
||||||
|
|
||||||
"
|
"
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
if host.contains("windows") && target.contains("windows-msvc") {
|
if host.contains("windows") && target.contains("windows-msvc") {
|
||||||
msg.push_str(&format!(
|
msg.push_str(&format!(
|
||||||
"
|
"
|
||||||
It looks like you're compiling for MSVC but we couldn't detect an OpenSSL
|
It looks like you're compiling for MSVC but we couldn't detect an OpenSSL
|
||||||
installation. If there isn't one installed then you can try the rust-openssl
|
installation. If there isn't one installed then you can try the rust-openssl
|
||||||
README for more information about how to download precompiled binaries of
|
README for more information about how to download precompiled binaries of
|
||||||
|
|
@ -234,97 +259,113 @@ OpenSSL:
|
||||||
https://github.com/sfackler/rust-openssl#windows
|
https://github.com/sfackler/rust-openssl#windows
|
||||||
|
|
||||||
"
|
"
|
||||||
));
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
panic!(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
panic!(msg);
|
/// Attempt to find OpenSSL through pkg-config.
|
||||||
}
|
///
|
||||||
|
/// Note that if this succeeds then the function does not return as pkg-config
|
||||||
|
/// typically tells us all the information that we need.
|
||||||
|
fn try_pkg_config() {
|
||||||
|
let target = env::var("TARGET").unwrap();
|
||||||
|
let host = env::var("HOST").unwrap();
|
||||||
|
|
||||||
/// Attempt to find OpenSSL through pkg-config.
|
// If we're going to windows-gnu we can use pkg-config, but only so long as
|
||||||
///
|
// we're coming from a windows host.
|
||||||
/// Note that if this succeeds then the function does not return as pkg-config
|
//
|
||||||
/// typically tells us all the information that we need.
|
// Otherwise if we're going to windows we probably can't use pkg-config.
|
||||||
fn try_pkg_config() {
|
if target.contains("windows-gnu") && host.contains("windows") {
|
||||||
let target = env::var("TARGET").unwrap();
|
env::set_var("PKG_CONFIG_ALLOW_CROSS", "1");
|
||||||
let host = env::var("HOST").unwrap();
|
} else if target.contains("windows") {
|
||||||
|
|
||||||
// If we're going to windows-gnu we can use pkg-config, but only so long as
|
|
||||||
// we're coming from a windows host.
|
|
||||||
//
|
|
||||||
// Otherwise if we're going to windows we probably can't use pkg-config.
|
|
||||||
if target.contains("windows-gnu") && host.contains("windows") {
|
|
||||||
env::set_var("PKG_CONFIG_ALLOW_CROSS", "1");
|
|
||||||
} else if target.contains("windows") {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let lib = match pkg_config::Config::new()
|
|
||||||
.print_system_libs(false)
|
|
||||||
.find("openssl")
|
|
||||||
{
|
|
||||||
Ok(lib) => lib,
|
|
||||||
Err(e) => {
|
|
||||||
println!("run pkg_config fail: {:?}", e);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
validate_headers(&lib.include_paths);
|
let lib = match pkg_config::Config::new()
|
||||||
|
.print_system_libs(false)
|
||||||
|
.find("openssl")
|
||||||
|
{
|
||||||
|
Ok(lib) => lib,
|
||||||
|
Err(e) => {
|
||||||
|
println!("run pkg_config fail: {:?}", e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
for include in lib.include_paths.iter() {
|
super::validate_headers(&lib.include_paths);
|
||||||
println!("cargo:include={}", include.display());
|
|
||||||
|
for include in lib.include_paths.iter() {
|
||||||
|
println!("cargo:include={}", include.display());
|
||||||
|
}
|
||||||
|
|
||||||
|
process::exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::process::exit(0);
|
/// Attempt to find OpenSSL through vcpkg.
|
||||||
}
|
///
|
||||||
|
/// Note that if this succeeds then the function does not return as vcpkg
|
||||||
|
/// should emit all of the cargo metadata that we need.
|
||||||
|
#[cfg(target_env = "msvc")]
|
||||||
|
fn try_vcpkg() {
|
||||||
|
use vcpkg;
|
||||||
|
|
||||||
/// Attempt to find OpenSSL through vcpkg.
|
// vcpkg will not emit any metadata if it can not find libraries
|
||||||
///
|
// appropriate for the target triple with the desired linkage.
|
||||||
/// Note that if this succeeds then the function does not return as vcpkg
|
|
||||||
/// should emit all of the cargo metadata that we need.
|
|
||||||
#[cfg(target_env = "msvc")]
|
|
||||||
fn try_vcpkg() {
|
|
||||||
// vcpkg will not emit any metadata if it can not find libraries
|
|
||||||
// appropriate for the target triple with the desired linkage.
|
|
||||||
|
|
||||||
let mut lib = vcpkg::Config::new()
|
let mut lib = vcpkg::Config::new()
|
||||||
.emit_includes(true)
|
|
||||||
.lib_name("libcrypto")
|
|
||||||
.lib_name("libssl")
|
|
||||||
.probe("openssl");
|
|
||||||
|
|
||||||
if let Err(e) = lib {
|
|
||||||
println!(
|
|
||||||
"note: vcpkg did not find openssl as libcrypto and libssl : {:?}",
|
|
||||||
e
|
|
||||||
);
|
|
||||||
lib = vcpkg::Config::new()
|
|
||||||
.emit_includes(true)
|
.emit_includes(true)
|
||||||
.lib_name("libeay32")
|
.lib_name("libcrypto")
|
||||||
.lib_name("ssleay32")
|
.lib_name("libssl")
|
||||||
.probe("openssl");
|
.probe("openssl");
|
||||||
}
|
|
||||||
if let Err(e) = lib {
|
if let Err(e) = lib {
|
||||||
println!(
|
println!(
|
||||||
"note: vcpkg did not find openssl as ssleay32 and libeay32: {:?}",
|
"note: vcpkg did not find openssl as libcrypto and libssl : {:?}",
|
||||||
e
|
e
|
||||||
);
|
);
|
||||||
return;
|
lib = vcpkg::Config::new()
|
||||||
|
.emit_includes(true)
|
||||||
|
.lib_name("libeay32")
|
||||||
|
.lib_name("ssleay32")
|
||||||
|
.probe("openssl");
|
||||||
|
}
|
||||||
|
if let Err(e) = lib {
|
||||||
|
println!(
|
||||||
|
"note: vcpkg did not find openssl as ssleay32 and libeay32: {:?}",
|
||||||
|
e
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let lib = lib.unwrap();
|
||||||
|
super::validate_headers(&lib.include_paths);
|
||||||
|
|
||||||
|
println!("cargo:rustc-link-lib=user32");
|
||||||
|
println!("cargo:rustc-link-lib=gdi32");
|
||||||
|
println!("cargo:rustc-link-lib=crypt32");
|
||||||
|
|
||||||
|
process::exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
let lib = lib.unwrap();
|
#[cfg(not(target_env = "msvc"))]
|
||||||
validate_headers(&lib.include_paths);
|
fn try_vcpkg() {}
|
||||||
|
|
||||||
println!("cargo:rustc-link-lib=user32");
|
fn execute_command_and_get_output(cmd: &str, args: &[&str]) -> Option<String> {
|
||||||
println!("cargo:rustc-link-lib=gdi32");
|
let out = Command::new(cmd).args(args).output();
|
||||||
println!("cargo:rustc-link-lib=crypt32");
|
if let Ok(ref r1) = out {
|
||||||
|
if r1.status.success() {
|
||||||
std::process::exit(0);
|
let r2 = String::from_utf8(r1.stdout.clone());
|
||||||
|
if let Ok(r3) = r2 {
|
||||||
|
return Some(r3.trim().to_string());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return None;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(target_env = "msvc"))]
|
|
||||||
fn try_vcpkg() {}
|
|
||||||
|
|
||||||
/// Validates the header files found in `include_dir` and then returns the
|
/// Validates the header files found in `include_dir` and then returns the
|
||||||
/// version string of OpenSSL.
|
/// version string of OpenSSL.
|
||||||
fn validate_headers(include_dirs: &[PathBuf]) -> Version {
|
fn validate_headers(include_dirs: &[PathBuf]) -> Version {
|
||||||
|
|
@ -565,16 +606,3 @@ fn determine_mode(libdir: &Path, libs: &[&str]) -> &'static str {
|
||||||
// practices with security libs", let's link dynamically.
|
// practices with security libs", let's link dynamically.
|
||||||
"dylib"
|
"dylib"
|
||||||
}
|
}
|
||||||
|
|
||||||
fn execute_command_and_get_output(cmd: &str, args: &[&str]) -> Option<String> {
|
|
||||||
let out = Command::new(cmd).args(args).output();
|
|
||||||
if let Ok(ref r1) = out {
|
|
||||||
if r1.status.success() {
|
|
||||||
let r2 = String::from_utf8(r1.stdout.clone());
|
|
||||||
if let Ok(r3) = r2 {
|
|
||||||
return Some(r3.trim().to_string());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,8 @@ v102 = []
|
||||||
v110 = []
|
v110 = []
|
||||||
v111 = []
|
v111 = []
|
||||||
|
|
||||||
|
vendored = ['openssl-sys/vendored']
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bitflags = "1.0"
|
bitflags = "1.0"
|
||||||
cfg-if = "0.1"
|
cfg-if = "0.1"
|
||||||
|
|
|
||||||
|
|
@ -775,6 +775,7 @@ fn refcount_ssl_context() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg_attr(libressl250, ignore)]
|
#[cfg_attr(libressl250, ignore)]
|
||||||
|
#[cfg_attr(all(target_os = "macos", feature = "vendored"), ignore)]
|
||||||
fn default_verify_paths() {
|
fn default_verify_paths() {
|
||||||
let mut ctx = SslContext::builder(SslMethod::tls()).unwrap();
|
let mut ctx = SslContext::builder(SslMethod::tls()).unwrap();
|
||||||
ctx.set_default_verify_paths().unwrap();
|
ctx.set_default_verify_paths().unwrap();
|
||||||
|
|
@ -804,6 +805,7 @@ fn add_extra_chain_cert() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(any(ossl102, ossl110))]
|
#[cfg(any(ossl102, ossl110))]
|
||||||
|
#[cfg_attr(all(target_os = "macos", feature = "vendored"), ignore)]
|
||||||
fn verify_valid_hostname() {
|
fn verify_valid_hostname() {
|
||||||
let mut ctx = SslContext::builder(SslMethod::tls()).unwrap();
|
let mut ctx = SslContext::builder(SslMethod::tls()).unwrap();
|
||||||
ctx.set_default_verify_paths().unwrap();
|
ctx.set_default_verify_paths().unwrap();
|
||||||
|
|
@ -845,6 +847,7 @@ fn verify_invalid_hostname() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg_attr(libressl250, ignore)]
|
#[cfg_attr(libressl250, ignore)]
|
||||||
|
#[cfg_attr(all(target_os = "macos", feature = "vendored"), ignore)]
|
||||||
fn connector_valid_hostname() {
|
fn connector_valid_hostname() {
|
||||||
let connector = SslConnector::builder(SslMethod::tls()).unwrap().build();
|
let connector = SslConnector::builder(SslMethod::tls()).unwrap().build();
|
||||||
|
|
||||||
|
|
@ -861,6 +864,7 @@ fn connector_valid_hostname() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[cfg_attr(all(target_os = "macos", feature = "vendored"), ignore)]
|
||||||
fn connector_invalid_hostname() {
|
fn connector_invalid_hostname() {
|
||||||
let connector = SslConnector::builder(SslMethod::tls()).unwrap().build();
|
let connector = SslConnector::builder(SslMethod::tls()).unwrap().build();
|
||||||
|
|
||||||
|
|
@ -870,6 +874,7 @@ fn connector_invalid_hostname() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg_attr(libressl250, ignore)]
|
#[cfg_attr(libressl250, ignore)]
|
||||||
|
#[cfg_attr(all(target_os = "macos", feature = "vendored"), ignore)]
|
||||||
fn connector_invalid_no_hostname_verification() {
|
fn connector_invalid_no_hostname_verification() {
|
||||||
let connector = SslConnector::builder(SslMethod::tls()).unwrap().build();
|
let connector = SslConnector::builder(SslMethod::tls()).unwrap().build();
|
||||||
|
|
||||||
|
|
@ -1202,6 +1207,7 @@ fn idle_session() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg_attr(libressl250, ignore)]
|
#[cfg_attr(libressl250, ignore)]
|
||||||
|
#[cfg_attr(all(target_os = "macos", feature = "vendored"), ignore)]
|
||||||
fn active_session() {
|
fn active_session() {
|
||||||
let connector = SslConnector::builder(SslMethod::tls()).unwrap().build();
|
let connector = SslConnector::builder(SslMethod::tls()).unwrap().build();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,3 +9,6 @@ openssl-sys = { path = "../openssl-sys" }
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
ctest = "0.1"
|
ctest = "0.1"
|
||||||
|
|
||||||
|
[features]
|
||||||
|
vendored = ['openssl-sys/vendored']
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,9 @@ case "${TARGET}" in
|
||||||
"i686-unknown-linux-gnu")
|
"i686-unknown-linux-gnu")
|
||||||
apt-get install -y --no-install-recommends gcc-multilib
|
apt-get install -y --no-install-recommends gcc-multilib
|
||||||
;;
|
;;
|
||||||
|
"x86_64-unknown-linux-musl")
|
||||||
|
apt-get install -y --no-install-recommends musl-tools
|
||||||
|
;;
|
||||||
"arm-unknown-linux-gnueabihf")
|
"arm-unknown-linux-gnueabihf")
|
||||||
dpkg --add-architecture armhf
|
dpkg --add-architecture armhf
|
||||||
apt-get update
|
apt-get update
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,6 @@ if [ -d "${OPENSSL_DIR}" ]; then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
apt-get install -y --no-install-recommends curl
|
|
||||||
|
|
||||||
case "${LIBRARY}" in
|
case "${LIBRARY}" in
|
||||||
"libressl")
|
"libressl")
|
||||||
URL1="http://ftp3.usa.openbsd.org/pub/OpenBSD/LibreSSL/libressl-${VERSION}.tar.gz"
|
URL1="http://ftp3.usa.openbsd.org/pub/OpenBSD/LibreSSL/libressl-${VERSION}.tar.gz"
|
||||||
|
|
@ -16,8 +14,14 @@ case "${LIBRARY}" in
|
||||||
URL1="https://openssl.org/source/openssl-${VERSION}.tar.gz"
|
URL1="https://openssl.org/source/openssl-${VERSION}.tar.gz"
|
||||||
URL2="http://mirrors.ibiblio.org/openssl/source/openssl-${VERSION}.tar.gz"
|
URL2="http://mirrors.ibiblio.org/openssl/source/openssl-${VERSION}.tar.gz"
|
||||||
;;
|
;;
|
||||||
|
"")
|
||||||
|
# using the vendored builds
|
||||||
|
exit 0;
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
apt-get install -y --no-install-recommends curl
|
||||||
|
|
||||||
case "${TARGET}" in
|
case "${TARGET}" in
|
||||||
"x86_64-unknown-linux-gnu")
|
"x86_64-unknown-linux-gnu")
|
||||||
OS_COMPILER=linux-x86_64
|
OS_COMPILER=linux-x86_64
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue