From 9220a982c9c0d497245935be3fa1bc0554b51462 Mon Sep 17 00:00:00 2001 From: "Stephen M. Coakley" Date: Tue, 9 Feb 2021 20:03:22 -0600 Subject: [PATCH] Allow crustls to be used as an rlib dependency Add the appropriate Cargo metadata to allow crustls to be built as an rlib dependency of another crate. This makes it possible for curl-rust to list crustls as a crate dependency. --- Cargo.toml | 3 ++- build.rs | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 build.rs diff --git a/Cargo.toml b/Cargo.toml index 8d48bfb5..7d22e8fa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,6 +4,7 @@ version = "0.3.0" authors = ["Jacob Hoffman-Andrews "] description = "C-to-rustls bindings" edition = "2018" +links = "crustls" [dependencies] # Keep in sync with RUSTLS_CRATE_VERSION in lib.rs @@ -19,4 +20,4 @@ cbindgen = "*" [lib] name = "crustls" -crate-type = ["staticlib"] +crate-type = ["lib", "staticlib"] diff --git a/build.rs b/build.rs new file mode 100644 index 00000000..6ef3c876 --- /dev/null +++ b/build.rs @@ -0,0 +1,11 @@ +use std::{env, fs, path::PathBuf}; + +fn main() { + let out_dir = PathBuf::from(env::var_os("OUT_DIR").unwrap()); + let include_dir = out_dir.join("include"); + + fs::create_dir_all(&include_dir).unwrap(); + fs::copy("src/crustls.h", include_dir.join("crustls.h")).unwrap(); + + println!("cargo:include={}", include_dir.to_str().unwrap()); +}