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

Fix web viewer feature flags #8295

Merged
merged 9 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
Comment on lines +178 to +200
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't easier to keep the default features and just add on grpc?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to be more explicit here, because you're not going to type the long command


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`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is for the NPM package, we don't want users' applications which embed the web viewer this way to send analytics to us. they will only do that if they embed the web viewer as an iframe

"-o rerun_js/web-viewer",
].join(" "),
);
Expand Down
Loading