Open elliottslaughter opened 1 month ago
For posterity, the equivalent Legion Prof-side build.rs
for this might look like:
use std::env;
use std::process::Command;
use std::path::Path;
fn main() {
let out_dir = env::var_os("OUT_DIR").unwrap();
let viewer_dir = env::var_os("DEP_LEGION_PROF_VIEWER_SOURCE").unwrap();
let dist_dir = Path::new(&out_dir).join("legion_prof_viewer_dist");
Command::new("trunk").args(["build", "--release", "--dist"]).arg(dist_dir).current_dir(viewer_dir).spawn().expect("Trunk failed");
// Rerun only when the build script or environment changes
println!("cargo::rerun-if-changed=build.rs");
println!("cargo::rerun-if-env-changed=DEP_LEGION_PROF_VIEWER_SOURCE");
}
This does actually work, aside from the fact that the Trunk build itself fails on macOS due to missing WASM target on Apple Clang.
See also the discussion here: https://users.rust-lang.org/t/how-to-bundle-a-dependency-as-a-wasm-blob/117794
This PR represents the first half of the work required to generate standalone archives with the profiler, where a user can load the archive directly on any webserver. This requires embedding the WASM blob produced by Trunk into the archive itself, which in turn requires embedding it in the code.
This version of the PR is intended to be used along with a
build.rs
script in the main Legion Prof implementation to actually runtrunk
. This PR only sets the variable so that it is accessible in the rest of the build.