@@ -412,6 +412,9 @@ include shared.mak
# Define LINK_FUZZ_PROGRAMS if you want `make all` to also build the fuzz test
# programs in oss-fuzz/.
#
+# Define INCLUDE_LIBGIT_RS if you want `make all` and `make test` to build and
+# test the Rust crates in contrib/libgit-rs/ and contrib/libgit-rs/libgit-sys/.
+#
# === Optional library: libintl ===
#
# Define NO_GETTEXT if you don't want Git output to be translated.
@@ -2181,6 +2184,13 @@ ifdef FSMONITOR_OS_SETTINGS
COMPAT_OBJS += compat/fsmonitor/fsm-path-utils-$(FSMONITOR_OS_SETTINGS).o
endif
+ifdef INCLUDE_LIBGIT_RS
+ # Enable symbol hiding in contrib/libgit-rs/libgit-sys/libgitpub.a
+ # without making us rebuild the whole tree every time we run a Rust
+ # build.
+ BASIC_CFLAGS += -fvisibility=hidden
+endif
+
ifeq ($(TCLTK_PATH),)
NO_TCLTK = NoThanks
endif
@@ -3873,6 +3883,22 @@ build-unit-tests: $(UNIT_TEST_PROGS)
unit-tests: $(UNIT_TEST_PROGS) t/helper/test-tool$X
$(MAKE) -C t/ unit-tests
+.PHONY: libgitrs-sys
+libgitrs-sys:
+ $(QUIET)(\
+ cd contrib/libgit-rs/libgit-sys && \
+ cargo build \
+ )
+.PHONY: libgitrs
+libgitrs:
+ $(QUIET)(\
+ cd contrib/libgit-rs && \
+ cargo build \
+ )
+ifdef INCLUDE_LIBGIT_RS
+all:: libgitrs
+endif
+
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
$(LD) -r $^ -o $@
@@ -14,7 +14,7 @@ pub fn main() -> std::io::Result<()> {
.env_remove("PROFILE")
.current_dir(git_root.clone())
.args([
- "CFLAGS=-fvisibility=hidden",
+ "INCLUDE_LIBGIT_RS=YesPlease",
"contrib/libgit-rs/libgit-sys/libgitpub.a",
])
.output()
@@ -169,3 +169,19 @@ perf:
.PHONY: pre-clean $(T) aggregate-results clean valgrind perf \
check-chainlint clean-chainlint test-chainlint $(UNIT_TESTS)
+
+.PHONY: libgitrs-sys-test
+libgitrs-sys-test:
+ $(QUIET)(\
+ cd ../contrib/libgit-rs/libgit-sys && \
+ cargo test \
+ )
+.PHONY: libgitrs-test
+libgitrs-test:
+ $(QUIET)(\
+ cd ../contrib/libgit-rs && \
+ cargo test \
+ )
+ifdef INCLUDE_LIBGIT_RS
+all:: libgitrs-sys-test libgitrs-test
+endif