-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.rs
55 lines (48 loc) · 1.37 KB
/
build.rs
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
use std::{error::Error, process::Command};
struct Meta;
impl Meta {
fn version() {
let out = Command::new("git")
.arg("describe")
.arg("--always")
.arg("--dirty")
.output()
.unwrap();
println!(
"cargo:rustc-env=GIT_DESCRIBE={}",
String::from_utf8(out.stdout).unwrap()
);
}
fn timestamp() {
let timestamp = chrono::Utc::now().to_rfc3339_opts(chrono::SecondsFormat::Secs, true);
println!("cargo:rustc-env=BUILD_TIMESTAMP={}", timestamp);
}
}
struct Build;
impl Build {
fn build_hlrt() {
// only run `pnpm install` if hlrt/node_modules is absent
if !std::path::Path::new("hlrt").join("node_modules").exists() {
Command::new("cmd")
.arg("/C")
.arg("pnpm")
.arg("install")
.current_dir("hlrt")
.spawn()
.expect("failed to run `pnpm install` for HLRT");
}
Command::new("cmd")
.arg("/C")
.arg("pnpm")
.arg("maybe-build:js")
.current_dir("hlrt")
.spawn()
.expect("failed to run `pnpm maybe-build:js` for HLRT");
}
}
fn main() -> Result<(), Box<dyn Error>> {
Meta::version();
Meta::timestamp();
Build::build_hlrt();
Ok(())
}