diff --git a/.github/workflows/reusable_build_and_upload_rerun_cli.yml b/.github/workflows/reusable_build_and_upload_rerun_cli.yml index a06ab82946c5..35e98d6839b3 100644 --- a/.github/workflows/reusable_build_and_upload_rerun_cli.yml +++ b/.github/workflows/reusable_build_and_upload_rerun_cli.yml @@ -166,9 +166,7 @@ jobs: pixi-version: v0.19.0 - name: Build web-viewer (release) - shell: bash - run: | - pixi run cargo run --locked -p re_build_web_viewer -- --release -g + run: pixi run rerun-build-web-release # This does not run in the pixi environment, doing so # causes it to select the wrong compiler on macos-arm64 diff --git a/.github/workflows/reusable_build_web.yml b/.github/workflows/reusable_build_web.yml index 34127757b4f5..e1f8a863fedd 100644 --- a/.github/workflows/reusable_build_web.yml +++ b/.github/workflows/reusable_build_web.yml @@ -71,7 +71,7 @@ jobs: if [ ${{ inputs.CHANNEL }} = "nightly" ]; then export DEFAULT_EXAMPLES_MANIFEST_URL="https://app.rerun.io/version/nightly/examples_manifest.json" fi - pixi run cargo run --locked -p re_build_web_viewer -- --release -g + pixi run rerun-build-web-release # We build a single manifest pointing to the `commit` # All the `pr`, `main`, release tag, etc. variants will always just point to the resolved commit diff --git a/.github/workflows/reusable_checks_rust.yml b/.github/workflows/reusable_checks_rust.yml index 1fe8ade91dbd..575cb403e997 100644 --- a/.github/workflows/reusable_checks_rust.yml +++ b/.github/workflows/reusable_checks_rust.yml @@ -65,9 +65,7 @@ jobs: # We need to build the web viewer for `rust_checks.py` to succeed. # We build in release so that we can reuse the results for actual publishing, if necessary - name: Build web-viewer (release) - shell: bash - run: | - pixi run cargo run --locked -p re_build_web_viewer -- --release -g + run: pixi run rerun-build-web-release - name: Rust checks & tests if: ${{ inputs.CHANNEL == 'pr' }} diff --git a/.github/workflows/reusable_publish_web.yml b/.github/workflows/reusable_publish_web.yml index f6078aaa7911..5ef2daadd9f8 100644 --- a/.github/workflows/reusable_publish_web.yml +++ b/.github/workflows/reusable_publish_web.yml @@ -108,7 +108,7 @@ jobs: - name: Build web-viewer (release) shell: bash run: | - pixi -e wheel-test run cargo run --locked -p re_build_web_viewer -- --release -g + pixi -e wheel-test run rerun-build-web-release - name: Build examples shell: bash diff --git a/.github/workflows/reusable_release_crates.yml b/.github/workflows/reusable_release_crates.yml index 669e1fc12f0f..63ad82f3bed1 100644 --- a/.github/workflows/reusable_release_crates.yml +++ b/.github/workflows/reusable_release_crates.yml @@ -29,7 +29,7 @@ jobs: pixi-version: v0.19.0 - name: Build web-viewer (release) - run: pixi run cargo run --locked -p re_build_web_viewer -- --release -g + run: pixi run rerun-build-web-release - name: Publish run: pixi run python scripts/ci/crates.py publish --token ${{ secrets.CRATES_IO_TOKEN }} diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md index 3c2f5a8511bd..af6ab630813c 100644 --- a/ARCHITECTURE.md +++ b/ARCHITECTURE.md @@ -176,14 +176,12 @@ Update instructions: ### Build support -| Crate | Description | -|----------------------------|---------------------------------------------------------------| -| re_build_info | Information about the build. Use together with re_build_tools | -| re_build_tools | build.rs helpers for generating build info | -| re_types_builder | Generates code for Rerun's SDKs from flatbuffers definitions. | -| re_build_examples | Build rerun example RRD files and manifest | -| re_build_search_index | Build a Meilisearch index from all our documentation | -| re_build_web_viewer | Build the rerun web-viewer Wasm from source | +| Crate | Description | +|----------------------------|------------------------------------------------------------------| +| re_build_info | Information about the build. Use together with re_build_tools | +| re_build_tools | build.rs helpers for generating build info | +| re_types_builder | Generates code for Rerun's SDKs from flatbuffers definitions. | +| re_dev_tools | Various tools for Rerun development. Each tool has a subcommand. | ### Utilities diff --git a/Cargo.lock b/Cargo.lock index 5eddcb0ff171..36b29ac7242e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4196,50 +4196,10 @@ dependencies = [ "simdutf8", ] -[[package]] -name = "re_build_examples" -version = "0.16.0-alpha.1+dev" -dependencies = [ - "anyhow", - "argh", - "indicatif", - "rayon", - "re_build_tools", - "re_format", - "serde", - "serde_json", - "toml", -] - [[package]] name = "re_build_info" version = "0.16.0-alpha.1+dev" -[[package]] -name = "re_build_search_index" -version = "0.16.0-alpha.1+dev" -dependencies = [ - "anyhow", - "argh", - "camino", - "cargo_metadata 0.18.1", - "glob", - "indicatif", - "itertools 0.12.0", - "rayon", - "re_build_examples", - "re_build_tools", - "roxmltree", - "rustdoc-json", - "rustdoc-types", - "serde", - "serde_json", - "serde_yaml", - "toml", - "ureq", - "url", -] - [[package]] name = "re_build_tools" version = "0.16.0-alpha.1+dev" @@ -4253,16 +4213,6 @@ dependencies = [ "walkdir", ] -[[package]] -name = "re_build_web_viewer" -version = "0.16.0-alpha.1+dev" -dependencies = [ - "anyhow", - "cargo_metadata 0.18.1", - "re_error", - "wasm-bindgen-cli-support", -] - [[package]] name = "re_crash_handler" version = "0.16.0-alpha.1+dev" @@ -4358,6 +4308,32 @@ dependencies = [ "rfd", ] +[[package]] +name = "re_dev_tools" +version = "0.16.0-alpha.1+dev" +dependencies = [ + "anyhow", + "argh", + "camino", + "cargo_metadata 0.18.1", + "glob", + "indicatif", + "itertools 0.12.0", + "rayon", + "re_build_tools", + "re_format", + "roxmltree", + "rustdoc-json", + "rustdoc-types", + "serde", + "serde_json", + "serde_yaml", + "toml", + "ureq", + "url", + "wasm-bindgen-cli-support", +] + [[package]] name = "re_entity_db" version = "0.16.0-alpha.1+dev" diff --git a/Cargo.toml b/Cargo.toml index 3fc940776264..e0789da88ba3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,15 +29,13 @@ version = "0.16.0-alpha.1+dev" # In particular: if we compile rerun 0.3.0-alpha.0 we only want it to use # re_log_types 0.3.0-alpha.0, NOT 0.3.0-alpha.4 even though it is newer and semver-compatible. re_analytics = { path = "crates/re_analytics", version = "=0.16.0-alpha.1", default-features = false } -re_build_search_index = { path = "crates/re_build_search_index", version = "=0.16.0-alpha.1", default-features = false } -re_build_examples = { path = "crates/re_build_examples", version = "=0.16.0-alpha.1", default-features = false } re_build_info = { path = "crates/re_build_info", version = "=0.16.0-alpha.1", default-features = false } re_build_tools = { path = "crates/re_build_tools", version = "=0.16.0-alpha.1", default-features = false } -re_build_web_viewer = { path = "crates/re_build_web_viewer", version = "=0.16.0-alpha.1", default-features = false } re_crash_handler = { path = "crates/re_crash_handler", version = "=0.16.0-alpha.1", default-features = false } re_data_source = { path = "crates/re_data_source", version = "=0.16.0-alpha.1", default-features = false } re_data_store = { path = "crates/re_data_store", version = "=0.16.0-alpha.1", default-features = false } re_data_ui = { path = "crates/re_data_ui", version = "=0.16.0-alpha.1", default-features = false } +re_dev_tools = { path = "crates/re_dev_tools", version = "=0.16.0-alpha.1", default-features = false } re_entity_db = { path = "crates/re_entity_db", version = "=0.16.0-alpha.1", default-features = false } re_error = { path = "crates/re_error", version = "=0.16.0-alpha.1", default-features = false } re_format = { path = "crates/re_format", version = "=0.16.0-alpha.1", default-features = false } @@ -47,9 +45,9 @@ re_log_encoding = { path = "crates/re_log_encoding", version = "=0.16.0-alpha.1" re_log_types = { path = "crates/re_log_types", version = "=0.16.0-alpha.1", default-features = false } re_memory = { path = "crates/re_memory", version = "=0.16.0-alpha.1", default-features = false } re_query = { path = "crates/re_query", version = "=0.16.0-alpha.1", default-features = false } -re_query2 = { path = "crates/re_query2", version = "=0.16.0-alpha.1", default-features = false } re_query_cache = { path = "crates/re_query_cache", version = "=0.16.0-alpha.1", default-features = false } re_query_cache2 = { path = "crates/re_query_cache2", version = "=0.16.0-alpha.1", default-features = false } +re_query2 = { path = "crates/re_query2", version = "=0.16.0-alpha.1", default-features = false } re_renderer = { path = "crates/re_renderer", version = "=0.16.0-alpha.1", default-features = false } re_sdk = { path = "crates/re_sdk", version = "=0.16.0-alpha.1", default-features = false } re_sdk_comms = { path = "crates/re_sdk_comms", version = "=0.16.0-alpha.1", default-features = false } diff --git a/crates/re_build_examples/Cargo.toml b/crates/re_build_examples/Cargo.toml deleted file mode 100644 index a2d0f8b12f04..000000000000 --- a/crates/re_build_examples/Cargo.toml +++ /dev/null @@ -1,30 +0,0 @@ -[package] -name = "re_build_examples" -authors.workspace = true -description = "Build rerun example RRD files" -edition.workspace = true -homepage.workspace = true -include.workspace = true -license.workspace = true -publish = false -readme = "README.md" -repository.workspace = true -rust-version.workspace = true -version.workspace = true - -[package.metadata.docs.rs] -all-features = true - - -[dependencies] -re_build_tools.workspace = true -re_format.workspace = true - -# External -anyhow.workspace = true -argh.workspace = true -indicatif.workspace = true -rayon.workspace = true -serde = { workspace = true, features = ["derive"] } -serde_json.workspace = true -toml = { workspace = true, features = ["parse", "preserve_order"] } diff --git a/crates/re_build_web_viewer/Cargo.toml b/crates/re_build_web_viewer/Cargo.toml deleted file mode 100644 index 1cf09c138a7d..000000000000 --- a/crates/re_build_web_viewer/Cargo.toml +++ /dev/null @@ -1,24 +0,0 @@ -[package] -name = "re_build_web_viewer" -authors.workspace = true -description = "Build the rerun web-viewer Wasm from source" -edition.workspace = true -homepage.workspace = true -include.workspace = true -license.workspace = true -publish = true -readme = "README.md" -repository.workspace = true -rust-version.workspace = true -version.workspace = true - -[package.metadata.docs.rs] -all-features = true - - -[dependencies] -re_error.workspace = true - -anyhow.workspace = true -cargo_metadata.workspace = true -wasm-bindgen-cli-support.workspace = true diff --git a/crates/re_build_web_viewer/src/main.rs b/crates/re_build_web_viewer/src/main.rs deleted file mode 100644 index f734d4097ef4..000000000000 --- a/crates/re_build_web_viewer/src/main.rs +++ /dev/null @@ -1,94 +0,0 @@ -use cargo_metadata::camino::Utf8PathBuf; -use re_build_web_viewer::{default_build_dir, Profile, Target}; -use std::process::ExitCode; - -struct Opts { - profile: Option, - debug_symbols: bool, - target: Target, - build_dir: Utf8PathBuf, -} - -impl Default for Opts { - fn default() -> Self { - Self { - profile: None, - debug_symbols: false, - target: Target::Browser, - build_dir: default_build_dir(), - } - } -} - -fn main() -> ExitCode { - let mut opts = Opts::default(); - - let mut args = std::env::args().skip(1); - while let Some(arg) = args.next() { - match arg.as_str() { - "--help" => { - print_help(); - return ExitCode::SUCCESS; - } - "--debug" => { - assert!( - opts.profile.is_none(), - "Can't set both --release and --debug" - ); - opts.profile = Some(Profile::Debug); - } - "--release" => { - assert!( - opts.profile.is_none(), - "Can't set both --release and --debug" - ); - opts.profile = Some(Profile::Release); - } - "-g" => { - opts.debug_symbols = true; - } - "-o" | "--out" => match args.next() { - Some(value) if !value.starts_with('-') => { - opts.build_dir = Utf8PathBuf::from(value); - } - _ => panic!("expected path after {arg}"), - }, - "--module" => { - opts.target = Target::Module; - } - _ => { - print_help(); - return ExitCode::FAILURE; - } - } - } - - let Some(release) = opts.profile else { - eprintln!("You need to pass either --debug or --release"); - return ExitCode::FAILURE; - }; - - if let Err(err) = - re_build_web_viewer::build(release, opts.debug_symbols, opts.target, &opts.build_dir) - { - eprintln!("Failed to build web viewer: {}", re_error::format(err)); - ExitCode::FAILURE - } else { - ExitCode::SUCCESS - } -} - -fn print_help() { - eprintln!( - r"Build the web-viewer. - - --help: Print this help text - --debug: Build a debug binary - --release: Compile for release, and run wasm-opt. - NOTE: --release also removes debug symbols which are otherwise useful for in-browser profiling. - -g: Keep debug symbols, even in release builds. - This gives better callstacks on panics, and also allows for in-browser profiling of the Wasm. - -o, --out: Set the output directory. This is a path relative to the cargo workspace root. -" - ); -} diff --git a/crates/re_build_search_index/Cargo.toml b/crates/re_dev_tools/Cargo.toml similarity index 86% rename from crates/re_build_search_index/Cargo.toml rename to crates/re_dev_tools/Cargo.toml index 5ea7f86fe1a1..d53eebfb2995 100644 --- a/crates/re_build_search_index/Cargo.toml +++ b/crates/re_dev_tools/Cargo.toml @@ -1,7 +1,7 @@ [package] -name = "re_build_search_index" +name = "re_dev_tools" authors.workspace = true -description = "Build a Meilisearch index from all of Rerun's documentation" +description = "Various tools for rerun development" edition.workspace = true homepage.workspace = true include.workspace = true @@ -17,8 +17,8 @@ all-features = true [dependencies] -re_build_examples.workspace = true re_build_tools.workspace = true +re_format.workspace = true # External anyhow.workspace = true @@ -28,8 +28,8 @@ cargo_metadata.workspace = true glob.workspace = true indicatif.workspace = true itertools.workspace = true -roxmltree = "0.19.0" rayon.workspace = true +roxmltree = "0.19.0" rustdoc-json = "0.8.8" rustdoc-types = "0.24.0" serde = { workspace = true, features = ["derive"] } @@ -38,3 +38,4 @@ serde_yaml.workspace = true toml = { workspace = true, features = ["parse", "preserve_order"] } ureq = { workspace = true, features = ["json"] } url.workspace = true +wasm-bindgen-cli-support.workspace = true diff --git a/crates/re_dev_tools/README.md b/crates/re_dev_tools/README.md new file mode 100644 index 000000000000..5fc1e4544695 --- /dev/null +++ b/crates/re_dev_tools/README.md @@ -0,0 +1,11 @@ +# re_dev_tools +Crate that combines several development utilities. +To get an overview over all tools run `pixi run dev-tools --help`. + +We keep all smaller rust "scripts" in this single crate so we don't needlessly +increase the number of such utility crates and to make it easy to get +an overview over all build tooling written in Rust. + +## Adding a new tool +* Create a folder under `src` with your new tool +* Add a new enum entry to `main.rs` diff --git a/crates/re_build_examples/src/example.rs b/crates/re_dev_tools/src/build_examples/example.rs similarity index 99% rename from crates/re_build_examples/src/example.rs rename to crates/re_dev_tools/src/build_examples/example.rs index 69f68b481705..6027510c5028 100644 --- a/crates/re_build_examples/src/example.rs +++ b/crates/re_dev_tools/src/build_examples/example.rs @@ -79,6 +79,7 @@ impl Example { pub enum Language { Rust, Python, + #[allow(dead_code)] C, Cpp, } diff --git a/crates/re_build_examples/src/manifest.rs b/crates/re_dev_tools/src/build_examples/manifest.rs similarity index 99% rename from crates/re_build_examples/src/manifest.rs rename to crates/re_dev_tools/src/build_examples/manifest.rs index 4ddd85ce8102..cb09f4714ebd 100644 --- a/crates/re_build_examples/src/manifest.rs +++ b/crates/re_dev_tools/src/build_examples/manifest.rs @@ -2,7 +2,7 @@ use std::path::PathBuf; use re_build_tools::Environment; -use crate::{Channel, Example}; +use super::{Channel, Example}; /// Collect examples in the repository and produce a manifest file. /// diff --git a/crates/re_build_examples/src/main.rs b/crates/re_dev_tools/src/build_examples/mod.rs similarity index 73% rename from crates/re_build_examples/src/main.rs rename to crates/re_dev_tools/src/build_examples/mod.rs index b4adb0725684..8addde805a61 100644 --- a/crates/re_build_examples/src/main.rs +++ b/crates/re_dev_tools/src/build_examples/mod.rs @@ -10,24 +10,25 @@ //! An example may also specify args to be run with via the frontmatter //! `build_args` string array. -pub use re_build_examples::*; +mod example; +mod manifest; +mod rrd; +mod snippets; +mod wait_for_output; -use argh::FromArgs; +use example::Channel; +use wait_for_output::wait_for_output; -fn main() -> anyhow::Result<()> { - re_build_tools::set_output_cargo_build_instructions(false); +pub use example::{Example, ExamplesManifest, Language}; - let args: Args = argh::from_env(); - match args.cmd { - Cmd::Rrd(cmd) => cmd.run(), - Cmd::Manifest(cmd) => cmd.run(), - Cmd::Snippets(cmd) => cmd.run(), - } -} +// ----------------------------------------------------------------------------- + +use argh::FromArgs; /// Build examples and their manifest. #[derive(FromArgs)] -struct Args { +#[argh(subcommand, name = "build-examples")] +pub struct Args { #[argh(subcommand)] cmd: Cmd, } @@ -39,3 +40,13 @@ enum Cmd { Manifest(manifest::Manifest), Snippets(snippets::Snippets), } + +pub fn main(args: Args) -> anyhow::Result<()> { + re_build_tools::set_output_cargo_build_instructions(false); + + match args.cmd { + Cmd::Rrd(cmd) => cmd.run(), + Cmd::Manifest(cmd) => cmd.run(), + Cmd::Snippets(cmd) => cmd.run(), + } +} diff --git a/crates/re_build_examples/src/rrd.rs b/crates/re_dev_tools/src/build_examples/rrd.rs similarity index 98% rename from crates/re_build_examples/src/rrd.rs rename to crates/re_dev_tools/src/build_examples/rrd.rs index efddf252d2d2..ef625cd6e161 100644 --- a/crates/re_build_examples/src/rrd.rs +++ b/crates/re_dev_tools/src/build_examples/rrd.rs @@ -1,5 +1,4 @@ -use crate::wait_for_output; -use crate::{Channel, Example}; +use super::{wait_for_output, Channel, Example}; use indicatif::MultiProgress; use rayon::prelude::IntoParallelIterator; use rayon::prelude::ParallelIterator; diff --git a/crates/re_build_examples/src/snippets.rs b/crates/re_dev_tools/src/build_examples/snippets.rs similarity index 99% rename from crates/re_build_examples/src/snippets.rs rename to crates/re_dev_tools/src/build_examples/snippets.rs index a75ed82f9f6c..d4ae335e0631 100644 --- a/crates/re_build_examples/src/snippets.rs +++ b/crates/re_dev_tools/src/build_examples/snippets.rs @@ -11,7 +11,7 @@ use indicatif::MultiProgress; use rayon::prelude::IntoParallelIterator; use rayon::prelude::ParallelIterator; -use crate::wait_for_output; +use super::wait_for_output; /// Collect code snippets from `docs/snippets` in the repository and run them to produce `.rrd` files. #[derive(argh::FromArgs)] diff --git a/crates/re_build_examples/src/lib.rs b/crates/re_dev_tools/src/build_examples/wait_for_output.rs similarity index 82% rename from crates/re_build_examples/src/lib.rs rename to crates/re_dev_tools/src/build_examples/wait_for_output.rs index 5f3784bdbdb6..ca809f49aa67 100644 --- a/crates/re_build_examples/src/lib.rs +++ b/crates/re_dev_tools/src/build_examples/wait_for_output.rs @@ -1,21 +1,13 @@ -//! Build rerun example RRD files and manifest - -pub mod example; -pub mod manifest; -pub mod rrd; -pub mod snippets; - use std::io::stdout; use std::io::IsTerminal; use std::process::Command; use std::process::Output; use std::time::Duration; -pub use example::{Channel, Example}; use indicatif::MultiProgress; use indicatif::ProgressBar; -fn wait_for_output( +pub fn wait_for_output( mut cmd: Command, name: &str, progress: &MultiProgress, diff --git a/crates/re_build_search_index/README.md b/crates/re_dev_tools/src/build_search_index/README.md similarity index 95% rename from crates/re_build_search_index/README.md rename to crates/re_dev_tools/src/build_search_index/README.md index cd86fc1b4cff..18c12860d796 100644 --- a/crates/re_build_search_index/README.md +++ b/crates/re_dev_tools/src/build_search_index/README.md @@ -1,4 +1,4 @@ -# re_build_search_index +# build_search_index Builds a Meilisearch index from our documentation. diff --git a/crates/re_build_search_index/src/build.rs b/crates/re_dev_tools/src/build_search_index/build.rs similarity index 94% rename from crates/re_build_search_index/src/build.rs rename to crates/re_dev_tools/src/build_search_index/build.rs index 24ce4b5e12d5..a2b57728289f 100644 --- a/crates/re_build_search_index/src/build.rs +++ b/crates/re_dev_tools/src/build_search_index/build.rs @@ -1,4 +1,4 @@ -use crate::{ingest, meili, DEFAULT_INDEX, DEFAULT_KEY, DEFAULT_URL}; +use super::{ingest, meili, DEFAULT_INDEX, DEFAULT_KEY, DEFAULT_URL}; /// Index documentation, examples, and API references for all languages #[derive(argh::FromArgs)] diff --git a/crates/re_build_search_index/src/ingest.rs b/crates/re_dev_tools/src/build_search_index/ingest.rs similarity index 100% rename from crates/re_build_search_index/src/ingest.rs rename to crates/re_dev_tools/src/build_search_index/ingest.rs diff --git a/crates/re_build_search_index/src/ingest/cpp.rs b/crates/re_dev_tools/src/build_search_index/ingest/cpp.rs similarity index 99% rename from crates/re_build_search_index/src/ingest/cpp.rs rename to crates/re_dev_tools/src/build_search_index/ingest/cpp.rs index c191279051f4..a9894a1f6ffb 100644 --- a/crates/re_build_search_index/src/ingest/cpp.rs +++ b/crates/re_dev_tools/src/build_search_index/ingest/cpp.rs @@ -10,7 +10,7 @@ use roxmltree::Descendants; use roxmltree::Document; use roxmltree::Node; -use crate::util::CommandExt as _; +use crate::build_search_index::util::CommandExt as _; use super::Context; use super::DocumentData; diff --git a/crates/re_build_search_index/src/ingest/docs.rs b/crates/re_dev_tools/src/build_search_index/ingest/docs.rs similarity index 100% rename from crates/re_build_search_index/src/ingest/docs.rs rename to crates/re_dev_tools/src/build_search_index/ingest/docs.rs diff --git a/crates/re_build_search_index/src/ingest/examples.rs b/crates/re_dev_tools/src/build_search_index/ingest/examples.rs similarity index 88% rename from crates/re_build_search_index/src/ingest/examples.rs rename to crates/re_dev_tools/src/build_search_index/ingest/examples.rs index 4688c1476347..680f0658109b 100644 --- a/crates/re_build_search_index/src/ingest/examples.rs +++ b/crates/re_dev_tools/src/build_search_index/ingest/examples.rs @@ -1,11 +1,6 @@ -use re_build_examples::example::ExamplesManifest; -use re_build_examples::example::Language; -use re_build_examples::Example; +use crate::build_examples::{Example, ExamplesManifest, Language}; -use crate::ingest::DocumentData; -use crate::ingest::DocumentKind; - -use super::Context; +use super::{Context, DocumentData, DocumentKind}; const LANGUAGES: &[Language] = &[Language::Python, Language::Rust, Language::Cpp]; diff --git a/crates/re_build_search_index/src/ingest/python.rs b/crates/re_dev_tools/src/build_search_index/ingest/python.rs similarity index 98% rename from crates/re_build_search_index/src/ingest/python.rs rename to crates/re_dev_tools/src/build_search_index/ingest/python.rs index bdbd6f863187..b3daba65e938 100644 --- a/crates/re_build_search_index/src/ingest/python.rs +++ b/crates/re_dev_tools/src/build_search_index/ingest/python.rs @@ -5,11 +5,9 @@ use std::process::Command; use anyhow::Context as _; use serde::Deserialize; -use crate::ingest::DocumentData; -use crate::ingest::DocumentKind; -use crate::util::CommandExt as _; +use crate::build_search_index::util::CommandExt as _; -use super::Context; +use super::{Context, DocumentData, DocumentKind}; const RERUN_SDK: &str = "rerun_sdk"; diff --git a/crates/re_build_search_index/src/ingest/rust.rs b/crates/re_dev_tools/src/build_search_index/ingest/rust.rs similarity index 100% rename from crates/re_build_search_index/src/ingest/rust.rs rename to crates/re_dev_tools/src/build_search_index/ingest/rust.rs diff --git a/crates/re_build_search_index/src/meili.rs b/crates/re_dev_tools/src/build_search_index/meili.rs similarity index 99% rename from crates/re_build_search_index/src/meili.rs rename to crates/re_dev_tools/src/build_search_index/meili.rs index ced580ff93b5..64a1d71ed890 100644 --- a/crates/re_build_search_index/src/meili.rs +++ b/crates/re_dev_tools/src/build_search_index/meili.rs @@ -3,7 +3,7 @@ use std::ops::ControlFlow; use anyhow::Context; use url::Url; -use crate::ingest::Document; +use super::ingest::Document; pub fn connect(url: &str, master_key: &str) -> anyhow::Result { SearchClient::connect(url, master_key) diff --git a/crates/re_build_search_index/src/main.rs b/crates/re_dev_tools/src/build_search_index/mod.rs similarity index 60% rename from crates/re_build_search_index/src/main.rs rename to crates/re_dev_tools/src/build_search_index/mod.rs index 162aaf00ade7..f174a12cf7b6 100644 --- a/crates/re_build_search_index/src/main.rs +++ b/crates/re_dev_tools/src/build_search_index/mod.rs @@ -7,30 +7,12 @@ mod meili; mod repl; mod util; -fn main() -> anyhow::Result<()> { - let args: Args = argh::from_env(); - - let Some(cmd) = args.cmd else { - let help_text = ::from_args(&["search-index"], &["--help"]) - .err() - .unwrap() - .output; - - eprintln!("{help_text}"); - return Ok(()); - }; - - match cmd { - Cmd::Repl(cmd) => cmd.run(), - Cmd::Build(cmd) => cmd.run(), - } -} - /// Meilisearch indexer and REPL #[derive(argh::FromArgs)] -struct Args { +#[argh(subcommand, name = "search-index")] +pub struct Args { #[argh(subcommand)] - cmd: Option, + cmd: Cmd, } #[derive(argh::FromArgs)] @@ -40,6 +22,13 @@ enum Cmd { Build(build::Build), } +pub fn main(args: Args) -> anyhow::Result<()> { + match args.cmd { + Cmd::Repl(cmd) => cmd.run(), + Cmd::Build(cmd) => cmd.run(), + } +} + const DEFAULT_URL: &str = "http://localhost:7700"; const DEFAULT_KEY: &str = "test"; const DEFAULT_INDEX: &str = "temp"; diff --git a/crates/re_build_search_index/src/repl.rs b/crates/re_dev_tools/src/build_search_index/repl.rs similarity index 96% rename from crates/re_build_search_index/src/repl.rs rename to crates/re_dev_tools/src/build_search_index/repl.rs index 77819c869515..21b064f0468d 100644 --- a/crates/re_build_search_index/src/repl.rs +++ b/crates/re_dev_tools/src/build_search_index/repl.rs @@ -1,5 +1,5 @@ -use crate::meili::SearchClient; -use crate::{ingest, meili, DEFAULT_INDEX, DEFAULT_KEY, DEFAULT_URL}; +use super::meili::SearchClient; +use super::{ingest, meili, DEFAULT_INDEX, DEFAULT_KEY, DEFAULT_URL}; use std::io::stdin; use std::io::stdout; diff --git a/crates/re_build_search_index/src/util.rs b/crates/re_dev_tools/src/build_search_index/util.rs similarity index 100% rename from crates/re_build_search_index/src/util.rs rename to crates/re_dev_tools/src/build_search_index/util.rs diff --git a/crates/re_build_web_viewer/README.md b/crates/re_dev_tools/src/build_web_viewer/README.md similarity index 51% rename from crates/re_build_web_viewer/README.md rename to crates/re_dev_tools/src/build_web_viewer/README.md index ca71944cbf2d..7d6f07ba9801 100644 --- a/crates/re_build_web_viewer/README.md +++ b/crates/re_dev_tools/src/build_web_viewer/README.md @@ -1,13 +1,13 @@ -# `re_build_web_viewer` +# `build_web_viewer` Binary and library for building the Rerun web viewer. This is also called by the `build.rs` of `re_web_viewer_server`. -``` -cargo r -p re_build_web_viewer -- --debug +```sh +pixi run dev-tools -- build-web-viewer ``` -``` -cargo r -p re_build_web_viewer -- --release -g +```sh +pixi run dev-tools -- build-web-viewer --release -g ``` diff --git a/crates/re_build_web_viewer/src/lib.rs b/crates/re_dev_tools/src/build_web_viewer/lib.rs similarity index 100% rename from crates/re_build_web_viewer/src/lib.rs rename to crates/re_dev_tools/src/build_web_viewer/lib.rs diff --git a/crates/re_dev_tools/src/build_web_viewer/mod.rs b/crates/re_dev_tools/src/build_web_viewer/mod.rs new file mode 100644 index 000000000000..0bc78827a32d --- /dev/null +++ b/crates/re_dev_tools/src/build_web_viewer/mod.rs @@ -0,0 +1,45 @@ +mod lib; + +use argh::FromArgs; +use cargo_metadata::camino::Utf8PathBuf; + +use lib::{build, default_build_dir, Profile, Target}; + +/// Build the web-viewer. +#[derive(FromArgs)] +#[argh(subcommand, name = "build-web-viewer")] +pub struct Args { + /// compile for release and run wasm-opt. + /// NOTE: --release also removes debug symbols which are otherwise useful for in-browser profiling. + #[argh(switch)] + release: bool, + + /// keep debug symbols, even in release builds. + /// This gives better callstacks on panics, and also allows for in-browser profiling of the Wasm. + #[argh(switch, short = 'g')] + debug_symbols: bool, + + /// if set, will build the module target instead of the browser target. + #[argh(switch)] + module: bool, + + /// set the output directory. This is a path relative to the cargo workspace root. + #[argh(option, short = 'o', long = "out")] + build_dir: Option, +} + +pub fn main(args: Args) -> anyhow::Result<()> { + let profile = if args.release { + Profile::Release + } else { + Profile::Debug + }; + let target = if args.module { + Target::Module + } else { + Target::Browser + }; + let build_dir = args.build_dir.unwrap_or_else(default_build_dir); + + build(profile, args.debug_symbols, target, &build_dir) +} diff --git a/crates/re_dev_tools/src/main.rs b/crates/re_dev_tools/src/main.rs new file mode 100644 index 000000000000..d2ba6dc5f5cb --- /dev/null +++ b/crates/re_dev_tools/src/main.rs @@ -0,0 +1,34 @@ +//! Crate that combines several development utilities. +//! +//! To get an overview over all tools run `pixi run dev-tools --help`. + +use argh::FromArgs; + +mod build_examples; +mod build_search_index; +mod build_web_viewer; + +#[derive(FromArgs)] +#[argh(subcommand)] +enum Commands { + BuildExamples(build_examples::Args), + BuildWebViewer(build_web_viewer::Args), + SearchIndex(build_search_index::Args), +} + +/// Various development tools for Rerun. +#[derive(FromArgs)] +struct TopLevel { + #[argh(subcommand)] + cmd: Commands, +} + +fn main() -> anyhow::Result<()> { + let args: TopLevel = argh::from_env(); + + match args.cmd { + Commands::BuildExamples(args) => build_examples::main(args), + Commands::SearchIndex(args) => build_search_index::main(args), + Commands::BuildWebViewer(args) => build_web_viewer::main(args), + } +} diff --git a/crates/re_web_viewer_server/Cargo.toml b/crates/re_web_viewer_server/Cargo.toml index 95248cde757e..da454704019f 100644 --- a/crates/re_web_viewer_server/Cargo.toml +++ b/crates/re_web_viewer_server/Cargo.toml @@ -36,7 +36,7 @@ all-features = true ## For instance: when the CI builds the docs for all crates, it uses `--all-features`, which means ## it can build the docs for this crate without having to build the web-viewer first. ## -## When not set, you must build the `.wasm` before building the crate, using `cargo run -p re_build_web_viewer`. +## When not set, you must build the `.wasm` before building the crate, using `pixi run rerun-build-web-release`. __ci = [] ## Enable telemetry using our analytics SDK. diff --git a/crates/re_web_viewer_server/README.md b/crates/re_web_viewer_server/README.md index 0fb29bef3da7..7ae7f9b849b6 100644 --- a/crates/re_web_viewer_server/README.md +++ b/crates/re_web_viewer_server/README.md @@ -9,5 +9,5 @@ Part of the [`rerun`](https://github.com/rerun-io/rerun) family of crates. Serves the Rerun web viewer (`re_viewer` as Wasm and HTML) over HTTP. -When developing, you must run `cargo r -p re_build_web_viewer -- --debug` (or `--release`), before building this package. +When developing, you must run `pixi run rerun-build-web` (or `pixi run rerun-build-web-release`), before building this package. This is done automatically with `pixi run rerun-web`. diff --git a/docs/snippets/snippets.toml b/docs/snippets/snippets.toml index 7f918fa81cf6..9ccb452f5d2e 100644 --- a/docs/snippets/snippets.toml +++ b/docs/snippets/snippets.toml @@ -1,4 +1,4 @@ -# This file is read in `compare_snippet_output.py` and the `snippets` command in `re_build_examples`. +# This file is read in `compare_snippet_output.py` and the `snippets` command in `re_dev_tools`/`build_examples`. # These entries won't run at all. # diff --git a/pixi.toml b/pixi.toml index 45194fb82a20..5a9242e032a4 100644 --- a/pixi.toml +++ b/pixi.toml @@ -56,13 +56,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_build_web_viewer -- --debug" +rerun-build-web = "rustup target add wasm32-unknown-unknown && cargo run -p re_dev_tools -- build-web-viewer --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_build_web_viewer -- --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 --debug && cargo build --package rerun-cli --no-default-features --features web_viewer" # Compile and run the web-viewer in release mode via rerun-cli. # @@ -78,12 +78,10 @@ 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_build_web_viewer -- --release -g" +rerun-build-web-release = "rustup target add wasm32-unknown-unknown && cargo run -p re_dev_tools -- build-web-viewer --release -g" rs-check = "rustup target add wasm32-unknown-unknown && python scripts/ci/rust_checks.py" -build-examples = "cargo run -q --locked -p re_build_examples --" - # Code formatting for all languages. format = { depends_on = ["py-fmt", "cpp-fmt", "toml-fmt", "misc-fmt"] } fmt = { depends_on = ["format"] } @@ -137,9 +135,12 @@ py-plot-dashboard = { cmd = "python tests/python/plot_dashboard_stress/main.py", ] } rs-plot-dashboard = { cmd = "cargo r -p plot_dashboard_stress --release --" } +dev-tools = "cargo run -q --locked -p re_dev_tools --" +build-examples = "cargo run -q --locked -p re_dev_tools -- build-examples" + # Build the documentation search index. # See `pixi run search-index --help` for more information. -search-index = "cargo run -p re_build_search_index --release --" +search-index = "cargo run -q --locked -p re_dev_tools -- search-index" # Start a local meilisearch instance at `localhost:7700` with master key `test`. # This should only be used for testing the search index locally. diff --git a/rerun_cpp/docs/Doxyfile b/rerun_cpp/docs/Doxyfile index d44f1a409476..9b9e39fcb46d 100644 --- a/rerun_cpp/docs/Doxyfile +++ b/rerun_cpp/docs/Doxyfile @@ -1773,7 +1773,7 @@ GENERATE_MAN = NO # captures the structure of the code including all documentation. # The default value is: NO. -GENERATE_XML = YES # Generated files are used in `re_build_search_index` +GENERATE_XML = YES # Generated files are used in `build_search_index` #--------------------------------------------------------------------------- # Configuration options related to the DOCBOOK output diff --git a/rerun_js/web-viewer/package.json b/rerun_js/web-viewer/package.json index 534416d3eca3..2c67800b8ea5 100644 --- a/rerun_js/web-viewer/package.json +++ b/rerun_js/web-viewer/package.json @@ -11,8 +11,8 @@ } ], "scripts": { - "build:wasm": "cargo run -p re_build_web_viewer -- --release -g --module -o rerun_js/web-viewer", - "build:wasm:debug": "cargo run -p re_build_web_viewer -- --debug --module -o rerun_js/web-viewer", + "build:wasm": "cargo run -p re_dev_tools -- build-web-viewer --release -g --module -o rerun_js/web-viewer", + "build:wasm:debug": "cargo run -p re_dev_tools -- build-web-viewer --module -o rerun_js/web-viewer", "build:types": "tsc --noEmit && dts-buddy", "build": "npm run build:wasm && npm run build:types" }, @@ -53,4 +53,4 @@ "dts-buddy": "^0.3.0", "typescript": "^5.2.2" } -} \ No newline at end of file +} diff --git a/rerun_py/docs/gen_common_index.py b/rerun_py/docs/gen_common_index.py index 2c1cca4fbaf8..51d3ad70af7d 100755 --- a/rerun_py/docs/gen_common_index.py +++ b/rerun_py/docs/gen_common_index.py @@ -2,7 +2,7 @@ """ Generate an index table and rendered pages for the common APIs. -NOTE: When changing anything in this file, also consider how it affects `re_build_search_index/src/ingest/python.rs`. +NOTE: When changing anything in this file, also consider how it affects `crates/re_dev_tools/src/build_search_index/ingest/python.rs`. The top-level index file should look like ``` diff --git a/scripts/ci/build_and_upload_wheels.py b/scripts/ci/build_and_upload_wheels.py index 147de0453906..d2c681350ffb 100755 --- a/scripts/ci/build_and_upload_wheels.py +++ b/scripts/ci/build_and_upload_wheels.py @@ -65,7 +65,7 @@ def __str__(self) -> str: def build_and_upload(bucket: Bucket, mode: BuildMode, gcs_dir: str, target: str, compatibility: str) -> None: if mode is BuildMode.PYPI: # Only build web viewer when publishing to pypi - run("pixi run cargo run --quiet --locked -p re_build_web_viewer -- --release -g") + run("pixi run rerun-build-web-release") maturin_feature_flags = "--no-default-features --features pypi" elif mode is BuildMode.PR: maturin_feature_flags = "--no-default-features --features extension-module" diff --git a/scripts/screenshot_compare/build_screenshot_compare.py b/scripts/screenshot_compare/build_screenshot_compare.py index 9a485efaa81b..2b5cebd3175d 100755 --- a/scripts/screenshot_compare/build_screenshot_compare.py +++ b/scripts/screenshot_compare/build_screenshot_compare.py @@ -8,7 +8,7 @@ - The screenshots listed in .fbs files (crates/re_types/definitions/rerun/**/*.fbs), and the corresponding snippets in the docs (docs/snippets/*.rs) -- The `rerun.io/viewer` examples, as built by the `re_build_examples` script. +- The `rerun.io/viewer` examples, as built by the `re_dev_tools`/`build_examples` script. The comparisons are generated in the `compare_screenshot` directory. Use the `--serve` option to show them in a browser. @@ -146,7 +146,7 @@ def collect_snippets() -> Iterable[Example]: # ==================================================================================================== # DEMO EXAMPLES # -# We run the `build_examples` script and scrap the output "example_data" directory. +# We run the `re_dev_tools`/`build_examples` script and scrap the output "example_data" directory. # ==================================================================================================== @@ -154,15 +154,15 @@ def build_examples() -> None: # fmt: off cmd = [ "cargo", "run", "--locked", - "-p", "re_build_examples", "--", - "rrd", "example_data", + "-p", "re_dev_tools", "--", + "build-examples", "rrd", "example_data", ] run(cmd, cwd=RERUN_DIR) cmd = [ "cargo", "run", "--locked", - "-p", "re_build_examples", "--", - "manifest", "example_data/examples_manifest.json", + "-p", "re_dev_tools", "--", + "build-examples", "manifest", "example_data/examples_manifest.json", ] run(cmd, cwd=RERUN_DIR) # fmt: on diff --git a/web_viewer/README.md b/web_viewer/README.md index c532f4ace282..16532e2a3766 100644 --- a/web_viewer/README.md +++ b/web_viewer/README.md @@ -2,4 +2,4 @@ This folder contains the files required for the web viewer app. You can build the web viewer with: -`cargo r -p re_build_web_viewer -- --release -g` +`pixi run rerun-build-web-release`