Repository: randombit/botan-rs (language: rust)

Issue:
Single threaded botan-src build
If I enable the vendored feature, the build takes a long time because it's single threaded.

I'm not sure how to enable parallel make. `make -j $NUM_JOBS` [is not the solution](https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-sets-for-build-scripts) but I'm not sure how one can do jobserver passthrough.


Discussion / hints:
cc #15 @breard-r 
Yeah it would be nice to fix this. Maybe the short term approach is just `-j $NUM_JOBS` even if not optimal.

Fix patch:
diff --git a/botan-src/src/lib.rs b/botan-src/src/lib.rs
index 881668e..8c1e4d5 100644
--- a/botan-src/src/lib.rs
+++ b/botan-src/src/lib.rs
@@ -108,21 +108,35 @@ fn configure(build_dir: &str) {
     add_env_arg!(configure, "BOTAN_CONFIGURE_LIBDIR", "--libdir", false);
     add_env_arg!(configure, "BOTAN_CONFIGURE_MANDIR", "--mandir", false);
     add_env_arg!(configure, "BOTAN_CONFIGURE_INCLUDEDIR", "--includedir", false);
-    configure
+    let status = configure
         .spawn()
         .expect(BUILD_ERROR_MSG)
         .wait()
         .expect(BUILD_ERROR_MSG);
+    if !status.success() {
+        panic!("configure terminated unsuccessfully");
+    }
 }
 
 fn make(build_dir: &str) {
-    Command::new("make")
-        .arg("-f")
+    let mut cmd = Command::new("make");
+    // Set MAKEFLAGS to the content of CARGO_MAKEFLAGS
+    // to give jobserver (parallel builds) support to the
+    // spawned sub-make.
+    if let Ok(val) = env::var("CARGO_MAKEFLAGS") {
+        cmd.env("MAKEFLAGS", val);
+    } else {
+        eprintln!("Can't set MAKEFLAGS as CARGO_MAKEFLAGS couldn't be read");
+    }
+    let status = cmd.arg("-f")
         .arg(format!("{}/Makefile", build_dir))
         .spawn()
         .expect(BUILD_ERROR_MSG)
         .wait()
         .expect(BUILD_ERROR_MSG);
+    if !status.success() {
+        panic!("make terminated unsuccessfully");
+    }
 }
 
 pub fn build() -> (String, String) {


Test patch: