@@ -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
@@ -986,6 +991,8 @@ LIB_OBJS += combine-diff.o
986991LIB_OBJS += commit-graph.o
987992LIB_OBJS += commit-reach.o
988993LIB_OBJS += commit.o
994+ LIB_OBJS += common-exit.o
995+ LIB_OBJS += common-init.o
989996LIB_OBJS += compat/nonblock.o
990997LIB_OBJS += compat/obstack.o
991998LIB_OBJS += compat/terminal.o
@@ -2230,6 +2237,13 @@ ifdef FSMONITOR_OS_SETTINGS
22302237 COMPAT_OBJS += compat/fsmonitor/fsm-path-utils-$(FSMONITOR_OS_SETTINGS).o
22312238endif
22322239
2240+ ifdef INCLUDE_LIBGIT_RS
2241+ # Enable symbol hiding in contrib/libgit-rs/libgit-sys/libgitpub.a
2242+ # without making us rebuild the whole tree every time we run a Rust
2243+ # build.
2244+ BASIC_CFLAGS += -fvisibility=hidden
2245+ endif
2246+
22332247ifeq ($(TCLTK_PATH ) ,)
22342248NO_TCLTK = NoThanks
22352249endif
@@ -2755,6 +2769,7 @@ OBJECTS += $(REFTABLE_OBJS) $(REFTABLE_TEST_OBJS)
27552769OBJECTS += $(UNIT_TEST_OBJS )
27562770OBJECTS += $(CLAR_TEST_OBJS )
27572771OBJECTS += $(patsubst % ,$(UNIT_TEST_DIR ) /% .o,$(UNIT_TEST_PROGRAMS ) )
2772+ OBJECTS += contrib/libgit-rs/libgit-sys/public_symbol_export.o
27582773
27592774ifndef NO_CURL
27602775 OBJECTS += http.o http-walker.o remote-curl.o
@@ -3762,6 +3777,10 @@ clean: profile-clean coverage-clean cocciclean
37623777 $(RM ) $(htmldocs ) .tar.gz $(manpages ) .tar.gz
37633778 $(MAKE ) -C Documentation/ clean
37643779 $(RM ) Documentation/GIT-EXCLUDED-PROGRAMS
3780+ $(RM ) -r contrib/libgit-rs/target contrib/libgit-rs/libgit-sys/target
3781+ $(RM ) -r contrib/libgit-rs/libgit-sys/partial_symbol_export.o
3782+ $(RM ) -r contrib/libgit-rs/libgit-sys/hidden_symbol_export.o
3783+ $(RM ) -r contrib/libgit-rs/libgit-sys/libgitpub.a
37653784ifndef NO_PERL
37663785 $(RM) -r perl/build/
37673786endif
@@ -3923,3 +3942,28 @@ $(CLAR_TEST_PROG): $(UNIT_TEST_DIR)/clar.suite $(CLAR_TEST_OBJS) $(GITLIBS) GIT-
39233942build-unit-tests : $(UNIT_TEST_PROGS ) $(CLAR_TEST_PROG )
39243943unit-tests : $(UNIT_TEST_PROGS ) $(CLAR_TEST_PROG ) t/helper/test-tool$X
39253944 $(MAKE ) -C t/ unit-tests
3945+
3946+ .PHONY : libgitrs-sys
3947+ libgitrs-sys :
3948+ $(QUIET ) (\
3949+ cd contrib/libgit-rs/libgit-sys && \
3950+ cargo build \
3951+ )
3952+ .PHONY : libgitrs
3953+ libgitrs :
3954+ $(QUIET ) (\
3955+ cd contrib/libgit-rs && \
3956+ cargo build \
3957+ )
3958+ ifdef INCLUDE_LIBGIT_RS
3959+ all :: libgitrs
3960+ endif
3961+
3962+ 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
3963+ $(LD ) -r $^ -o $@
3964+
3965+ contrib/libgit-rs/libgit-sys/hidden_symbol_export.o : contrib/libgit-rs/libgit-sys/partial_symbol_export.o
3966+ $(OBJCOPY ) --localize-hidden $^ $@
3967+
3968+ contrib/libgit-rs/libgit-sys/libgitpub.a : contrib/libgit-rs/libgit-sys/hidden_symbol_export.o
3969+ $(AR ) $(ARFLAGS ) $@ $^
0 commit comments