git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Josh Steadmon <steadmon@google.com>
To: git@vger.kernel.org
Cc: "brian m. carlson" <sandals@crustytoothpaste.net>
Subject: [RFC PATCH v1 4/4] libgit-sys: exclude unnecessary directories in git-src
Date: Tue, 18 Mar 2025 16:24:22 -0700	[thread overview]
Message-ID: <8bd61ee5dd33d0529240b677caaff361876ec271.1742339107.git.josh@steadmon.net> (raw)
In-Reply-To: <cover.1742339107.git.josh@steadmon.net>

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                      | 14 +++++++++++++-
 contrib/libgit-sys/Cargo.toml | 12 ++++++++++++
 contrib/libgit-sys/build.rs   |  8 +++++++-
 3 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index e7d8786e4e..c75f1d0208 100644
--- a/Makefile
+++ b/Makefile
@@ -651,6 +651,7 @@ export prefix bindir sharedir sysconfdir perllibdir localedir
 CC = cc
 AR = ar
 RM = rm -f
+RMDIR = rmdir --ignore-fail-on-non-empty
 DIFF = diff
 TAR = tar
 FIND = find
@@ -3477,13 +3478,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
 
@@ -3763,7 +3764,9 @@ clean: profile-clean coverage-clean cocciclean
 	$(RM) -r .dist-tmp-dir .doc-tmp-dir
 	$(RM) $(GIT_TARNAME).tar.gz
 	$(RM) $(htmldocs).tar.gz $(manpages).tar.gz
+ifndef INCLUDE_LIBGIT_RS
 	$(MAKE) -C Documentation/ clean
+endif
 	$(RM) Documentation/GIT-EXCLUDED-PROGRAMS
 ifndef PRESERVE_LIBGIT_TARGET
 	$(RM) -r contrib/libgit-sys/target contrib/libgit-rs/target
@@ -3775,7 +3778,9 @@ ifndef NO_PERL
 	$(RM) -r perl/build/
 endif
 	$(MAKE) -C templates/ clean
+ifndef INCLUDE_LIBGIT_RS
 	$(MAKE) -C t/ clean
+endif
 ifndef NO_TCLTK
 	$(MAKE) -C gitk-git clean
 	$(MAKE) -C git-gui clean
@@ -3798,6 +3803,13 @@ ifdef MSVC
 	$(RM) compat/vcbuild/MSVC-DEFS-GEN
 endif
 
+# Handle additional cleanup needed for running `cargo package` for libgit-sys.
+ifdef INCLUDE_LIBGIT_RS
+libgit-pkg-clean: clean
+	$(RMDIR) t/helper t/unit-tests/clar t/unit-tests t
+	$(RMDIR) oss-fuzz
+endif
+
 .PHONY: all install profile-clean cocciclean clean strip
 .PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell
 .PHONY: FORCE
diff --git a/contrib/libgit-sys/Cargo.toml b/contrib/libgit-sys/Cargo.toml
index e0623022c3..4b8facccfe 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/ci",
+  "git-src/Documentation",
+  "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 16e0d66afb..0a72040726 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([
             "INCLUDE_LIBGIT_RS=YesPlease",
+            "NO_GITWEB=YesPlease",
+            "NO_PERL=YesPlease",
+            "NO_TCLTK=YesPlease",
             "contrib/libgitpub/libgitpub.a",
         ])
         .output()
@@ -40,8 +43,11 @@ pub fn main() -> std::io::Result<()> {
         .current_dir(git_root.clone())
         .args([
             "INCLUDE_LIBGIT_RS=YesPlease",
+            "NO_GITWEB=YesPlease",
+            "NO_PERL=YesPlease",
+            "NO_TCLTK=YesPlease",
             "PRESERVE_LIBGIT_TARGET=YesPlease",
-            "clean",
+            "libgit-pkg-clean",
         ])
         .output()
         .expect("`make clean` failed to run");
-- 
2.49.0.rc1.451.g8f38331e32-goog


  parent reply	other threads:[~2025-03-18 23:24 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-18 23:24 [RFC PATCH v1 0/4] Fix `cargo package` for libgit-sys Josh Steadmon
2025-03-18 23:24 ` [RFC PATCH v1 1/4] libgitpub: move to separate contrib/ directory Josh Steadmon
2025-03-18 23:24 ` [RFC PATCH v1 2/4] libgit-sys: add symlink to git repo root and clean after build Josh Steadmon
2025-03-19 22:23   ` Josh Steadmon
2025-03-20 11:10     ` Phillip Wood
2025-03-21 19:49       ` Josh Steadmon
2025-03-18 23:24 ` [RFC PATCH v1 3/4] libgit-sys: parallelize build with Cargo's jobserver Josh Steadmon
2025-03-18 23:24 ` Josh Steadmon [this message]
2025-03-21 22:14 ` [PATCH v2 0/5] Fix `cargo package` for libgit-sys Josh Steadmon
2025-03-21 22:14   ` [PATCH v2 1/5] libgitpub: move to separate contrib/ directory Josh Steadmon
2025-03-21 22:14   ` [PATCH v2 2/5] libgit-sys: add symlink to git repo root and build out of tree Josh Steadmon
2025-03-23  1:46     ` Eric Sunshine
2025-03-24 15:42       ` Junio C Hamano
2025-03-25 17:57         ` Josh Steadmon
2025-03-25 23:08           ` Junio C Hamano
2025-03-27 18:58             ` Josh Steadmon
2025-03-29 10:46               ` Junio C Hamano
2025-03-31 14:52               ` Johannes Schindelin
2025-03-21 22:14   ` [PATCH v2 3/5] libgit-sys: parallelize build with Cargo's jobserver Josh Steadmon
2025-03-21 22:14   ` [PATCH v2 4/5] libgit-sys: exclude unnecessary directories in git-src Josh Steadmon
2025-03-21 22:14   ` [PATCH v2 5/5] libgit-{sys,rs}: add license and description fields Josh Steadmon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8bd61ee5dd33d0529240b677caaff361876ec271.1742339107.git.josh@steadmon.net \
    --to=steadmon@google.com \
    --cc=git@vger.kernel.org \
    --cc=sandals@crustytoothpaste.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).