rkgk/crates/haku2/build.rs
リキ萌 bff899c9c0 removing server-side brush rendering
brush rendering is now completely client-side.
the server only receives edits the client would like to do, in the form of PNG images of chunks, that are then composited onto the wall

known issue: it is possible to brush up against the current 256 chunk edit limit pretty easily.
I'm not sure it can be solved very easily though. the perfect solution would involve splitting up the interaction into multiple edits, and I tried to do that, but there's a noticable stutter for some reason that I haven't managed to track down yet.
so it'll be kinda crap for the time being.
2025-06-30 18:55:53 +02:00

64 lines
1.8 KiB
Rust

use std::{
env,
error::Error,
path::PathBuf,
process::{Command, Stdio},
};
fn main() -> Result<(), Box<dyn Error>> {
println!("cargo::rerun-if-changed=build.zig");
println!("cargo::rerun-if-changed=build.zig.zon");
println!("cargo::rerun-if-changed=src");
let out_dir = env::var("OUT_DIR").unwrap();
let out_path = PathBuf::from(&out_dir);
let profile = env::var("PROFILE").unwrap();
let target = env::var("TARGET").unwrap();
// TODO: Use of PROFILE is discouraged, so we should switch this to a more fine-grained system
// reading back from other environment variables.
let optimize = match &profile[..] {
"debug" => "Debug",
"release" => "ReleaseSmall",
_ => panic!("unknown profile"),
};
let color = match env::var("NO_COLOR").is_ok() {
true => "off",
false => "on",
};
let target = match &target[..] {
"x86_64-unknown-linux-gnu" => "x86_64-linux-gnu",
"aarch64-unknown-linux-gnu" => "aarch64-linux-gnu",
other => {
eprintln!("warning: unknown target {other:?}");
&target
}
};
let output = Command::new("zig")
.arg("build")
.arg("install")
// Terminal output
.stdout(Stdio::inherit())
.stderr(Stdio::inherit())
.arg("--prominent-compile-errors")
.arg("--color")
.arg(color)
// Build output
.arg("--cache-dir")
.arg(out_path.join("zig-cache"))
.arg("--prefix")
.arg(out_path.join("zig-out"))
// Build settings
.arg(format!("-Doptimize={optimize}"))
.arg(format!("-Dtarget={target}"))
.output()?;
if !output.status.success() {
panic!("zig failed to build");
}
Ok(())
}