extern crate cc; extern crate glob; use std::env; use std::path::{Path, PathBuf}; fn main() { let internals_include_path = &std::env::var("DEP_PQCRYPTO_INTERNALS_WASI_INCLUDEPATH").unwrap(); let common_dir = Path::new("pqclean/common"); #[allow(unused_variables)] let avx2_enabled = env::var("CARGO_FEATURE_AVX2").is_ok(); #[allow(unused_variables)] let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap(); #[allow(unused_variables)] let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap(); #[allow(unused_variables)] let is_windows = target_os == "windows"; #[allow(unused_variables)] let is_macos = target_os == "macos"; { let mut builder = cc::Build::new(); let target_dir: PathBuf = ["pqclean", "crypto_sign", "rainbowI-circumzenithal", "clean"] .iter() .collect(); let scheme_files = glob::glob(target_dir.join("*.c").to_str().unwrap()).unwrap(); if target_arch == "wasm32" { let wasi_sdk_path = &std::env::var("WASI_SDK_DIR").expect("missing environment variable: WASI_SDK_DIR"); builder.flag(format!("--sysroot={}", wasi_sdk_path).as_str()); } builder .include(internals_include_path) .include(&common_dir) .include(target_dir) .files( scheme_files .into_iter() .map(|p| p.unwrap().to_string_lossy().into_owned()), ); builder.compile("rainbowI-circumzenithal_clean"); } { let mut builder = cc::Build::new(); let target_dir: PathBuf = ["pqclean", "crypto_sign", "rainbowI-classic", "clean"] .iter() .collect(); let scheme_files = glob::glob(target_dir.join("*.c").to_str().unwrap()).unwrap(); if target_arch == "wasm32" { let wasi_sdk_path = &std::env::var("WASI_SDK_DIR").expect("missing environment variable: WASI_SDK_DIR"); builder.flag(format!("--sysroot={}", wasi_sdk_path).as_str()); } builder .include(internals_include_path) .include(&common_dir) .include(target_dir) .files( scheme_files .into_iter() .map(|p| p.unwrap().to_string_lossy().into_owned()), ); builder.compile("rainbowI-classic_clean"); } { let mut builder = cc::Build::new(); let target_dir: PathBuf = ["pqclean", "crypto_sign", "rainbowI-compressed", "clean"] .iter() .collect(); let scheme_files = glob::glob(target_dir.join("*.c").to_str().unwrap()).unwrap(); if target_arch == "wasm32" { let wasi_sdk_path = &std::env::var("WASI_SDK_DIR").expect("missing environment variable: WASI_SDK_DIR"); builder.flag(format!("--sysroot={}", wasi_sdk_path).as_str()); } builder .include(internals_include_path) .include(&common_dir) .include(target_dir) .files( scheme_files .into_iter() .map(|p| p.unwrap().to_string_lossy().into_owned()), ); builder.compile("rainbowI-compressed_clean"); } { let mut builder = cc::Build::new(); let target_dir: PathBuf = [ "pqclean", "crypto_sign", "rainbowIII-circumzenithal", "clean", ] .iter() .collect(); let scheme_files = glob::glob(target_dir.join("*.c").to_str().unwrap()).unwrap(); if target_arch == "wasm32" { let wasi_sdk_path = &std::env::var("WASI_SDK_DIR").expect("missing environment variable: WASI_SDK_DIR"); builder.flag(format!("--sysroot={}", wasi_sdk_path).as_str()); } builder .include(internals_include_path) .include(&common_dir) .include(target_dir) .files( scheme_files .into_iter() .map(|p| p.unwrap().to_string_lossy().into_owned()), ); builder.compile("rainbowIII-circumzenithal_clean"); } { let mut builder = cc::Build::new(); let target_dir: PathBuf = ["pqclean", "crypto_sign", "rainbowIII-classic", "clean"] .iter() .collect(); let scheme_files = glob::glob(target_dir.join("*.c").to_str().unwrap()).unwrap(); if target_arch == "wasm32" { let wasi_sdk_path = &std::env::var("WASI_SDK_DIR").expect("missing environment variable: WASI_SDK_DIR"); builder.flag(format!("--sysroot={}", wasi_sdk_path).as_str()); } builder .include(internals_include_path) .include(&common_dir) .include(target_dir) .files( scheme_files .into_iter() .map(|p| p.unwrap().to_string_lossy().into_owned()), ); builder.compile("rainbowIII-classic_clean"); } { let mut builder = cc::Build::new(); let target_dir: PathBuf = ["pqclean", "crypto_sign", "rainbowIII-compressed", "clean"] .iter() .collect(); let scheme_files = glob::glob(target_dir.join("*.c").to_str().unwrap()).unwrap(); if target_arch == "wasm32" { let wasi_sdk_path = &std::env::var("WASI_SDK_DIR").expect("missing environment variable: WASI_SDK_DIR"); builder.flag(format!("--sysroot={}", wasi_sdk_path).as_str()); } builder .include(internals_include_path) .include(&common_dir) .include(target_dir) .files( scheme_files .into_iter() .map(|p| p.unwrap().to_string_lossy().into_owned()), ); builder.compile("rainbowIII-compressed_clean"); } { let mut builder = cc::Build::new(); let target_dir: PathBuf = ["pqclean", "crypto_sign", "rainbowV-circumzenithal", "clean"] .iter() .collect(); let scheme_files = glob::glob(target_dir.join("*.c").to_str().unwrap()).unwrap(); if target_arch == "wasm32" { let wasi_sdk_path = &std::env::var("WASI_SDK_DIR").expect("missing environment variable: WASI_SDK_DIR"); builder.flag(format!("--sysroot={}", wasi_sdk_path).as_str()); } builder .include(internals_include_path) .include(&common_dir) .include(target_dir) .files( scheme_files .into_iter() .map(|p| p.unwrap().to_string_lossy().into_owned()), ); builder.compile("rainbowV-circumzenithal_clean"); } { let mut builder = cc::Build::new(); let target_dir: PathBuf = ["pqclean", "crypto_sign", "rainbowV-classic", "clean"] .iter() .collect(); let scheme_files = glob::glob(target_dir.join("*.c").to_str().unwrap()).unwrap(); if target_arch == "wasm32" { let wasi_sdk_path = &std::env::var("WASI_SDK_DIR").expect("missing environment variable: WASI_SDK_DIR"); builder.flag(format!("--sysroot={}", wasi_sdk_path).as_str()); } builder .include(internals_include_path) .include(&common_dir) .include(target_dir) .files( scheme_files .into_iter() .map(|p| p.unwrap().to_string_lossy().into_owned()), ); builder.compile("rainbowV-classic_clean"); } { let mut builder = cc::Build::new(); let target_dir: PathBuf = ["pqclean", "crypto_sign", "rainbowV-compressed", "clean"] .iter() .collect(); let scheme_files = glob::glob(target_dir.join("*.c").to_str().unwrap()).unwrap(); if target_arch == "wasm32" { let wasi_sdk_path = &std::env::var("WASI_SDK_DIR").expect("missing environment variable: WASI_SDK_DIR"); builder.flag(format!("--sysroot={}", wasi_sdk_path).as_str()); } builder .include(internals_include_path) .include(&common_dir) .include(target_dir) .files( scheme_files .into_iter() .map(|p| p.unwrap().to_string_lossy().into_owned()), ); builder.compile("rainbowV-compressed_clean"); } }