Skip to content

Commit

Permalink
Remove native_viewer from the default features of rerun crate
Browse files Browse the repository at this point in the history
Closes #1997

Most of our users only use the `rerun` library as a logging library
but are still paying the cost of compiling the native viewer.

With this PR, the `rerun` crate will not have the `native_viewer`
(not `web_viewer`) feature on by default. This halves the compilation
time on my computer.

The `native_viewer` feature is only for users using the `show`
or `spawn` features, which will hopefully be removed soon anyay:
* #2109

To install the `rerun` binary with `native_viewer` and `web_viewer`,
you now have to run `cargo install rerun --features binary`.
This will be improved by:
* #2108

To make things nicer for us developers, I've added `cargo rerun` as a
shorthand for compiling and running `rerun` with the `native_viewer`
feature, but NOT the `web_viewer` feature.
  • Loading branch information
emilk committed May 20, 2023
1 parent 8620892 commit d5fc78d
Show file tree
Hide file tree
Showing 14 changed files with 40 additions and 21 deletions.
3 changes: 3 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
[alias]
# `cargo rerun` is short a convenient shorthand
rerun = "run --package rerun --features native_viewer --features server --"

# To easily run examples on the web, see https://github.com/rukai/cargo-run-wasm.
# Temporary solution while we wait for our own xtasks!
run-wasm = "run --release --package run_wasm --"
Expand Down
3 changes: 3 additions & 0 deletions BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ This is a guide to how to build Rerun.
* Run `./scripts/setup_dev.sh`.
* Make sure `cargo --version` prints `1.69.0` once you are done

You should now be able run our Rust examples, e.g. with `cargo run -p dna`.

You can type `cargo rerun` to compile and run the `rerun` binary with most features enabled, thanks to a shortcut in `.cargo/config.toml`.

### Apple-silicon Macs

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ rr.log_rect("car", bbox)
### Rerun Viewer binary
Both the Python and Rust library can start the Rerun Viewer, but to stream log data over the network or load our `.rrd` data files you also need the `rerun` binary.

It can be installed with `pip install rerun-sdk` or with `cargo install rerun`.
It can be installed with `pip install rerun-sdk` or with `cargo install rerun --features binary`.

You should now be able to run `rerun --help` in any terminal.

Expand Down
18 changes: 8 additions & 10 deletions crates/rerun/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,13 @@ targets = ["x86_64-unknown-linux-gnu", "wasm32-unknown-unknown"]


[features]
default = [
"analytics",
"demo",
"glam",
"image",
"native_viewer",
"server",
"sdk",
]
default = ["library"]

## Default features when using `rerun` as a binary. Everything included.
binary = ["library", "native_viewer", "server", "web_viewer"]

## Default features when using `rerun` as a logging library. Optimized for compilation speed.
library = ["analytics", "demo", "glam", "image", "sdk", "server"]

## Enable telemetry using our analytics SDK.
analytics = [
Expand All @@ -52,7 +50,7 @@ image = ["re_log_types/image", "re_sdk?/image"]
## This adds a lot of extra dependencies, so only enable this feature if you need it!
native_viewer = ["dep:re_viewer"]

## Support for running a HTTP server that listens to incoming log messages from a Rerun SDK.
## Support for running a TCP server that listens to incoming log messages from a Rerun SDK.
server = ["re_sdk_comms/server"]

## Embed the Rerun SDK and re-export all of its public symbols.
Expand Down
2 changes: 1 addition & 1 deletion crates/rerun/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ You can add the `rerun` crate to your project with `cargo add rerun`.
To get started, see [the examples](https://github.com/rerun-io/rerun/tree/latest/examples/rust).
## Binary
You can install the binary with `cargo install rerun`
You can install the binary with `cargo install rerun --features binary`
This can act either as a server, a viewer, or both, depending on which options you use when you start it.
Expand Down
2 changes: 1 addition & 1 deletion crates/rerun/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//! There is also a `rerun` binary.
//! The binary is required in order to stream log data
//! over the networks, and to open our `.rrd` data files.
//! If you need it, install the `rerun` binary with `cargo install rerun`.
//! If you need it, install the `rerun` binary with `cargo install rerun --features binary`.
//!
//! ## Feature flags
#![doc = document_features::document_features!()]
Expand Down
2 changes: 1 addition & 1 deletion crates/rerun/src/web_viewer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ impl crate::sink::LogSink for WebViewerSink {
/// If the `open_browser` argument is `true`, your default browser
/// will be opened with a connected web-viewer.
///
/// If not, you can connect to this server using the `rerun` binary (`cargo install rerun`).
/// If not, you can connect to this server using the `rerun` binary (`cargo install rerun --features binary`).
///
/// NOTE: you can not connect one `Session` to another.
///
Expand Down
5 changes: 4 additions & 1 deletion examples/rust/api_demo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ license = "MIT OR Apache-2.0"
publish = false

[dependencies]
rerun = { path = "../../../crates/rerun", features = ["web_viewer"] }
rerun = { path = "../../../crates/rerun", features = [
"native_viewer",
"web_viewer",
] }

anyhow = "1.0"
clap = { version = "4.0", features = ["derive"] }
Expand Down
5 changes: 4 additions & 1 deletion examples/rust/clock/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ license = "MIT OR Apache-2.0"
publish = false

[dependencies]
rerun = { path = "../../../crates/rerun", features = ["web_viewer"] }
rerun = { path = "../../../crates/rerun", features = [
"native_viewer",
"web_viewer",
] }

anyhow = "1.0"
clap = { version = "4.0", features = ["derive"] }
Expand Down
2 changes: 1 addition & 1 deletion examples/rust/dna/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ license = "MIT OR Apache-2.0"
publish = false

[dependencies]
rerun = { path = "../../../crates/rerun", features = ["web_viewer"] }
rerun = { path = "../../../crates/rerun", features = ["native_viewer"] }

itertools = "0.10"
rand = "0.8"
2 changes: 1 addition & 1 deletion examples/rust/minimal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ license = "MIT OR Apache-2.0"
publish = false

[dependencies]
rerun = { path = "../../../crates/rerun" }
rerun = { path = "../../../crates/rerun", features = ["native_viewer"] }
5 changes: 4 additions & 1 deletion examples/rust/minimal_options/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ license = "MIT OR Apache-2.0"
publish = false

[dependencies]
rerun = { path = "../../../crates/rerun", features = ["web_viewer"] }
rerun = { path = "../../../crates/rerun", features = [
"native_viewer",
"web_viewer",
] }

anyhow = "1.0"
clap = { version = "4.0", features = ["derive"] }
Expand Down
5 changes: 4 additions & 1 deletion examples/rust/objectron/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ publish = false


[dependencies]
rerun = { path = "../../../crates/rerun", features = ["web_viewer"] }
rerun = { path = "../../../crates/rerun", features = [
"native_viewer",
"web_viewer",
] }

anyhow = "1.0"
clap = { version = "4.0", features = ["derive"] }
Expand Down
5 changes: 4 additions & 1 deletion examples/rust/raw_mesh/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ license = "MIT OR Apache-2.0"
publish = false

[dependencies]
rerun = { path = "../../../crates/rerun", features = ["web_viewer"] }
rerun = { path = "../../../crates/rerun", features = [
"native_viewer",
"web_viewer",
] }

anyhow = "1.0"
bytes = "1.3"
Expand Down

0 comments on commit d5fc78d

Please sign in to comment.