Skip to content

Commit 312f91c

Browse files
authored
Fix web viewer feature flags (#8295)
1 parent 16f0309 commit 312f91c

File tree

5 files changed

+19
-8
lines changed

5 files changed

+19
-8
lines changed

crates/build/re_dev_tools/src/build_web_viewer/lib.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ pub fn build(
7474
debug_symbols: bool,
7575
target: Target,
7676
build_dir: &Utf8Path,
77+
no_default_features: bool,
7778
features: &String,
7879
) -> anyhow::Result<()> {
7980
std::env::set_current_dir(workspace_root())?;
@@ -118,9 +119,13 @@ pub fn build(
118119
"--lib",
119120
"--target=wasm32-unknown-unknown",
120121
&format!("--target-dir={}", target_wasm_dir.as_str()),
121-
"--no-default-features",
122-
&format!("--features={features}"),
123122
]);
123+
if no_default_features {
124+
cmd.arg("--no-default-features");
125+
}
126+
if !features.is_empty() {
127+
cmd.arg(&format!("--features={features}"));
128+
}
124129
if profile == Profile::Release {
125130
cmd.arg("--release");
126131
}

crates/build/re_dev_tools/src/build_web_viewer/mod.rs

+5
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ pub struct Args {
3838
/// comma-separated list of features to pass on to `re_viewer`
3939
#[argh(option, short = 'F', long = "features", default = "default_features()")]
4040
features: String,
41+
42+
/// whether to exclude default features from `re_viewer` wasm build
43+
#[argh(switch, long = "no-default-features")]
44+
no_default_features: bool,
4145
}
4246

4347
fn default_features() -> String {
@@ -62,6 +66,7 @@ pub fn main(args: Args) -> anyhow::Result<()> {
6266
args.debug_symbols,
6367
args.target,
6468
&build_dir,
69+
args.no_default_features,
6570
&args.features,
6671
)
6772
}

crates/viewer/re_viewer/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ crate-type = ["cdylib", "rlib"]
3232

3333

3434
[features]
35-
default = ["analytics"]
35+
default = ["analytics", "map_view"]
3636

3737
## Enable telemetry using our analytics SDK.
3838
analytics = ["dep:re_analytics"]

pixi.toml

+4-4
Original file line numberDiff line numberDiff line change
@@ -175,29 +175,29 @@ rerun-web = { cmd = "cargo run --package rerun-cli --no-default-features --featu
175175
#
176176
# This installs the `wasm32-unknown-unknown` rust target if it's not already installed.
177177
# (this looks heavy but takes typically below 0.1s!)
178-
rerun-build-web = "rustup target add wasm32-unknown-unknown && cargo run -p re_dev_tools -- build-web-viewer --features analytics,grpc --debug"
178+
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"
179179

180180
# Compile the web-viewer wasm and the cli.
181181
#
182182
# This installs the `wasm32-unknown-unknown` rust target if it's not already installed.
183183
# (this looks heavy but takes typically below 0.1s!)
184-
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"
184+
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"
185185

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

196196
# Compile the web-viewer wasm in release mode.
197197
#
198198
# This installs the `wasm32-unknown-unknown` rust target if it's not already installed.
199199
# (this looks heavy but takes typically below 0.1s!)
200-
rerun-build-web-release = "rustup target add wasm32-unknown-unknown && cargo run -p re_dev_tools -- build-web-viewer --features analytics,grpc --release -g"
200+
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"
201201

202202
rs-check = { cmd = "rustup target add wasm32-unknown-unknown && python scripts/ci/rust_checks.py", depends_on = [
203203
"rerun-build-web", # The checks require the web viewer wasm to be around.

rerun_js/web-viewer/build-wasm.mjs

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ function buildWebViewer(mode) {
3131
"cargo run -p re_dev_tools -- build-web-viewer",
3232
modeFlags,
3333
"--target no-modules-base",
34-
"--features grpc",
34+
"--no-default-features",
35+
"--features grpc,map_view", // no `analytics`
3536
"-o rerun_js/web-viewer",
3637
].join(" "),
3738
);

0 commit comments

Comments
 (0)