@@ -417,6 +417,9 @@ include shared.mak
417417# Define LINK_FUZZ_PROGRAMS if you want `make all` to also build the fuzz test
418418# programs in oss-fuzz/.
419419#
420+ # Define INCLUDE_LIBGIT_RS if you want `make all` and `make test` to build and
421+ # test the Rust crates in contrib/libgit-sys and contrib/libgit-rs.
422+ #
420423# === Optional library: libintl ===
421424#
422425# Define NO_GETTEXT if you don't want Git output to be translated.
@@ -658,6 +661,8 @@ CURL_CONFIG = curl-config
658661GCOV = gcov
659662STRIP = strip
660663SPATCH = spatch
664+ LD = ld
665+ OBJCOPY = objcopy
661666
662667export TCL_PATH TCLTK_PATH
663668
@@ -984,6 +989,8 @@ LIB_OBJS += combine-diff.o
984989LIB_OBJS += commit-graph.o
985990LIB_OBJS += commit-reach.o
986991LIB_OBJS += commit.o
992+ LIB_OBJS += common-exit.o
993+ LIB_OBJS += common-init.o
987994LIB_OBJS += compat/nonblock.o
988995LIB_OBJS += compat/obstack.o
989996LIB_OBJS += compat/terminal.o
@@ -2254,6 +2261,12 @@ ifdef WITH_BREAKING_CHANGES
22542261 BASIC_CFLAGS += -DWITH_BREAKING_CHANGES
22552262endif
22562263
2264+ ifdef INCLUDE_LIBGIT_RS
2265+ # Enable symbol hiding in contrib/libgit-sys/libgitpub.a without making
2266+ # us rebuild the whole tree every time we run a Rust build.
2267+ BASIC_CFLAGS += -fvisibility=hidden
2268+ endif
2269+
22572270ifeq ($(TCLTK_PATH ) ,)
22582271NO_TCLTK = NoThanks
22592272endif
@@ -2750,6 +2763,10 @@ OBJECTS += $(UNIT_TEST_OBJS)
27502763OBJECTS += $(CLAR_TEST_OBJS )
27512764OBJECTS += $(patsubst % ,$(UNIT_TEST_DIR ) /% .o,$(UNIT_TEST_PROGRAMS ) )
27522765
2766+ ifdef INCLUDE_LIBGIT_RS
2767+ OBJECTS += contrib/libgit-sys/public_symbol_export.o
2768+ endif
2769+
27532770ifndef NO_CURL
27542771 OBJECTS += http.o http-walker.o remote-curl.o
27552772endif
@@ -3745,6 +3762,10 @@ clean: profile-clean coverage-clean cocciclean
37453762 $(RM ) $(htmldocs ) .tar.gz $(manpages ) .tar.gz
37463763 $(MAKE ) -C Documentation/ clean
37473764 $(RM ) Documentation/GIT-EXCLUDED-PROGRAMS
3765+ $(RM ) -r contrib/libgit-sys/target contrib/libgit-rs/target
3766+ $(RM ) contrib/libgit-sys/partial_symbol_export.o
3767+ $(RM ) contrib/libgit-sys/hidden_symbol_export.o
3768+ $(RM ) contrib/libgit-sys/libgitpub.a
37483769ifndef NO_PERL
37493770 $(RM) -r perl/build/
37503771endif
@@ -3906,3 +3927,27 @@ $(CLAR_TEST_PROG): $(UNIT_TEST_DIR)/clar.suite $(CLAR_TEST_OBJS) $(GITLIBS) GIT-
39063927build-unit-tests : $(UNIT_TEST_PROGS ) $(CLAR_TEST_PROG )
39073928unit-tests : $(UNIT_TEST_PROGS ) $(CLAR_TEST_PROG ) t/helper/test-tool$X
39083929 $(MAKE ) -C t/ unit-tests
3930+
3931+ .PHONY : libgit-sys libgit-rs
3932+ libgit-sys :
3933+ $(QUIET ) (\
3934+ cd contrib/libgit-sys && \
3935+ cargo build \
3936+ )
3937+ libgit-rs :
3938+ $(QUIET ) (\
3939+ cd contrib/libgit-rs && \
3940+ cargo build \
3941+ )
3942+ ifdef INCLUDE_LIBGIT_RS
3943+ all :: libgit-sys libgit-rs
3944+ endif
3945+
3946+ contrib/libgit-sys/partial_symbol_export.o : contrib/libgit-sys/public_symbol_export.o libgit.a reftable/libreftable.a xdiff/lib.a
3947+ $(LD ) -r $^ -o $@
3948+
3949+ contrib/libgit-sys/hidden_symbol_export.o : contrib/libgit-sys/partial_symbol_export.o
3950+ $(OBJCOPY ) --localize-hidden $^ $@
3951+
3952+ contrib/libgit-sys/libgitpub.a : contrib/libgit-sys/hidden_symbol_export.o
3953+ $(AR ) $(ARFLAGS ) $@ $^
0 commit comments