@@ -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-rs/ and contrib/libgit-rs/libgit-sys/.
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,13 @@ ifdef WITH_BREAKING_CHANGES
22542261 BASIC_CFLAGS += -DWITH_BREAKING_CHANGES
22552262endif
22562263
2264+ ifdef INCLUDE_LIBGIT_RS
2265+ # Enable symbol hiding in contrib/libgit-rs/libgit-sys/libgitpub.a
2266+ # without making us rebuild the whole tree every time we run a Rust
2267+ # build.
2268+ BASIC_CFLAGS += -fvisibility=hidden
2269+ endif
2270+
22572271ifeq ($(TCLTK_PATH ) ,)
22582272NO_TCLTK = NoThanks
22592273endif
@@ -2749,6 +2763,7 @@ OBJECTS += $(REFTABLE_OBJS) $(REFTABLE_TEST_OBJS)
27492763OBJECTS += $(UNIT_TEST_OBJS )
27502764OBJECTS += $(CLAR_TEST_OBJS )
27512765OBJECTS += $(patsubst % ,$(UNIT_TEST_DIR ) /% .o,$(UNIT_TEST_PROGRAMS ) )
2766+ OBJECTS += contrib/libgit-sys/public_symbol_export.o
27522767
27532768ifndef NO_CURL
27542769 OBJECTS += http.o http-walker.o remote-curl.o
@@ -3745,6 +3760,10 @@ clean: profile-clean coverage-clean cocciclean
37453760 $(RM ) $(htmldocs ) .tar.gz $(manpages ) .tar.gz
37463761 $(MAKE ) -C Documentation/ clean
37473762 $(RM ) Documentation/GIT-EXCLUDED-PROGRAMS
3763+ $(RM ) -r contrib/libgit-rs/target contrib/libgit-sys/target
3764+ $(RM ) -r contrib/libgit-sys/partial_symbol_export.o
3765+ $(RM ) -r contrib/libgit-sys/hidden_symbol_export.o
3766+ $(RM ) -r contrib/libgit-sys/libgitpub.a
37483767ifndef NO_PERL
37493768 $(RM) -r perl/build/
37503769endif
@@ -3906,3 +3925,28 @@ $(CLAR_TEST_PROG): $(UNIT_TEST_DIR)/clar.suite $(CLAR_TEST_OBJS) $(GITLIBS) GIT-
39063925build-unit-tests : $(UNIT_TEST_PROGS ) $(CLAR_TEST_PROG )
39073926unit-tests : $(UNIT_TEST_PROGS ) $(CLAR_TEST_PROG ) t/helper/test-tool$X
39083927 $(MAKE ) -C t/ unit-tests
3928+
3929+ .PHONY : libgit-sys
3930+ libgit-sys :
3931+ $(QUIET ) (\
3932+ cd contrib/libgit-sys && \
3933+ cargo build \
3934+ )
3935+ .PHONY : libgit-rs
3936+ libgit-rs :
3937+ $(QUIET ) (\
3938+ cd contrib/libgit-rs && \
3939+ cargo build \
3940+ )
3941+ ifdef INCLUDE_LIBGIT_RS
3942+ all :: libgit-rs
3943+ endif
3944+
3945+ contrib/libgit-sys/partial_symbol_export.o : contrib/libgit-sys/public_symbol_export.o libgit.a reftable/libreftable.a xdiff/lib.a
3946+ $(LD ) -r $^ -o $@
3947+
3948+ contrib/libgit-sys/hidden_symbol_export.o : contrib/libgit-sys/partial_symbol_export.o
3949+ $(OBJCOPY ) --localize-hidden $^ $@
3950+
3951+ contrib/libgit-sys/libgitpub.a : contrib/libgit-sys/hidden_symbol_export.o
3952+ $(AR ) $(ARFLAGS ) $@ $^
0 commit comments