Skip to content

Commit 970e48c

Browse files
bk2204gitster
authored andcommitted
rust: add a build.rs script for tests
Cargo uses the build.rs script to determine how to compile and link a binary. The only binary we're generating, however, is for our tests, but in a future commit, we're going to link against libgit.a for some functionality and we'll need to make sure the test binaries are complete. Add a build.rs file for this case and specify the files we're going to be linking against. Because we cannot specify different dependencies when building our static library versus our tests, update the Makefile to specify these dependencies for our static library to avoid race conditions during build. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 84af9d2 commit 970e48c

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2958,7 +2958,7 @@ scalar$X: scalar.o GIT-LDFLAGS $(GITLIBS)
29582958
$(LIB_FILE): $(LIB_OBJS)
29592959
$(QUIET_AR)$(RM) $@ && $(AR) $(ARFLAGS) $@ $^
29602960

2961-
$(RUST_LIB): Cargo.toml $(RUST_SOURCES)
2961+
$(RUST_LIB): Cargo.toml $(RUST_SOURCES) $(XDIFF_LIB) $(LIB_FILE) $(REFTABLE_LIB)
29622962
$(QUIET_CARGO)cargo build $(CARGO_ARGS)
29632963

29642964
.PHONY: rust

build.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// This program is free software; you can redistribute it and/or modify
2+
// it under the terms of the GNU General Public License as published by
3+
// the Free Software Foundation: version 2 of the License, dated June 1991.
4+
//
5+
// This program is distributed in the hope that it will be useful,
6+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
7+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8+
// GNU General Public License for more details.
9+
//
10+
// You should have received a copy of the GNU General Public License along
11+
// with this program; if not, see <https://www.gnu.org/licenses/>.
12+
13+
fn main() {
14+
println!("cargo::rustc-link-search=.");
15+
println!("cargo::rustc-link-search=reftable");
16+
println!("cargo::rustc-link-search=xdiff");
17+
println!("cargo::rustc-link-lib=git");
18+
println!("cargo::rustc-link-lib=reftable");
19+
println!("cargo::rustc-link-lib=z");
20+
println!("cargo::rustc-link-lib=xdiff");
21+
}

0 commit comments

Comments
 (0)