1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//! This build script collects all examples which should be part of our example page,
//! and either runs them to produce `.rrd` files, or builds a manifest file which
//! serves as an index for the files.
//!
//! It identifies runnable examples by checking if they have `channel` set in
//! their `README.md` frontmatter. The available values are:
//! - `main` for simple/fast examples built on each PR and the `main` branch
//! - `nightly` for heavier examples built once per day
//!
//! An example may also specify args to be run with via the frontmatter
//! `build_args` string array.

mod example;
mod install;
mod manifest;
mod rrd;
mod snippets;
mod wait_for_output;

use example::Channel;
use wait_for_output::wait_for_output;

pub use example::{Example, ExamplesManifest, Language};

// -----------------------------------------------------------------------------

use argh::FromArgs;

/// Build examples and their manifest.
#[derive(FromArgs)]
#[argh(subcommand, name = "build-examples")]
pub struct Args {
    #[argh(subcommand)]
    cmd: Cmd,
}

#[derive(FromArgs)]
#[argh(subcommand)]
enum Cmd {
    Install(install::Install),
    Rrd(rrd::Rrd),
    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::Install(cmd) => cmd.run(),
        Cmd::Rrd(cmd) => cmd.run(),
        Cmd::Manifest(cmd) => cmd.run(),
        Cmd::Snippets(cmd) => cmd.run(),
    }
}