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

Function generate_cargo_keys

ch_10/build.rs:4–34  ·  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!(
16 "cargo:warning=Git command failed with status: {}",
17 o.status
18 );
19 Cow::from("unknown")
20 }
21 Err(err) => {
22 println!(
23 "cargo:warning=Failed to execute git command: {}",
24 err
25 );
26 Cow::from("unknown")
27 }
28 };
29
30 println!(
31 "cargo:rustc-env=RUST_WEB_DEV_VERSION={}",
32 get_version(&commit)
33 )
34}
35
36fn get_platform() -> String {
37 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