Stable Hash: Add feature, adjust CI, modify build.rs, add new API for accessing and setting the ahash seed in config.rs, make config.rs public
This commit is contained in:
25
build.rs
25
build.rs
@@ -8,20 +8,21 @@ fn main() {
|
||||
// Tell Cargo that if the given environment variable changes, to rerun this build script.
|
||||
println!("cargo:rerun-if-changed=build.template");
|
||||
println!("cargo:rerun-if-env-changed=RHAI_AHASH_SEED");
|
||||
if !cfg!(feature = "stable_hash") {
|
||||
let mut contents = String::new();
|
||||
|
||||
let mut contents = String::new();
|
||||
File::open("build.template")
|
||||
.expect("cannot open `build.template`")
|
||||
.read_to_string(&mut contents)
|
||||
.expect("cannot read from `build.template`");
|
||||
|
||||
File::open("build.template")
|
||||
.expect("cannot open `build.template`")
|
||||
.read_to_string(&mut contents)
|
||||
.expect("cannot read from `build.template`");
|
||||
let seed = env::var("RHAI_AHASH_SEED").map_or_else(|_| "None".into(), |s| format!("Some({s})"));
|
||||
|
||||
let seed = env::var("RHAI_AHASH_SEED").map_or_else(|_| "None".into(), |s| format!("Some({s})"));
|
||||
contents = contents.replace("{{AHASH_SEED}}", &seed);
|
||||
|
||||
contents = contents.replace("{{AHASH_SEED}}", &seed);
|
||||
|
||||
File::create("src/config.rs")
|
||||
.expect("cannot create `config.rs`")
|
||||
.write(contents.as_bytes())
|
||||
.expect("cannot write to `config.rs`");
|
||||
File::create("src/config.rs")
|
||||
.expect("cannot create `config.rs`")
|
||||
.write_all(contents.as_bytes())
|
||||
.expect("cannot write to `config.rs`");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user