@@ -416,6 +416,9 @@ include shared.mak
416416# Define LINK_FUZZ_PROGRAMS if you want `make all` to also build the fuzz test
417417# programs in oss-fuzz/.
418418#
419+ # Define INCLUDE_LIBGIT_RS if you want `make all` and `make test` to build and
420+ # test the Rust crates in contrib/libgit-rs/ and contrib/libgit-rs/libgit-sys/.
421+ #
419422# === Optional library: libintl ===
420423#
421424# Define NO_GETTEXT if you don't want Git output to be translated.
@@ -661,6 +664,8 @@ CURL_CONFIG = curl-config
661664GCOV = gcov
662665STRIP = strip
663666SPATCH = spatch
667+ LD = ld
668+ OBJCOPY = objcopy
664669
665670export TCL_PATH TCLTK_PATH
666671
@@ -987,6 +992,8 @@ LIB_OBJS += combine-diff.o
987992LIB_OBJS += commit-graph.o
988993LIB_OBJS += commit-reach.o
989994LIB_OBJS += commit.o
995+ LIB_OBJS += common-exit.o
996+ LIB_OBJS += common-init.o
990997LIB_OBJS += compat/nonblock.o
991998LIB_OBJS += compat/obstack.o
992999LIB_OBJS += compat/terminal.o
@@ -2232,6 +2239,13 @@ ifdef FSMONITOR_OS_SETTINGS
22322239 COMPAT_OBJS += compat/fsmonitor/fsm-path-utils-$(FSMONITOR_OS_SETTINGS).o
22332240endif
22342241
2242+ ifdef INCLUDE_LIBGIT_RS
2243+ # Enable symbol hiding in contrib/libgit-rs/libgit-sys/libgitpub.a
2244+ # without making us rebuild the whole tree every time we run a Rust
2245+ # build.
2246+ BASIC_CFLAGS += -fvisibility=hidden
2247+ endif
2248+
22352249ifeq ($(TCLTK_PATH ) ,)
22362250NO_TCLTK = NoThanks
22372251endif
@@ -2760,6 +2774,7 @@ OBJECTS += $(REFTABLE_OBJS) $(REFTABLE_TEST_OBJS)
27602774OBJECTS += $(UNIT_TEST_OBJS )
27612775OBJECTS += $(CLAR_TEST_OBJS )
27622776OBJECTS += $(patsubst % ,$(UNIT_TEST_DIR ) /% .o,$(UNIT_TEST_PROGRAMS ) )
2777+ OBJECTS += contrib/libgit-rs/libgit-sys/public_symbol_export.o
27632778
27642779ifndef NO_CURL
27652780 OBJECTS += http.o http-walker.o remote-curl.o
@@ -3767,6 +3782,10 @@ clean: profile-clean coverage-clean cocciclean
37673782 $(RM ) $(htmldocs ) .tar.gz $(manpages ) .tar.gz
37683783 $(MAKE ) -C Documentation/ clean
37693784 $(RM ) Documentation/GIT-EXCLUDED-PROGRAMS
3785+ $(RM ) -r contrib/libgit-rs/target contrib/libgit-rs/libgit-sys/target
3786+ $(RM ) -r contrib/libgit-rs/libgit-sys/partial_symbol_export.o
3787+ $(RM ) -r contrib/libgit-rs/libgit-sys/hidden_symbol_export.o
3788+ $(RM ) -r contrib/libgit-rs/libgit-sys/libgitpub.a
37703789ifndef NO_PERL
37713790 $(RM) -r perl/build/
37723791endif
@@ -3928,3 +3947,28 @@ $(CLAR_TEST_PROG): $(UNIT_TEST_DIR)/clar.suite $(CLAR_TEST_OBJS) $(GITLIBS) GIT-
39283947build-unit-tests : $(UNIT_TEST_PROGS ) $(CLAR_TEST_PROG )
39293948unit-tests : $(UNIT_TEST_PROGS ) $(CLAR_TEST_PROG ) t/helper/test-tool$X
39303949 $(MAKE ) -C t/ unit-tests
3950+
3951+ .PHONY : libgitrs-sys
3952+ libgitrs-sys :
3953+ $(QUIET ) (\
3954+ cd contrib/libgit-rs/libgit-sys && \
3955+ cargo build \
3956+ )
3957+ .PHONY : libgitrs
3958+ libgitrs :
3959+ $(QUIET ) (\
3960+ cd contrib/libgit-rs && \
3961+ cargo build \
3962+ )
3963+ ifdef INCLUDE_LIBGIT_RS
3964+ all :: libgitrs
3965+ endif
3966+
3967+ contrib/libgit-rs/libgit-sys/partial_symbol_export.o : contrib/libgit-rs/libgit-sys/public_symbol_export.o libgit.a reftable/libreftable.a xdiff/lib.a
3968+ $(LD ) -r $^ -o $@
3969+
3970+ contrib/libgit-rs/libgit-sys/hidden_symbol_export.o : contrib/libgit-rs/libgit-sys/partial_symbol_export.o
3971+ $(OBJCOPY ) --localize-hidden $^ $@
3972+
3973+ contrib/libgit-rs/libgit-sys/libgitpub.a : contrib/libgit-rs/libgit-sys/hidden_symbol_export.o
3974+ $(AR ) $(ARFLAGS ) $@ $^
0 commit comments