From 710445dd4bbb89204be183ec9e49e524e94528e6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jo=C3=A3o=20Magalh=C3=A3es?= <joamag@gmail.com>
Date: Sun, 19 Feb 2023 18:39:23 +0000
Subject: [PATCH] feat: more env variable obtained

---
 build.rs        | 32 +++++++++++++++++++++++++++++++-
 src/gen/mock.rs |  5 +++++
 2 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/build.rs b/build.rs
index 6b7ee9cc..66f53f78 100644
--- a/build.rs
+++ b/build.rs
@@ -29,7 +29,7 @@ use std::fs::{File, OpenOptions};
 use std::io::Write;
 use std::path::Path;
 use std::process::Command;
-use std::str;
+use std::{env, str};
 
 const BUILD_OUT_FILE: &str = "build.rs";
 const SOURCE_DIR: &str = "./src/gen";
@@ -70,6 +70,12 @@ fn main() {
         &format!("{}", now_utc.format("%H:%M:%S")),
     );
 
+    write_str_constant(
+        &mut file,
+        "NAME",
+        option_env!("CARGO_PKG_NAME").unwrap_or("UNKNOWN"),
+    );
+
     write_str_constant(
         &mut file,
         "VERSION",
@@ -93,6 +99,30 @@ fn main() {
         .as_str();
     write_str_constant(&mut file, "COMPILER_VERSION", compiler_version);
 
+    write_str_constant(
+        &mut file,
+        "HOST",
+        &env::var("HOST").unwrap_or(String::from("UNKNOWN")),
+    );
+
+    write_str_constant(
+        &mut file,
+        "TARGET",
+        &env::var("TARGET").unwrap_or(String::from("UNKNOWN")),
+    );
+
+    write_str_constant(
+        &mut file,
+        "PROFILE",
+        &env::var("PROFILE").unwrap_or(String::from("UNKNOWN")),
+    );
+
+    write_str_constant(
+        &mut file,
+        "MAKEFLAGS",
+        option_env!("CARGO_MAKEFLAGS").unwrap_or("UNKNOWN"),
+    );
+
     let mut features = vec!["cpu"];
 
     if cfg!(feature = "wasm-extension") {
diff --git a/src/gen/mock.rs b/src/gen/mock.rs
index f98bedf3..b292a553 100644
--- a/src/gen/mock.rs
+++ b/src/gen/mock.rs
@@ -2,9 +2,14 @@
 
 pub const COMPILATION_DATE: &str = "-";
 pub const COMPILATION_TIME: &str = "-";
+pub const NAME: &str = "-";
 pub const VERSION: &str = "x.x.x";
 pub const COMPILER: &str = "rustc";
 pub const COMPILER_VERSION: &str = "x.x.x";
+pub const HOST: &str = "-";
+pub const TARGET: &str = "-";
+pub const PROFILE: &str = "-";
+pub const MAKEFLAGS: &str = "-";
 pub const FEATURES: [&str; 1] = ["cpu"];
 pub const PLATFORM_CPU_BITS: &str = "64";
 pub const DEFAULT_THREAD_POOL_SIZE: usize = 1;
-- 
GitLab