summaryrefslogtreecommitdiff
path: root/media-video/walksnail-osd-tool/files/walksnail-osd-tool-0.3.0-build-remove-git-dep.patch
blob: d394ceffbb7a7bafc9622f2a8b56876c089cc7ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
diff --git a/ui/build.rs b/ui/build.rs
index b9826ab..447a91f 100644
--- a/ui/build.rs
+++ b/ui/build.rs
@@ -1,38 +1,41 @@
 use std::process::Command;
-
-use vergen::{vergen, Config};
+use std::str;
 
 fn main() {
-    println!("cargo:rerun-if-changed=./src");
+    println!("cargo:rerun-if-changed=/src");
 
-    // Save details from build environment so they can be included in the binary
-    vergen(Config::default()).unwrap();
+    // Explicilty set variables because git isn't available
+    println!("cargo:rustc-env=GIT_VERSION={}", "v0.3.0");
+    println!("cargo:rustc-env=GIT_COMMIT_HASH={}", "1044026");
+    println!("cargo:rustc-env=VERGEN_CARGO_TARGET_TRIPLE=x86_64-gentoo-linux-gnu");
 
-    if let Some(git_tag) = Command::new("git")
-        .args(["describe", "--exact-match", "--tags", "HEAD"])
+    let rustc_output = Command::new("rustc")
+        .arg("--version")
         .output()
-        .ok()
-        .and_then(|output| String::from_utf8(output.stdout).ok())
-    {
-        if !git_tag.is_empty() {
-            println!("cargo:rustc-env=GIT_VERSION={}", git_tag);
-        }
-    }
+        .expect("Failed to run rustc");
+    if !rustc_output.status.success() {
+        panic!("Failed to get rustc version");
 
-    if let Some(short_commit) = Command::new("git")
-        .args(["rev-parse", "--short", "HEAD"])
-        .output()
-        .ok()
-        .and_then(|output| String::from_utf8(output.stdout).ok())
-    {
-        println!("cargo:rustc-env=GIT_COMMIT_HASH={}", short_commit);
+    }
+    let rustc_output_str = str::from_utf8(&rustc_output.stdout).expect("Output is not valid UTF-8");
+    let rustc_version = rustc_output_str
+        .lines()
+        .next()
+        .and_then(|line| line.split_whitespace().nth(1));
+    match rustc_version {
+        Some(version_str) => {
+            println!("cargo:rustc-env=VERGEN_RUSTC_SEMVER={}", version_str)
+        }
+        None => {
+            panic!("Unable to parse rustc version");
+        }
     }
 
     // Load icon data
     let out_dir = std::env::var_os("OUT_DIR").unwrap();
     let dest_path = std::path::Path::new(&out_dir).join("icon_bytes");
     let icon = image::io::Reader::open("../resources/icons/256x256.png")
         .expect("Failed to load icon file")
         .decode()
         .expect("Failed to decode icon file");
     let icon_bytes = icon.as_bytes();
     std::fs::write(dest_path, icon_bytes).expect("Failed to write icon bytes");
 }