Skip to content

Commit

Permalink
fixup! Make paths more resilient for Windows (rustpq#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomwiggers committed May 25, 2020
1 parent 7632dd9 commit e6c7a21
Show file tree
Hide file tree
Showing 16 changed files with 1,153 additions and 961 deletions.
296 changes: 133 additions & 163 deletions pqcrypto-classicmceliece/build.rs

Large diffs are not rendered by default.

66 changes: 30 additions & 36 deletions pqcrypto-dilithium/build.rs
@@ -1,10 +1,10 @@
extern crate cc;
extern crate glob;

use std::path::Path;
use std::path::PathBuf;

fn main() {
let common_dir = Path::new("pqclean").join("common");
let common_dir: PathBuf = ["pqclean", "common"].iter().collect();
let common_files = vec![
common_dir.join("fips202.c"),
common_dir.join("aes.c"),
Expand All @@ -15,20 +15,19 @@ fn main() {

cc::Build::new()
.flag("-std=c99")
.include(common_dir)
.include(&common_dir)
.files(common_files.into_iter())
.compile("pqclean_common");

{
let mut builder = cc::Build::new();
let target_dir = Path::new("pqclean")
.join("crypto_sign")
.join("dilithium2")
.join("clean");
let target_dir: PathBuf = ["pqclean", "crypto_sign", "dilithium2", "clean"]
.iter()
.collect();
let scheme_files = glob::glob(target_dir.join("*.c").to_str().unwrap()).unwrap();
builder
.flag("-std=c99")
.include(common_dir)
.include(&common_dir)
.include(target_dir)
.files(
scheme_files
Expand All @@ -40,10 +39,9 @@ fn main() {

#[cfg(all(not(disable_avx2), not(target_os = "windows"), target_arch = "x86_64"))]
{
let target_dir = Path::new("pqclean")
.join("crypto_sign")
.join("dilithium2")
.join("avx2");
let target_dir: PathBuf = ["pqclean", "crypto_sign", "dilithium2", "avx2"]
.iter()
.collect();
let scheme_files = glob::glob(target_dir.join("*.[csS]").to_str().unwrap()).unwrap();
cc::Build::new()
.flag("-std=c99")
Expand All @@ -52,7 +50,7 @@ fn main() {
.flag("-mbmi")
.flag("-maes")
.flag("-mpopcnt")
.include(common_dir)
.include(&common_dir)
.include(target_dir)
.files(
scheme_files
Expand All @@ -65,22 +63,21 @@ fn main() {
.flag("-std=c99")
.flag("-mavx2")
.file(
common_dir
&common_dir
.join("keccak4x")
.join("KeccakP-1600-times4-SIMD256.c"),
)
.compile("keccak4x");
}
{
let mut builder = cc::Build::new();
let target_dir = Path::new("pqclean")
.join("crypto_sign")
.join("dilithium3")
.join("clean");
let target_dir: PathBuf = ["pqclean", "crypto_sign", "dilithium3", "clean"]
.iter()
.collect();
let scheme_files = glob::glob(target_dir.join("*.c").to_str().unwrap()).unwrap();
builder
.flag("-std=c99")
.include(common_dir)
.include(&common_dir)
.include(target_dir)
.files(
scheme_files
Expand All @@ -92,10 +89,9 @@ fn main() {

#[cfg(all(not(disable_avx2), not(target_os = "windows"), target_arch = "x86_64"))]
{
let target_dir = Path::new("pqclean")
.join("crypto_sign")
.join("dilithium3")
.join("avx2");
let target_dir: PathBuf = ["pqclean", "crypto_sign", "dilithium3", "avx2"]
.iter()
.collect();
let scheme_files = glob::glob(target_dir.join("*.[csS]").to_str().unwrap()).unwrap();
cc::Build::new()
.flag("-std=c99")
Expand All @@ -104,7 +100,7 @@ fn main() {
.flag("-mbmi")
.flag("-maes")
.flag("-mpopcnt")
.include(common_dir)
.include(&common_dir)
.include(target_dir)
.files(
scheme_files
Expand All @@ -117,22 +113,21 @@ fn main() {
.flag("-std=c99")
.flag("-mavx2")
.file(
common_dir
&common_dir
.join("keccak4x")
.join("KeccakP-1600-times4-SIMD256.c"),
)
.compile("keccak4x");
}
{
let mut builder = cc::Build::new();
let target_dir = Path::new("pqclean")
.join("crypto_sign")
.join("dilithium4")
.join("clean");
let target_dir: PathBuf = ["pqclean", "crypto_sign", "dilithium4", "clean"]
.iter()
.collect();
let scheme_files = glob::glob(target_dir.join("*.c").to_str().unwrap()).unwrap();
builder
.flag("-std=c99")
.include(common_dir)
.include(&common_dir)
.include(target_dir)
.files(
scheme_files
Expand All @@ -144,10 +139,9 @@ fn main() {

#[cfg(all(not(disable_avx2), not(target_os = "windows"), target_arch = "x86_64"))]
{
let target_dir = Path::new("pqclean")
.join("crypto_sign")
.join("dilithium4")
.join("avx2");
let target_dir: PathBuf = ["pqclean", "crypto_sign", "dilithium4", "avx2"]
.iter()
.collect();
let scheme_files = glob::glob(target_dir.join("*.[csS]").to_str().unwrap()).unwrap();
cc::Build::new()
.flag("-std=c99")
Expand All @@ -156,7 +150,7 @@ fn main() {
.flag("-mbmi")
.flag("-maes")
.flag("-mpopcnt")
.include(common_dir)
.include(&common_dir)
.include(target_dir)
.files(
scheme_files
Expand All @@ -169,7 +163,7 @@ fn main() {
.flag("-std=c99")
.flag("-mavx2")
.file(
common_dir
&common_dir
.join("keccak4x")
.join("KeccakP-1600-times4-SIMD256.c"),
)
Expand Down
24 changes: 11 additions & 13 deletions pqcrypto-falcon/build.rs
@@ -1,10 +1,10 @@
extern crate cc;
extern crate glob;

use std::path::Path;
use std::path::PathBuf;

fn main() {
let common_dir = Path::new("pqclean").join("common");
let common_dir: PathBuf = ["pqclean", "common"].iter().collect();
let common_files = vec![
common_dir.join("fips202.c"),
common_dir.join("aes.c"),
Expand All @@ -15,20 +15,19 @@ fn main() {

cc::Build::new()
.flag("-std=c99")
.include(common_dir)
.include(&common_dir)
.files(common_files.into_iter())
.compile("pqclean_common");

{
let mut builder = cc::Build::new();
let target_dir = Path::new("pqclean")
.join("crypto_sign")
.join("falcon-512")
.join("clean");
let target_dir: PathBuf = ["pqclean", "crypto_sign", "falcon-512", "clean"]
.iter()
.collect();
let scheme_files = glob::glob(target_dir.join("*.c").to_str().unwrap()).unwrap();
builder
.flag("-std=c99")
.include(common_dir)
.include(&common_dir)
.include(target_dir)
.files(
scheme_files
Expand All @@ -40,14 +39,13 @@ fn main() {

{
let mut builder = cc::Build::new();
let target_dir = Path::new("pqclean")
.join("crypto_sign")
.join("falcon-1024")
.join("clean");
let target_dir: PathBuf = ["pqclean", "crypto_sign", "falcon-1024", "clean"]
.iter()
.collect();
let scheme_files = glob::glob(target_dir.join("*.c").to_str().unwrap()).unwrap();
builder
.flag("-std=c99")
.include(common_dir)
.include(&common_dir)
.include(target_dir)
.files(
scheme_files
Expand Down

0 comments on commit e6c7a21

Please sign in to comment.