diff options
| author | Steven Fackler <[email protected]> | 2016-08-11 21:01:27 -0700 |
|---|---|---|
| committer | Steven Fackler <[email protected]> | 2016-08-11 21:01:27 -0700 |
| commit | 652326003cefe215dbfc838051e6114515cc5190 (patch) | |
| tree | 22dc99a726321cd8228004c34c40ca4a0648c594 /openssl-sys-extras/build.rs | |
| parent | Merge branch 'release-v0.7.14' into release (diff) | |
| parent | Release openssl-sys v0.7.15, openssl v0.8.0 (diff) | |
| download | rust-openssl-openssl-sys-v0.7.15.tar.xz rust-openssl-openssl-sys-v0.7.15.zip | |
Merge branch 'release-v0.7.15-sys-v0.8.0' into releaseopenssl-v0.8.0openssl-sys-v0.7.15
Diffstat (limited to 'openssl-sys-extras/build.rs')
| -rw-r--r-- | openssl-sys-extras/build.rs | 77 |
1 files changed, 0 insertions, 77 deletions
diff --git a/openssl-sys-extras/build.rs b/openssl-sys-extras/build.rs deleted file mode 100644 index e3c695b1..00000000 --- a/openssl-sys-extras/build.rs +++ /dev/null @@ -1,77 +0,0 @@ -extern crate gcc; - -use std::env; -use std::path::PathBuf; -use std::fs::File; -use std::io::Write as IoWrite; -use std::fmt::Write; - -fn main() { - let options_shim_file = generate_options_shim(); - let mut config = gcc::Config::new(); - - if let Some(paths) = env::var_os("DEP_OPENSSL_INCLUDE") { - for path in env::split_paths(&paths) { - config.include(PathBuf::from(path)); - } - } - - config.file("src/openssl_shim.c") - .file(options_shim_file) - .compile("libopenssl_shim.a"); -} - -macro_rules! import_options { - ( $( $name:ident $val:expr )* ) => { - &[ $( (stringify!($name),$val), )* ] - }; -} - -fn generate_options_shim() -> PathBuf { - let options: &[(&'static str,u64)]=include!("src/ssl_options.rs"); - let mut shim = String::new(); - writeln!(shim,"#include <stdint.h>").unwrap(); - writeln!(shim,"#include <openssl/ssl.h>").unwrap(); - - for &(name,value) in options { - writeln!(shim,"#define RUST_{} UINT64_C({})",name,value).unwrap(); - writeln!(shim,"#ifndef {}",name).unwrap(); - writeln!(shim,"# define {} 0",name).unwrap(); - writeln!(shim,"#endif").unwrap(); - } - - writeln!(shim,"#define COPY_MASK ( \\").unwrap(); - - let mut it=options.iter().peekable(); - while let Some(&(name,_))=it.next() { - let eol=match it.peek() { - Some(_) => " | \\", - None => " )" - }; - writeln!(shim," ((RUST_{0}==(uint64_t)(uint32_t){0})?RUST_{0}:UINT64_C(0)){1}",name,eol).unwrap(); - } - - writeln!(shim,"long rust_openssl_ssl_ctx_options_rust_to_c(uint64_t rustval) {{").unwrap(); - writeln!(shim," long cval=rustval©_MASK;").unwrap(); - for &(name,_) in options { - writeln!(shim," if (rustval&RUST_{0}) cval|={0};",name).unwrap(); - } - writeln!(shim," return cval;").unwrap(); - writeln!(shim,"}}").unwrap(); - - writeln!(shim,"uint64_t rust_openssl_ssl_ctx_options_c_to_rust(long cval) {{").unwrap(); - writeln!(shim," uint64_t rustval=cval©_MASK;").unwrap(); - for &(name,_) in options { - writeln!(shim," if (cval&{0}) rustval|=RUST_{0};",name).unwrap(); - } - writeln!(shim," return rustval;").unwrap(); - writeln!(shim,"}}").unwrap(); - - let out_dir = env::var("OUT_DIR").unwrap(); - let dest_file = PathBuf::from(&out_dir).join("ssl_ctx_options_shim.c"); - let mut f = File::create(&dest_file).unwrap(); - - f.write_all(shim.as_bytes()).unwrap(); - - dest_file -} |