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@xxxxxxxxxx> --- 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@xxxxxxxxxxxxxxxxxxxxxxxxxxxx/ 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