MCPcopy Create free account
hub / github.com/Rust-Web-Development/code / generate_cargo_keys

Function generate_cargo_keys

ch_11/build.rs:4–28  ·  view source on GitHub ↗

Generate the `cargo:` key output

()

Source from the content-addressed store, hash-verified

2
3/// Generate the `cargo:` key output
4pub fn generate_cargo_keys() {
5 let output = Command::new("git")
6 .args(&["rev-parse", "--short", "HEAD"])
7 .output();
8
9 let commit = match output {
10 Ok(o) if o.status.success() => {
11 let sha = String::from_utf8_lossy(&o.stdout).trim().to_owned();
12 Cow::from(sha)
13 }
14 Ok(o) => {
15 println!("cargo:warning=Git command failed with status: {}", o.status);
16 Cow::from("unknown")
17 }
18 Err(err) => {
19 println!("cargo:warning=Failed to execute git command: {}", err);
20 Cow::from("unknown")
21 }
22 };
23
24 println!(
25 "cargo:rustc-env=RUST_WEB_DEV_VERSION={}",
26 get_version(&commit)
27 )
28}
29
30fn get_platform() -> String {
31 let arch = std::env::var("CARGO_CFG_TARGET_ARCH").unwrap_or_default();

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected