diff mbox series

[v2,4/5] libgit-sys: exclude unnecessary directories in git-src

Message ID 390695ac1f929727478e6c8c26f5c69b9a6c068a.1742594960.git.steadmon@google.com (mailing list archive)
State New
Headers show
Series Fix `cargo package` for libgit-sys | expand

Commit Message

Josh Steadmon March 21, 2025, 10:14 p.m. UTC
We can avoid copying tens of megabytes of unnecessary source files by excluding
a few directories which are not needed to compile libgitpub.a. This helps us
stay below crates.io's 10 MB size limit.

Signed-off-by: Josh Steadmon <steadmon@google.com>
---
 Makefile                      |  2 +-
 contrib/libgit-sys/Cargo.toml | 12 ++++++++++++
 contrib/libgit-sys/build.rs   |  3 +++
 3 files changed, 16 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/Makefile b/Makefile
index 91677448ba..1574fc76e2 100644
--- a/Makefile
+++ b/Makefile
@@ -3500,13 +3500,13 @@  coccicheck-pending: $(COCCICHECK_PATCHES_PENDING_INTREE)
 
 # "Sub"-Makefiles, not really because they can't be run stand-alone,
 # only there to contain directory-specific rules and variables
+ifndef NO_GITWEB
 ## gitweb/Makefile inclusion:
 MAK_DIR_GITWEB = gitweb/
 include gitweb/Makefile
 
 .PHONY: gitweb
 gitweb: $(MAK_DIR_GITWEB_ALL)
-ifndef NO_GITWEB
 all:: gitweb
 endif
 
diff --git a/contrib/libgit-sys/Cargo.toml b/contrib/libgit-sys/Cargo.toml
index e0623022c3..1c1efb6211 100644
--- a/contrib/libgit-sys/Cargo.toml
+++ b/contrib/libgit-sys/Cargo.toml
@@ -7,6 +7,18 @@  links = "gitpub"
 rust-version = "1.63" # TODO: Once we hit 1.84 or newer, we may want to remove Cargo.lock from
                       # version control. See https://lore.kernel.org/git/Z47jgK-oMjFRSslr@tapette.crustytoothpaste.net/
 description = "Native bindings to a portion of libgit"
+exclude = [
+  "git-src/.github",
+  "git-src/Documentation",
+  "git-src/ci",
+  "git-src/git-gui",
+  "git-src/gitk-git",
+  "git-src/gitweb",
+  "git-src/oss-fuzz",
+  "git-src/perl",
+  "git-src/po",
+  "git-src/t"
+]
 
 [lib]
 path = "src/lib.rs"
diff --git a/contrib/libgit-sys/build.rs b/contrib/libgit-sys/build.rs
index 1237c9a37f..7e1244fcd5 100644
--- a/contrib/libgit-sys/build.rs
+++ b/contrib/libgit-sys/build.rs
@@ -17,6 +17,9 @@  pub fn main() -> std::io::Result<()> {
         .current_dir(git_root.clone())
         .args([
             &format!("CARGO_OUT_DIR={}", dst.display()),
+            "NO_GITWEB=YesPlease",
+            "NO_PERL=YesPlease",
+            "NO_TCLTK=YesPlease",
             "INCLUDE_LIBGIT_RS=YesPlease",
             &format!("{}/contrib/libgitpub/libgitpub.a", dst.display()),
         ])