@@ -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.
@@ -664,6 +667,8 @@ CURL_CONFIG = curl-config
664667GCOV = gcov
665668STRIP = strip
666669SPATCH = spatch
670+ LD = ld
671+ OBJCOPY = objcopy
667672
668673export TCL_PATH TCLTK_PATH
669674
@@ -990,6 +995,8 @@ LIB_OBJS += combine-diff.o
990995LIB_OBJS += commit-graph.o
991996LIB_OBJS += commit-reach.o
992997LIB_OBJS += commit.o
998+ LIB_OBJS += common-exit.o
999+ LIB_OBJS += common-init.o
9931000LIB_OBJS += compat/nonblock.o
9941001LIB_OBJS += compat/obstack.o
9951002LIB_OBJS += compat/terminal.o
@@ -2235,6 +2242,13 @@ ifdef FSMONITOR_OS_SETTINGS
22352242 COMPAT_OBJS += compat/fsmonitor/fsm-path-utils-$(FSMONITOR_OS_SETTINGS).o
22362243endif
22372244
2245+ ifdef INCLUDE_LIBGIT_RS
2246+ # Enable symbol hiding in contrib/libgit-rs/libgit-sys/libgitpub.a
2247+ # without making us rebuild the whole tree every time we run a Rust
2248+ # build.
2249+ BASIC_CFLAGS += -fvisibility=hidden
2250+ endif
2251+
22382252ifeq ($(TCLTK_PATH ) ,)
22392253NO_TCLTK = NoThanks
22402254endif
@@ -2732,6 +2746,7 @@ OBJECTS += $(REFTABLE_OBJS) $(REFTABLE_TEST_OBJS)
27322746OBJECTS += $(UNIT_TEST_OBJS )
27332747OBJECTS += $(CLAR_TEST_OBJS )
27342748OBJECTS += $(patsubst % ,$(UNIT_TEST_DIR ) /% .o,$(UNIT_TEST_PROGRAMS ) )
2749+ OBJECTS += contrib/libgit-rs/libgit-sys/public_symbol_export.o
27352750
27362751ifndef NO_CURL
27372752 OBJECTS += http.o http-walker.o remote-curl.o
@@ -3726,6 +3741,10 @@ clean: profile-clean coverage-clean cocciclean
37263741 $(RM ) $(htmldocs ) .tar.gz $(manpages ) .tar.gz
37273742 $(MAKE ) -C Documentation/ clean
37283743 $(RM ) Documentation/GIT-EXCLUDED-PROGRAMS
3744+ $(RM ) -r contrib/libgit-rs/target contrib/libgit-rs/libgit-sys/target
3745+ $(RM ) -r contrib/libgit-rs/libgit-sys/partial_symbol_export.o
3746+ $(RM ) -r contrib/libgit-rs/libgit-sys/hidden_symbol_export.o
3747+ $(RM ) -r contrib/libgit-rs/libgit-sys/libgitpub.a
37293748ifndef NO_PERL
37303749 $(RM) -r perl/build/
37313750endif
@@ -3887,3 +3906,28 @@ $(CLAR_TEST_PROG): $(UNIT_TEST_DIR)/clar.suite $(CLAR_TEST_OBJS) $(GITLIBS) GIT-
38873906build-unit-tests : $(UNIT_TEST_PROGS ) $(CLAR_TEST_PROG )
38883907unit-tests : $(UNIT_TEST_PROGS ) $(CLAR_TEST_PROG ) t/helper/test-tool$X
38893908 $(MAKE ) -C t/ unit-tests
3909+
3910+ .PHONY : libgitrs-sys
3911+ libgitrs-sys :
3912+ $(QUIET ) (\
3913+ cd contrib/libgit-rs/libgit-sys && \
3914+ cargo build \
3915+ )
3916+ .PHONY : libgitrs
3917+ libgitrs :
3918+ $(QUIET ) (\
3919+ cd contrib/libgit-rs && \
3920+ cargo build \
3921+ )
3922+ ifdef INCLUDE_LIBGIT_RS
3923+ all :: libgitrs
3924+ endif
3925+
3926+ 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
3927+ $(LD ) -r $^ -o $@
3928+
3929+ contrib/libgit-rs/libgit-sys/hidden_symbol_export.o : contrib/libgit-rs/libgit-sys/partial_symbol_export.o
3930+ $(OBJCOPY ) --localize-hidden $^ $@
3931+
3932+ contrib/libgit-rs/libgit-sys/libgitpub.a : contrib/libgit-rs/libgit-sys/hidden_symbol_export.o
3933+ $(AR ) $(ARFLAGS ) $@ $^
0 commit comments