summaryrefslogtreecommitdiffstats
path: root/build.rs
diff options
context:
space:
mode:
authorRory Dudley2024-07-03 15:42:32 -0600
committerRory Dudley2024-07-03 15:42:32 -0600
commite022a7eff4b9af4df3b3a852b911d89a04fdb98b (patch)
treed4331106f43cea0923e0523d03499ad655fb12a6 /build.rs
parentaf66f66f9d7b4a977ffd2420211704c050f23da8 (diff)
downloaddwarvish-e022a7eff4b9af4df3b3a852b911d89a04fdb98b.tar.gz
Option parsing and version
Add some basic logic for parsing commandline arguments. Also, use build.rs to embed the program version (and git commit) during the compile step. The program currently accepts the '--version' commandline argument to print the version, then quit.
Diffstat (limited to 'build.rs')
-rw-r--r--build.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/build.rs b/build.rs
new file mode 100644
index 0000000..fef4321
--- /dev/null
+++ b/build.rs
@@ -0,0 +1,16 @@
+use std::process::Command;
+
+fn main() {
+ let build = String::from_utf8_lossy(
+ &Command::new("git")
+ .args(&["rev-parse", "HEAD"])
+ .output()
+ .unwrap()
+ .stdout,
+ )
+ .to_string();
+ println!(
+ "cargo::rustc-env=DWVSH_BUILD={}",
+ build.get(0..10).unwrap_or(&build)
+ );
+}