From 71051a384b98fc55eb494dc37f2eea89d0e6c106 Mon Sep 17 00:00:00 2001 From: Lucas Schwiderski Date: Wed, 2 Jul 2025 16:18:25 +0200 Subject: [PATCH] luajit2-sys: Compile in parallel --- Cargo.toml | 2 +- lib/luajit2-sys/build.rs | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 15e26c6..608bcda 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ bincode = "2.0.0" bindgen = "0.70.1" bitflags = "2.5.0" byteorder = "1.4.3" -cc = "1.2.27" +cc = { version = "1.2.27", features = ["parallel"] } clap = { version = "4.0.15", features = ["color", "derive", "std", "cargo", "string", "unicode"] } cli-table = { version = "0.5.0", default-features = false, features = ["derive"] } color-eyre = { path = "lib/color-eyre" } diff --git a/lib/luajit2-sys/build.rs b/lib/luajit2-sys/build.rs index fc564db..ea6026b 100644 --- a/lib/luajit2-sys/build.rs +++ b/lib/luajit2-sys/build.rs @@ -82,6 +82,11 @@ const LUAJIT_SRC: [&str; 65] = [ fn build_gcc(src_dir: &str) { let mut buildcmd = Command::new("make"); + if let Ok(flags) = env::var("CARGO_MAKEFLAGS") { + buildcmd.env("MAKEFLAGS", flags); + } else { + buildcmd.arg("-j8"); + } buildcmd.current_dir(src_dir); buildcmd.stderr(Stdio::inherit()); buildcmd.arg("--no-silent"); @@ -102,14 +107,10 @@ fn build_gcc(src_dir: &str) { let mut child = buildcmd.spawn().expect("failed to run make"); - if !child + child .wait() .map(|status| status.success()) - .map_err(|_| false) - .unwrap_or(false) - { - panic!("Failed to build luajit"); - } + .expect("Failed to build LuaJIT"); } fn build_msvc(src_dir: &str, out_dir: &str) {