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 4 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
7 changes: 6 additions & 1 deletion 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,7 +119,11 @@ pub fn build(
"--lib",
"--target=wasm32-unknown-unknown",
&format!("--target-dir={}", target_wasm_dir.as_str()),
"--no-default-features",
if no_default_features {
"--no-default-features"
} else {
""
},
&format!("--features={features}"),
]);
if profile == Profile::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(option, long = "no-default-features", default = "false")]
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,
)
}
6 changes: 3 additions & 3 deletions pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,13 @@ 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 --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 --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.
#
Expand All @@ -197,7 +197,7 @@ rerun-web-release = { cmd = "cargo run --package rerun-cli --no-default-features
#
# 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 --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",
Copy link
Member

Choose a reason for hiding this comment

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

I suggest we have a release = ["grpc", "map_view"] feature in re_viewer instead. It feels like a more discoverable location for controlling what goes into the release.

Suggested change
"--features grpc,map_view",
"--features release",

Copy link
Member Author

@jprochazk jprochazk Dec 3, 2024

Choose a reason for hiding this comment

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

At this point I just made map_view a default feature. I don't agree with the release feature for web viewer specifically, it makes sense for rerun-cli because there it makes it possible for it to be compiled without nasm, and with -F release in case you do want nasm.

Copy link
Member Author

@jprochazk jprochazk Dec 3, 2024

Choose a reason for hiding this comment

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

The big problem here imho was build_web_viewer silently passing --no-default-features to the re_viewer build

Copy link
Member

Choose a reason for hiding this comment

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

Makes sense 👍

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