Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pola-rs
GitHub Repository: pola-rs/polars
Path: blob/main/crates/polars-plan/build.rs
6939 views
1
use std::env;
2
use std::io::Write;
3
use std::path::Path;
4
5
use sha2::Digest;
6
7
fn main() {
8
println!("cargo:rerun-if-changed=build.rs");
9
let channel = version_check::Channel::read().unwrap();
10
if channel.is_nightly() {
11
println!("cargo:rustc-cfg=feature=\"nightly\"");
12
}
13
14
generate_schema_hash();
15
}
16
17
/// Generate a hash of the schema hashes file, to be embedded in the binary.
18
///
19
/// Used in `SchemaHash` (crates/polars-plan/src/dsl/plan.rs) for DSL compatibility check.
20
fn generate_schema_hash() {
21
let hash_hexstr = {
22
let mut digest = sha2::Sha256::new();
23
digest
24
.write_all(include_bytes!("dsl-schema-hashes.json"))
25
.expect("failed to hash the schema hashes file");
26
let hash = digest.finalize();
27
28
format!("{hash:064x}")
29
};
30
31
let out_dir = env::var_os("OUT_DIR").unwrap();
32
let dst = Path::new(&out_dir).join("dsl-schema.sha256");
33
std::fs::write(dst, &hash_hexstr).expect("failed to write the schema hash file");
34
35
println!("cargo:rerun-if-changed=dsl-schema-hashes.json");
36
}
37
38