@@ -417,6 +417,9 @@ include shared.mak
417
417
# Define LINK_FUZZ_PROGRAMS if you want `make all` to also build the fuzz test
418
418
# programs in oss-fuzz/.
419
419
#
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
+ #
420
423
# === Optional library: libintl ===
421
424
#
422
425
# Define NO_GETTEXT if you don't want Git output to be translated.
@@ -658,6 +661,8 @@ CURL_CONFIG = curl-config
658
661
GCOV = gcov
659
662
STRIP = strip
660
663
SPATCH = spatch
664
+ LD = ld
665
+ OBJCOPY = objcopy
661
666
662
667
export TCL_PATH TCLTK_PATH
663
668
@@ -676,6 +681,7 @@ FUZZ_OBJS =
676
681
FUZZ_PROGRAMS =
677
682
GIT_OBJS =
678
683
LIB_OBJS =
684
+ LIBGIT_PUB_OBJS =
679
685
SCALAR_OBJS =
680
686
OBJECTS =
681
687
OTHER_PROGRAMS =
@@ -984,6 +990,8 @@ LIB_OBJS += combine-diff.o
984
990
LIB_OBJS += commit-graph.o
985
991
LIB_OBJS += commit-reach.o
986
992
LIB_OBJS += commit.o
993
+ LIB_OBJS += common-exit.o
994
+ LIB_OBJS += common-init.o
987
995
LIB_OBJS += compat/nonblock.o
988
996
LIB_OBJS += compat/obstack.o
989
997
LIB_OBJS += compat/terminal.o
@@ -2252,6 +2260,12 @@ ifdef WITH_BREAKING_CHANGES
2252
2260
BASIC_CFLAGS += -DWITH_BREAKING_CHANGES
2253
2261
endif
2254
2262
2263
+ ifdef INCLUDE_LIBGIT_RS
2264
+ # Enable symbol hiding in contrib/libgit-sys/libgitpub.a without making
2265
+ # us rebuild the whole tree every time we run a Rust build.
2266
+ BASIC_CFLAGS += -fvisibility=hidden
2267
+ endif
2268
+
2255
2269
ifeq ($(TCLTK_PATH ) ,)
2256
2270
NO_TCLTK = NoThanks
2257
2271
endif
@@ -2748,6 +2762,10 @@ OBJECTS += $(UNIT_TEST_OBJS)
2748
2762
OBJECTS += $(CLAR_TEST_OBJS )
2749
2763
OBJECTS += $(patsubst % ,$(UNIT_TEST_DIR ) /% .o,$(UNIT_TEST_PROGRAMS ) )
2750
2764
2765
+ ifdef INCLUDE_LIBGIT_RS
2766
+ OBJECTS += contrib/libgit-sys/public_symbol_export.o
2767
+ endif
2768
+
2751
2769
ifndef NO_CURL
2752
2770
OBJECTS += http.o http-walker.o remote-curl.o
2753
2771
endif
@@ -3743,6 +3761,10 @@ clean: profile-clean coverage-clean cocciclean
3743
3761
$(RM ) $(htmldocs ) .tar.gz $(manpages ) .tar.gz
3744
3762
$(MAKE ) -C Documentation/ clean
3745
3763
$(RM ) Documentation/GIT-EXCLUDED-PROGRAMS
3764
+ $(RM ) -r contrib/libgit-sys/target contrib/libgit-rs/target
3765
+ $(RM ) contrib/libgit-sys/partial_symbol_export.o
3766
+ $(RM ) contrib/libgit-sys/hidden_symbol_export.o
3767
+ $(RM ) contrib/libgit-sys/libgitpub.a
3746
3768
ifndef NO_PERL
3747
3769
$(RM) -r perl/build/
3748
3770
endif
@@ -3904,3 +3926,31 @@ $(CLAR_TEST_PROG): $(UNIT_TEST_DIR)/clar.suite $(CLAR_TEST_OBJS) $(GITLIBS) GIT-
3904
3926
build-unit-tests : $(UNIT_TEST_PROGS ) $(CLAR_TEST_PROG )
3905
3927
unit-tests : $(UNIT_TEST_PROGS ) $(CLAR_TEST_PROG ) t/helper/test-tool$X
3906
3928
$(MAKE ) -C t/ unit-tests
3929
+
3930
+ .PHONY : libgit-sys libgit-rs
3931
+ libgit-sys libgit-rs :
3932
+ $(QUIET ) (\
3933
+ cd contrib/$@ && \
3934
+ cargo build \
3935
+ )
3936
+ ifdef INCLUDE_LIBGIT_RS
3937
+ all :: libgit-sys libgit-rs
3938
+ endif
3939
+
3940
+ LIBGIT_PUB_OBJS += contrib/libgit-sys/public_symbol_export.o
3941
+ LIBGIT_PUB_OBJS += libgit.a
3942
+ LIBGIT_PUB_OBJS += reftable/libreftable.a
3943
+ LIBGIT_PUB_OBJS += xdiff/lib.a
3944
+
3945
+ LIBGIT_PARTIAL_EXPORT = contrib/libgit-sys/partial_symbol_export.o
3946
+
3947
+ LIBGIT_HIDDEN_EXPORT = contrib/libgit-sys/hidden_symbol_export.o
3948
+
3949
+ $(LIBGIT_PARTIAL_EXPORT ) : $(LIBGIT_PUB_OBJS )
3950
+ $(LD ) -r $^ -o $@
3951
+
3952
+ $(LIBGIT_HIDDEN_EXPORT ) : $(LIBGIT_PARTIAL_EXPORT )
3953
+ $(OBJCOPY ) --localize-hidden $^ $@
3954
+
3955
+ contrib/libgit-sys/libgitpub.a : $(LIBGIT_HIDDEN_EXPORT )
3956
+ $(AR ) $(ARFLAGS ) $@ $^
0 commit comments