Skip to content

Commit

Permalink
Fix web viewer feature flags (#8295)
Browse files Browse the repository at this point in the history
  • Loading branch information
jprochazk authored Dec 3, 2024
1 parent 16f0309 commit 312f91c
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 8 deletions.
9 changes: 7 additions & 2 deletions crates/build/re_dev_tools/src/build_web_viewer/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ pub fn build(
debug_symbols: bool,
target: Target,
build_dir: &Utf8Path,
no_default_features: bool,
features: &String,
) -> anyhow::Result<()> {
std::env::set_current_dir(workspace_root())?;
Expand Down Expand Up @@ -118,9 +119,13 @@ pub fn build(
"--lib",
"--target=wasm32-unknown-unknown",
&format!("--target-dir={}", target_wasm_dir.as_str()),
"--no-default-features",
&format!("--features={features}"),
]);
if no_default_features {
cmd.arg("--no-default-features");
}
if !features.is_empty() {
cmd.arg(&format!("--features={features}"));
}
if profile == Profile::Release {
cmd.arg("--release");
}
Expand Down
5 changes: 5 additions & 0 deletions crates/build/re_dev_tools/src/build_web_viewer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ pub struct Args {
/// comma-separated list of features to pass on to `re_viewer`
#[argh(option, short = 'F', long = "features", default = "default_features()")]
features: String,

/// whether to exclude default features from `re_viewer` wasm build
#[argh(switch, long = "no-default-features")]
no_default_features: bool,
}

fn default_features() -> String {
Expand All @@ -62,6 +66,7 @@ pub fn main(args: Args) -> anyhow::Result<()> {
args.debug_symbols,
args.target,
&build_dir,
args.no_default_features,
&args.features,
)
}
2 changes: 1 addition & 1 deletion crates/viewer/re_viewer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ crate-type = ["cdylib", "rlib"]


[features]
default = ["analytics"]
default = ["analytics", "map_view"]

## Enable telemetry using our analytics SDK.
analytics = ["dep:re_analytics"]
Expand Down
8 changes: 4 additions & 4 deletions pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -175,29 +175,29 @@ rerun-web = { cmd = "cargo run --package rerun-cli --no-default-features --featu
#
# This installs the `wasm32-unknown-unknown` rust target if it's not already installed.
# (this looks heavy but takes typically below 0.1s!)
rerun-build-web = "rustup target add wasm32-unknown-unknown && cargo run -p re_dev_tools -- build-web-viewer --features analytics,grpc --debug"
rerun-build-web = "rustup target add wasm32-unknown-unknown && cargo run -p re_dev_tools -- build-web-viewer --no-default-features --features analytics,grpc,map_view --debug"

# Compile the web-viewer wasm and the cli.
#
# This installs the `wasm32-unknown-unknown` rust target if it's not already installed.
# (this looks heavy but takes typically below 0.1s!)
rerun-build-web-cli = "rustup target add wasm32-unknown-unknown && cargo run -p re_dev_tools -- build-web-viewer --features analytics,grpc --debug && cargo build --package rerun-cli --no-default-features --features web_viewer"
rerun-build-web-cli = "rustup target add wasm32-unknown-unknown && cargo run -p re_dev_tools -- build-web-viewer --no-default-features --features analytics,grpc,map_view --debug && cargo build --package rerun-cli --no-default-features --features web_viewer"

# Compile and run the web-viewer in release mode via rerun-cli.
#
# You can also give an argument for what to view (e.g. an .rrd file).
#
# This installs the `wasm32-unknown-unknown` rust target if it's not already installed.
# (this looks heavy but takes typically below 0.1s!)
rerun-web-release = { cmd = "cargo run --package rerun-cli --no-default-features --features web_viewer --release -- --web-viewer", depends_on = [
rerun-web-release = { cmd = "cargo run --package rerun-cli --no-default-features --features web_viewer,map_view,grpc --release -- --web-viewer", depends_on = [
"rerun-build-web-release",
] }

# Compile the web-viewer wasm in release mode.
#
# This installs the `wasm32-unknown-unknown` rust target if it's not already installed.
# (this looks heavy but takes typically below 0.1s!)
rerun-build-web-release = "rustup target add wasm32-unknown-unknown && cargo run -p re_dev_tools -- build-web-viewer --features analytics,grpc --release -g"
rerun-build-web-release = "rustup target add wasm32-unknown-unknown && cargo run -p re_dev_tools -- build-web-viewer --no-default-features --features analytics,grpc,map_view --release -g"

rs-check = { cmd = "rustup target add wasm32-unknown-unknown && python scripts/ci/rust_checks.py", depends_on = [
"rerun-build-web", # The checks require the web viewer wasm to be around.
Expand Down
3 changes: 2 additions & 1 deletion rerun_js/web-viewer/build-wasm.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ function buildWebViewer(mode) {
"cargo run -p re_dev_tools -- build-web-viewer",
modeFlags,
"--target no-modules-base",
"--features grpc",
"--no-default-features",
"--features grpc,map_view", // no `analytics`
"-o rerun_js/web-viewer",
].join(" "),
);
Expand Down

0 comments on commit 312f91c

Please sign in to comment.