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.
This commit is contained in:
Bernhard M. Wiedemann 2023-07-31 21:42:46 +02:00 committed by GitHub
parent fcf4298ea3
commit 7ff5f6ad22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -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::<io::Result<Vec<_>>>()?;
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");