diff mbox series

[RFC,v1,3/4] libgit-sys: parallelize build with Cargo's jobserver

Message ID 905e4e4d043a0ae78bf329c074552c7feba900d2.1742339107.git.josh@steadmon.net (mailing list archive)
State Superseded
Headers show
Series Fix `cargo package` for libgit-sys | expand

Commit Message

Josh Steadmon March 18, 2025, 11:24 p.m. UTC
Cargo provides GNU Make flags that can be used to connect to its jobserver for
managing parallel builds. They are not automatically passed to any `make`
invocations, so let's add that to our build.rs script.

Signed-off-by: Josh Steadmon <steadmon@google.com>
---
 contrib/libgit-sys/build.rs | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/contrib/libgit-sys/build.rs b/contrib/libgit-sys/build.rs
index 9d586d272d..16e0d66afb 100644
--- a/contrib/libgit-sys/build.rs
+++ b/contrib/libgit-sys/build.rs
@@ -8,9 +8,11 @@  pub fn main() -> std::io::Result<()> {
     let crate_root = PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").unwrap());
     let git_root = crate_root.join("git-src");
     let dst = PathBuf::from(env::var_os("OUT_DIR").unwrap());
+    let makeflags = env::var_os("CARGO_MAKEFLAGS").unwrap();
 
     let make_output = make_cmd::gnu_make()
         .env("DEVELOPER", "1")
+        .env("MAKEFLAGS", &makeflags)
         .env_remove("PROFILE")
         .current_dir(git_root.clone())
         .args([
@@ -33,6 +35,7 @@  pub fn main() -> std::io::Result<()> {
 
     let make_output = make_cmd::gnu_make()
         .env("DEVELOPER", "1")
+        .env("MAKEFLAGS", &makeflags)
         .env_remove("PROFILE")
         .current_dir(git_root.clone())
         .args([