forked from rustls/rustls-ffi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.rs
28 lines (22 loc) · 888 Bytes
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use std::fs::File;
use std::io::Write;
use std::{env, fs, path::PathBuf};
// Keep in sync with Cargo.toml.
const RUSTLS_CRATE_VERSION: &str = "0.20.1";
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/rustls.h", include_dir.join("rustls.h")).unwrap();
println!("cargo:include={}", include_dir.to_str().unwrap());
let dest_path = out_dir.join("version.rs");
let mut f = File::create(&dest_path).expect("Could not create file");
let pkg_version = env!("CARGO_PKG_VERSION");
writeln!(
&mut f,
r#"const RUSTLS_FFI_VERSION: &str = "rustls-ffi/{}/rustls/{}";"#,
pkg_version, RUSTLS_CRATE_VERSION
)
.expect("Could not write file");
println!("cargo:rerun-if-env-changed=CARGO_PKG_VERSION");
}