Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standalone mode for viewer (embedded build) #64

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

elliottslaughter
Copy link
Contributor

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 run trunk. This PR only sets the variable so that it is accessible in the rest of the build.

@elliottslaughter elliottslaughter changed the title Standalone mode for viewer Standalone mode for viewer (embedded build) Sep 19, 2024
@elliottslaughter
Copy link
Contributor Author

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.

@elliottslaughter
Copy link
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant