From 7ff5f6ad2276549ffd49d9e4e718e77168466a38 Mon Sep 17 00:00:00 2001 From: "Bernhard M. Wiedemann" Date: Mon, 31 Jul 2023 21:42:46 +0200 Subject: [PATCH] build: Sort toml preset files (#5352) build: Sort toml input file list for reproducible build results. See https://reproducible-builds.org/ for why this is good. This patch was done while working on reproducible builds for openSUSE. --- build.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/build.rs b/build.rs index 1d2f4c59..5e34d970 100644 --- a/build.rs +++ b/build.rs @@ -1,4 +1,5 @@ use std::fs::{self, File}; +use std::io; use std::io::Write; use shadow_rs::SdResult; @@ -20,11 +21,12 @@ fn main() -> SdResult<()> { fn gen_presets_hook(mut file: &File) -> SdResult<()> { println!("cargo:rerun-if-changed=docs/.vuepress/public/presets/toml"); let paths = fs::read_dir("docs/.vuepress/public/presets/toml")?; + let mut sortedpaths = paths.collect::>>()?; + sortedpaths.sort_by_key(|e| e.path()); let mut presets = String::new(); let mut match_arms = String::new(); - for path in paths { - let unwrapped = path?; + for unwrapped in sortedpaths { let file_name = unwrapped.file_name(); let full_path = dunce::canonicalize(unwrapped.path())?; let full_path = full_path.to_str().expect("failed to convert to string");