-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbuild.rs
More file actions
43 lines (38 loc) · 1.6 KB
/
build.rs
File metadata and controls
43 lines (38 loc) · 1.6 KB
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
use std::net::TcpStream;
use std::process::Command;
fn run_command(command: &str, args: &[&str], dir: &str) {
let status = Command::new(command)
.args(args)
.current_dir(dir)
.status()
.unwrap_or_else(|_| panic!("Failed: {} {}", command, args.join(" ")));
if !status.success() {
panic!("Failed: {} {}", command, args.join(" "));
} else {
println!("cargo:warning=Succeeded: {} {}", command, args.join(" "));
}
}
fn main() {
println!("cargo:rerun-if-changed=resources/photosphereviewer/index.html");
println!("cargo:rerun-if-changed=resources/photosphereviewer/src/viewer.js");
println!("cargo:rerun-if-changed=resources/photosphereviewer/src/style.css");
println!("cargo:rerun-if-changed=resources/photosphereviewer/public/demo.webp");
println!("cargo:rerun-if-changed=resources/data/window.blp");
println!("cargo:rerun-if-changed=resources/io.github.dynobo.sphereview.gresource.xml");
println!("cargo:rerun-if-changed=resources/io.github.dynobo.sphereview.gresource");
if TcpStream::connect(("8.8.8.8", 53)).is_ok() {
run_command("npm", &["install"], "resources/photosphereviewer");
} else {
run_command("npm", &["ci", "--offline"], "resources/photosphereviewer");
}
run_command("npm", &["run", "build"], "resources/photosphereviewer");
run_command(
"glib-compile-resources",
&[
"--sourcedir=resources",
"resources/io.github.dynobo.sphereview.gresource.xml",
"--target=resources/io.github.dynobo.sphereview.gresource",
],
".",
);
}