Skip to content

Commit c557398

Browse files
calvin-wan-googlesteadmon
authored andcommitted
Makefile: add option to build and test libgit-rs and libgit-rs-sys
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@google.com> Signed-off-by: Calvin Wan <calvinwan@google.com> Signed-off-by: Josh Steadmon <steadmon@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent bd362ea commit c557398

File tree

3 files changed

+43
-1
lines changed

3 files changed

+43
-1
lines changed

Makefile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,9 @@ include shared.mak
416416
# Define LINK_FUZZ_PROGRAMS if you want `make all` to also build the fuzz test
417417
# programs in oss-fuzz/.
418418
#
419+
# Define INCLUDE_LIBGIT_RS if you want `make all` and `make test` to build and
420+
# test the Rust crates in contrib/libgit-rs/ and contrib/libgit-rs/libgit-sys/.
421+
#
419422
# === Optional library: libintl ===
420423
#
421424
# Define NO_GETTEXT if you don't want Git output to be translated.
@@ -2238,6 +2241,13 @@ ifdef FSMONITOR_OS_SETTINGS
22382241
COMPAT_OBJS += compat/fsmonitor/fsm-path-utils-$(FSMONITOR_OS_SETTINGS).o
22392242
endif
22402243

2244+
ifdef INCLUDE_LIBGIT_RS
2245+
# Enable symbol hiding in contrib/libgit-rs/libgit-sys/libgitpub.a
2246+
# without making us rebuild the whole tree every time we run a Rust
2247+
# build.
2248+
BASIC_CFLAGS += -fvisibility=hidden
2249+
endif
2250+
22412251
ifeq ($(TCLTK_PATH),)
22422252
NO_TCLTK = NoThanks
22432253
endif
@@ -3895,6 +3905,22 @@ build-unit-tests: $(UNIT_TEST_PROGS) $(CLAR_TEST_PROG)
38953905
unit-tests: $(UNIT_TEST_PROGS) $(CLAR_TEST_PROG) t/helper/test-tool$X
38963906
$(MAKE) -C t/ unit-tests
38973907

3908+
.PHONY: libgit-sys
3909+
libgit-sys:
3910+
$(QUIET)(\
3911+
cd contrib/libgit-sys && \
3912+
cargo build \
3913+
)
3914+
.PHONY: libgit-rs
3915+
libgit-rs:
3916+
$(QUIET)(\
3917+
cd contrib/libgit-rs && \
3918+
cargo build \
3919+
)
3920+
ifdef INCLUDE_LIBGIT_RS
3921+
all:: libgit-rs
3922+
endif
3923+
38983924
contrib/libgit-sys/partial_symbol_export.o: contrib/libgit-sys/public_symbol_export.o libgit.a reftable/libreftable.a xdiff/lib.a
38993925
$(LD) -r $^ -o $@
39003926

contrib/libgit-sys/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub fn main() -> std::io::Result<()> {
1414
.env_remove("PROFILE")
1515
.current_dir(git_root.clone())
1616
.args([
17-
"CFLAGS=-fvisibility=hidden",
17+
"INCLUDE_LIBGIT_RS=YesPlease",
1818
"contrib/libgit-sys/libgitpub.a",
1919
])
2020
.output()

t/Makefile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,3 +177,19 @@ perf:
177177

178178
.PHONY: pre-clean $(T) aggregate-results clean valgrind perf \
179179
check-chainlint clean-chainlint test-chainlint $(UNIT_TESTS)
180+
181+
.PHONY: libgit-sys-test
182+
libgit-sys-test:
183+
$(QUIET)(\
184+
cd ../contrib/libgit-sys && \
185+
cargo test \
186+
)
187+
.PHONY: libgit-rs-test
188+
libgit-rs-test:
189+
$(QUIET)(\
190+
cd ../contrib/libgit-rs && \
191+
cargo test \
192+
)
193+
ifdef INCLUDE_LIBGIT_RS
194+
all:: libgit-sys-test libgit-rs-test
195+
endif

0 commit comments

Comments
 (0)