-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.rs
More file actions
executable file
·52 lines (47 loc) · 1.66 KB
/
Copy pathbuild.rs
File metadata and controls
executable file
·52 lines (47 loc) · 1.66 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
44
45
46
47
48
49
50
51
52
// build.rs
fn main() -> Result<(), Box<dyn std::error::Error>> {
let target_arch = std::env::var("CARGO_CFG_TARGET_ARCH").unwrap_or_default();
if target_arch != "wasm32" {
tonic_prost_build::configure()
.build_server(true)
.compile_protos(
&[
"proto/common_protocol.proto",
"proto/common_serial.proto",
"proto/proxyman.proto",
"proto/stats.proto",
"proto/rustray.proto",
"proto/health.proto",
],
&["."],
)?;
}
// Detect if we are building the server (not wasm)
let target_arch = std::env::var("CARGO_CFG_TARGET_ARCH").unwrap_or_default();
if target_arch != "wasm32" {
// Compile Tailwind CSS
println!("cargo:warning=Compiling Tailwind CSS...");
let status = std::process::Command::new("npx")
.args([
"tailwindcss",
"-i",
"./src/input.css",
"-o",
"./public/tailwind.css",
"--minify",
])
.status();
if let Ok(status) = status {
if !status.success() {
println!("cargo:warning=Tailwind CSS compilation failed.");
}
} else {
println!("cargo:warning=npx tailwindcss not found or failed to start.");
}
}
// Add rerun-if-changed for tailwind related files
println!("cargo:rerun-if-changed=src/input.css");
println!("cargo:rerun-if-changed=tailwind.config.js");
println!("cargo:rerun-if-changed=src");
Ok(())
}