forked from Technosorcery/sd2snes-lttp-rando-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.rs
49 lines (42 loc) · 1.14 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
extern crate includedir_codegen;
use includedir_codegen::Compression;
use std::process::Command;
fn main() {
build_ui_files();
package_extra_files();
}
fn build_ui_files() {
if let Ok(_) = std::env::var("SKIP_UI_BUILD") {
return;
}
let ui_dir = match std::env::current_dir() {
Ok(mut d) => {
d.push("ui");
d
},
Err(e) => panic!("Could not get current directory: {}", e),
};
let yarn_command = match std::env::var("YARN_PATH") {
Ok(c) => c,
_ => "yarn".to_string(),
};
println!("yarn command: {}", &yarn_command);
let ui_build_status = Command::new(yarn_command)
.arg("build")
.current_dir(ui_dir)
.status()
.expect("Failed to build UI");
if !ui_build_status.success() {
panic!("Could not build UI");
}
}
fn package_extra_files() {
includedir_codegen::start("UI_FILES")
.dir("ui/dist", Compression::Gzip)
.build("ui_files.rs")
.unwrap();
includedir_codegen::start("LOGIC_FILES")
.dir("logic", Compression::Gzip)
.build("logic_files.rs")
.unwrap();
}