From: Calvin Wan <calvinwan@xxxxxxxxxx> Add libgitrs, libgitrs-sys, libgitrs-test, and libgitrs-sys-test targets to their respective Makefiles so they can be built and tested without having to run cargo build/test. Add build variable, INCLUDE_LIBGIT_RS, that when set, automatically builds and tests libgit-rs and libgit-rs-sys when `make all` is run. Co-authored-by: Josh Steadmon <steadmon@xxxxxxxxxx> Signed-off-by: Calvin Wan <calvinwan@xxxxxxxxxx> Signed-off-by: Josh Steadmon <steadmon@xxxxxxxxxx> --- Makefile | 26 ++++++++++++++++++++++++++ contrib/libgit-sys/build.rs | 2 +- t/Makefile | 16 ++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 230d366457..133090a145 100644 --- a/Makefile +++ b/Makefile @@ -416,6 +416,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. @@ -2238,6 +2241,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 @@ -3895,6 +3905,22 @@ build-unit-tests: $(UNIT_TEST_PROGS) $(CLAR_TEST_PROG) unit-tests: $(UNIT_TEST_PROGS) $(CLAR_TEST_PROG) t/helper/test-tool$X $(MAKE) -C t/ unit-tests +.PHONY: libgit-sys +libgit-sys: + $(QUIET)(\ + cd contrib/libgit-sys && \ + cargo build \ + ) +.PHONY: libgit-rs +libgit-rs: + $(QUIET)(\ + cd contrib/libgit-rs && \ + cargo build \ + ) +ifdef INCLUDE_LIBGIT_RS +all:: libgit-rs +endif + contrib/libgit-sys/partial_symbol_export.o: contrib/libgit-sys/public_symbol_export.o libgit.a reftable/libreftable.a xdiff/lib.a $(LD) -r $^ -o $@ diff --git a/contrib/libgit-sys/build.rs b/contrib/libgit-sys/build.rs index b6c65193bc..3ffd80ad91 100644 --- a/contrib/libgit-sys/build.rs +++ b/contrib/libgit-sys/build.rs @@ -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-sys/libgitpub.a", ]) .output() diff --git a/t/Makefile b/t/Makefile index daa5fcae86..45fe6089b2 100644 --- a/t/Makefile +++ b/t/Makefile @@ -177,3 +177,19 @@ perf: .PHONY: pre-clean $(T) aggregate-results clean valgrind perf \ check-chainlint clean-chainlint test-chainlint $(UNIT_TESTS) + +.PHONY: libgit-sys-test +libgit-sys-test: + $(QUIET)(\ + cd ../contrib/libgit-sys && \ + cargo test \ + ) +.PHONY: libgit-rs-test +libgit-rs-test: + $(QUIET)(\ + cd ../contrib/libgit-rs && \ + cargo test \ + ) +ifdef INCLUDE_LIBGIT_RS +all:: libgit-sys-test libgit-rs-test +endif -- 2.48.0.rc2.279.g1de40edade-goog