Skip to content

Commit de8a880

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 <[email protected]> Signed-off-by: Calvin Wan <[email protected]> Signed-off-by: Josh Steadmon <[email protected]> Signed-off-by: Taylor Blau <[email protected]>
1 parent a32db1b commit de8a880

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
@@ -412,6 +412,9 @@ include shared.mak
412412
# Define LINK_FUZZ_PROGRAMS if you want `make all` to also build the fuzz test
413413
# programs in oss-fuzz/.
414414
#
415+
# Define INCLUDE_LIBGIT_RS if you want `make all` and `make test` to build and
416+
# test the Rust crates in contrib/libgit-rs/ and contrib/libgit-rs/libgit-sys/.
417+
#
415418
# === Optional library: libintl ===
416419
#
417420
# Define NO_GETTEXT if you don't want Git output to be translated.
@@ -2181,6 +2184,13 @@ ifdef FSMONITOR_OS_SETTINGS
21812184
COMPAT_OBJS += compat/fsmonitor/fsm-path-utils-$(FSMONITOR_OS_SETTINGS).o
21822185
endif
21832186

2187+
ifdef INCLUDE_LIBGIT_RS
2188+
# Enable symbol hiding in contrib/libgit-rs/libgit-sys/libgitpub.a
2189+
# without making us rebuild the whole tree every time we run a Rust
2190+
# build.
2191+
BASIC_CFLAGS += -fvisibility=hidden
2192+
endif
2193+
21842194
ifeq ($(TCLTK_PATH),)
21852195
NO_TCLTK = NoThanks
21862196
endif
@@ -3873,6 +3883,22 @@ build-unit-tests: $(UNIT_TEST_PROGS)
38733883
unit-tests: $(UNIT_TEST_PROGS) t/helper/test-tool$X
38743884
$(MAKE) -C t/ unit-tests
38753885

3886+
.PHONY: libgitrs-sys
3887+
libgitrs-sys:
3888+
$(QUIET)(\
3889+
cd contrib/libgit-rs/libgit-sys && \
3890+
cargo build \
3891+
)
3892+
.PHONY: libgitrs
3893+
libgitrs:
3894+
$(QUIET)(\
3895+
cd contrib/libgit-rs && \
3896+
cargo build \
3897+
)
3898+
ifdef INCLUDE_LIBGIT_RS
3899+
all:: libgitrs
3900+
endif
3901+
38763902
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
38773903
$(LD) -r $^ -o $@
38783904

contrib/libgit-rs/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-rs/libgit-sys/libgitpub.a",
1919
])
2020
.output()

t/Makefile

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

170170
.PHONY: pre-clean $(T) aggregate-results clean valgrind perf \
171171
check-chainlint clean-chainlint test-chainlint $(UNIT_TESTS)
172+
173+
.PHONY: libgitrs-sys-test
174+
libgitrs-sys-test:
175+
$(QUIET)(\
176+
cd ../contrib/libgit-rs/libgit-sys && \
177+
cargo test \
178+
)
179+
.PHONY: libgitrs-test
180+
libgitrs-test:
181+
$(QUIET)(\
182+
cd ../contrib/libgit-rs && \
183+
cargo test \
184+
)
185+
ifdef INCLUDE_LIBGIT_RS
186+
all:: libgitrs-sys-test libgitrs-test
187+
endif

0 commit comments

Comments
 (0)