Skip to content

Commit b9cbb44

Browse files
authored
Support for building refactored libgit2 sources when using the vendored libgit2 (#822)
Since libgit2/libgit2@3a3ab06 libgit2 is refactored into a library and CLI. This change allows git2-rs to build those sources when the copy is used. This should not be integrated until a libgit2 release is made incorporating those sources. The libgit2 submodule has been updated at the current commit on libgit2's `main` branch.
1 parent 0443adb commit b9cbb44

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

libgit2-sys/build.rs

+19-13
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,21 @@ fn main() {
4141
cp_r("libgit2/include", &include);
4242

4343
cfg.include(&include)
44-
.include("libgit2/src")
44+
.include("libgit2/src/libgit2")
45+
.include("libgit2/src/util")
4546
.out_dir(dst.join("build"))
4647
.warnings(false);
4748

4849
// Include all cross-platform C files
49-
add_c_files(&mut cfg, "libgit2/src");
50-
add_c_files(&mut cfg, "libgit2/src/xdiff");
50+
add_c_files(&mut cfg, "libgit2/src/libgit2");
51+
add_c_files(&mut cfg, "libgit2/src/util");
52+
add_c_files(&mut cfg, "libgit2/src/libgit2/xdiff");
5153

5254
// These are activated by features, but they're all unconditionally always
5355
// compiled apparently and have internal #define's to make sure they're
5456
// compiled correctly.
55-
add_c_files(&mut cfg, "libgit2/src/transports");
56-
add_c_files(&mut cfg, "libgit2/src/streams");
57+
add_c_files(&mut cfg, "libgit2/src/libgit2/transports");
58+
add_c_files(&mut cfg, "libgit2/src/libgit2/streams");
5759

5860
// Always use bundled http-parser for now
5961
cfg.include("libgit2/deps/http-parser")
@@ -82,11 +84,11 @@ fn main() {
8284
// when when COMPILE_PCRE8 is not defined, which is the default.
8385
add_c_files(&mut cfg, "libgit2/deps/pcre");
8486

85-
cfg.file("libgit2/src/allocators/failalloc.c");
86-
cfg.file("libgit2/src/allocators/stdalloc.c");
87+
cfg.file("libgit2/src/util/allocators/failalloc.c");
88+
cfg.file("libgit2/src/util/allocators/stdalloc.c");
8789

8890
if windows {
89-
add_c_files(&mut cfg, "libgit2/src/win32");
91+
add_c_files(&mut cfg, "libgit2/src/util/win32");
9092
cfg.define("STRSAFE_NO_DEPRECATE", None);
9193
cfg.define("WIN32", None);
9294
cfg.define("_WIN32_WINNT", Some("0x0600"));
@@ -98,7 +100,7 @@ fn main() {
98100
cfg.define("__USE_MINGW_ANSI_STDIO", "1");
99101
}
100102
} else {
101-
add_c_files(&mut cfg, "libgit2/src/unix");
103+
add_c_files(&mut cfg, "libgit2/src/util/unix");
102104
cfg.flag("-fvisibility=hidden");
103105
}
104106
if target.contains("solaris") || target.contains("illumos") {
@@ -156,9 +158,9 @@ fn main() {
156158
cfg.define("SHA1DC_NO_STANDARD_INCLUDES", "1");
157159
cfg.define("SHA1DC_CUSTOM_INCLUDE_SHA1_C", "\"common.h\"");
158160
cfg.define("SHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C", "\"common.h\"");
159-
cfg.file("libgit2/src/hash/sha1/collisiondetect.c");
160-
cfg.file("libgit2/src/hash/sha1/sha1dc/sha1.c");
161-
cfg.file("libgit2/src/hash/sha1/sha1dc/ubc_check.c");
161+
cfg.file("libgit2/src/util/hash/sha1/collisiondetect.c");
162+
cfg.file("libgit2/src/util/hash/sha1/sha1dc/sha1.c");
163+
cfg.file("libgit2/src/util/hash/sha1/sha1dc/ubc_check.c");
162164

163165
if let Some(path) = env::var_os("DEP_Z_INCLUDE") {
164166
cfg.include(path);
@@ -210,8 +212,12 @@ fn cp_r(from: impl AsRef<Path>, to: impl AsRef<Path>) {
210212
}
211213

212214
fn add_c_files(build: &mut cc::Build, path: impl AsRef<Path>) {
215+
let path = path.as_ref();
216+
if !path.exists() {
217+
panic!("Path {} does not exist", path.display());
218+
}
213219
// sort the C files to ensure a deterministic build for reproducible builds
214-
let dir = path.as_ref().read_dir().unwrap();
220+
let dir = path.read_dir().unwrap();
215221
let mut paths = dir.collect::<io::Result<Vec<_>>>().unwrap();
216222
paths.sort_by_key(|e| e.path());
217223

libgit2-sys/libgit2

Submodule libgit2 updated 886 files

0 commit comments

Comments
 (0)