Skip to content

Commit 1b39a52

Browse files
committed
Compile libgit2 deterministically by sorting read_dir
1 parent 218a2b3 commit 1b39a52

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

libgit2-sys/build.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use std::env;
22
use std::fs;
3+
use std::io;
34
use std::path::{Path, PathBuf};
45
use std::process::Command;
56

@@ -199,8 +200,10 @@ fn cp_r(from: impl AsRef<Path>, to: impl AsRef<Path>) {
199200
}
200201

201202
fn add_c_files(build: &mut cc::Build, path: impl AsRef<Path>) {
202-
for e in path.as_ref().read_dir().unwrap() {
203-
let e = e.unwrap();
203+
let dir = path.as_ref().read_dir().unwrap();
204+
let mut paths = dir.collect::<io::Result<Vec<_>>>().unwrap();
205+
paths.sort_by_key(|e| e.path());
206+
for e in paths {
204207
let path = e.path();
205208
if e.file_type().unwrap().is_dir() {
206209
// skip dirs for now

0 commit comments

Comments
 (0)