Skip to content

Commit

Permalink
refactor build.rs to collect and sort directory entries for determini…
Browse files Browse the repository at this point in the history
…stic output
  • Loading branch information
ZibanPirate committed Nov 21, 2024
1 parent 3c63547 commit d70725c
Show file tree
Hide file tree
Showing 2 changed files with 1,087 additions and 1,083 deletions.
26 changes: 15 additions & 11 deletions rust/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,22 +83,26 @@ mod r#static {
};

let sub_dirs = fs::read_dir(&dir).unwrap();
let children = sub_dirs.filter_map(|entry| {
let entry = entry.unwrap();
let ty = entry.file_type().unwrap();
if ty.is_dir() {
Some(dir_tree_to_list(entry.path()))
} else {
None
}
});
let mut children: Vec<(String, String)> = sub_dirs
.filter_map(|entry| {
let entry = entry.unwrap();
let ty = entry.file_type().unwrap();
if ty.is_dir() {
Some(dir_tree_to_list(entry.path()))
} else {
None
}
})
.collect();
// to ensure deterministic output on different platforms
children.sort();

let mut constants = String::new();
let mut matches = String::new();
children.for_each(|(c, m)| {
for (c, m) in children {
constants.push_str(&c);
matches.push_str(&m);
});
}

(
format!("{}{}", this_node, constants),
Expand Down
Loading

0 comments on commit d70725c

Please sign in to comment.