From 51c8d6a0b7fab89c417671e52be5930d96a3575d Mon Sep 17 00:00:00 2001 From: Rodolphe Breard Date: Sat, 8 Jun 2019 18:32:39 +0200 Subject: [PATCH] Prepare the build tools for the standalone feature --- acme_common/Cargo.toml | 7 +++++-- acmed/Cargo.toml | 7 +++++-- acmed/build.rs | 21 +++++++++++++++++++++ tacd/Cargo.toml | 8 +++++--- 4 files changed, 36 insertions(+), 7 deletions(-) diff --git a/acme_common/Cargo.toml b/acme_common/Cargo.toml index fa6aec9..ed9e9e9 100644 --- a/acme_common/Cargo.toml +++ b/acme_common/Cargo.toml @@ -11,6 +11,10 @@ include = ["src/**/*", "Cargo.toml", "Licence_*.txt"] [lib] name = "acme_common" +[features] +default = ["openssl"] +standalone = [] + [dependencies] base64 = "0.10" daemonize = "0.4" @@ -18,8 +22,7 @@ env_logger = "0.6" handlebars = "2.0.0-beta.2" http_req = "0.5" log = "0.4" -openssl = "0.10" -serde = { version = "1.0", features = ["derive"] } +openssl = { version = "0.10", optional = true } serde_json = "1.0" syslog = "4.0" time = "0.1" diff --git a/acmed/Cargo.toml b/acmed/Cargo.toml index 91cc4ab..c286aed 100644 --- a/acmed/Cargo.toml +++ b/acmed/Cargo.toml @@ -11,6 +11,10 @@ license = "MIT OR Apache-2.0" include = ["src/**/*", "Cargo.toml", "LICENSE-*.txt"] build = "build.rs" +[features] +default = ["openssl-sys"] +standalone = [] + [dependencies] acme_common = { path = "../acme_common" } clap = "2.32" @@ -18,8 +22,7 @@ handlebars = "2.0.0-beta.2" http_req = "0.5" log = "0.4" nom = "5.0.0-beta2" -openssl = "0.10" -openssl-sys = "0.9" +openssl-sys = { version = "0.9", optional = true } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" time = "0.1" diff --git a/acmed/build.rs b/acmed/build.rs index 5907ccc..745d83d 100644 --- a/acmed/build.rs +++ b/acmed/build.rs @@ -5,6 +5,7 @@ use serde::Deserialize; use std::env; use std::fs::File; use std::io::prelude::*; +use std::io::BufReader; use std::path::PathBuf; macro_rules! set_rustc_env_var { @@ -91,6 +92,21 @@ fn get_openssl_version(v: &str) -> String { } } +fn get_lib_version(lib: &str) -> Option { + let pat = format!("\"checksum {} ", lib); + let mut lock_file = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()); + lock_file.push("../Cargo.lock"); + let file = File::open(lock_file).unwrap(); + for line in BufReader::new(file).lines() { + let line = line.unwrap(); + if line.starts_with(&pat) { + let v: Vec<&str> = line.split(' ').collect(); + return Some(String::from(v[2])); + } + } + None +} + fn set_tls() { if let Ok(v) = env::var("DEP_OPENSSL_VERSION_NUMBER") { let version = get_openssl_version(&v); @@ -102,6 +118,11 @@ fn set_tls() { set_rustc_env_var!("ACMED_TLS_LIB_VERSION", version); set_rustc_env_var!("ACMED_TLS_LIB_NAME", "LibreSSL"); } + if let Ok(_) = env::var("CARGO_FEATURE_STANDALONE") { + let version = get_lib_version("ring").unwrap(); + set_rustc_env_var!("ACMED_TLS_LIB_VERSION", version); + set_rustc_env_var!("ACMED_TLS_LIB_NAME", "ring"); + } } fn set_target() { diff --git a/tacd/Cargo.toml b/tacd/Cargo.toml index 7d3cf60..e6b21a8 100644 --- a/tacd/Cargo.toml +++ b/tacd/Cargo.toml @@ -10,10 +10,12 @@ readme = "../README.md" license = "MIT OR Apache-2.0" include = ["src/**/*", "Cargo.toml", "LICENSE-*.txt"] +[features] +default = ["openssl"] +standalone = [] + [dependencies] acme_common = { path = "../acme_common" } clap = "2.32" -env_logger = "0.6" log = "0.4" -openssl = "0.10" -syslog = "4.0" +openssl = { version = "0.10", optional = true }