7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1 | #![allow(unexpected_cfgs)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 2 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 3 | mod ci; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 4 | mod fixup; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 5 | mod kotlin; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 6 | mod log; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 7 | mod release; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 8 | mod swift; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 9 | mod workspace; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 10 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 11 | use std::rc::Rc; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 12 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 13 | use ci::CiArgs; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 14 | use clap::{Parser, Subcommand}; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 15 | use fixup::FixupArgs; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 16 | use kotlin::KotlinArgs; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 17 | use log::LogArgs; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 18 | use release::ReleaseArgs; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 19 | use swift::SwiftArgs; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 20 | use xshell::{Shell, cmd}; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 21 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 22 | const NIGHTLY: &str = "nightly-2026-02-26"; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 23 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 24 | type Result<T, E = Box<dyn std::error::Error>> = std::result::Result<T, E>; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 25 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 26 | #[derive(Parser)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 27 | struct Xtask { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 28 | #[clap(subcommand)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 29 | cmd: Command, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 30 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 31 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 32 | #[derive(Subcommand)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 33 | enum Command { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 34 | /// Run continuous integration checks |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 35 | Ci(CiArgs), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 36 | /// Fix up automatic checks |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 37 | Fixup(FixupArgs), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 38 | /// Build the SDKs documentation |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 39 | Doc { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 40 | /// Opens the docs in a browser after the operation |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 41 | #[clap(long)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 42 | open: bool, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 43 | }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 44 | /// Prepare and publish a release of the matrix-sdk crates |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 45 | Release(ReleaseArgs), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 46 | Swift(SwiftArgs), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 47 | Kotlin(KotlinArgs), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 48 | Log(LogArgs), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 49 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 50 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 51 | fn main() -> Result<()> { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 52 | match Xtask::parse().cmd { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 53 | Command::Ci(ci) => ci.run(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 54 | Command::Fixup(cfg) => cfg.run(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 55 | Command::Doc { open } => build_docs(open.then_some("--open"), DenyWarnings::No), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 56 | Command::Swift(cfg) => cfg.run(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 57 | Command::Kotlin(cfg) => cfg.run(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 58 | Command::Release(cfg) => cfg.run(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 59 | Command::Log(cfg) => cfg.run(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 60 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 61 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 62 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 63 | enum DenyWarnings { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 64 | Yes, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 65 | No, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 66 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 67 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 68 | fn build_docs( |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 69 | extra_args: impl IntoIterator<Item = &'static str>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 70 | deny_warnings: DenyWarnings, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 71 | ) -> Result<()> { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 72 | let mut rustdocflags = "--enable-index-page -Zunstable-options --cfg docsrs".to_owned(); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 73 | if let DenyWarnings::Yes = deny_warnings { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 74 | rustdocflags += " -Dwarnings"; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 75 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 76 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 77 | let sh = sh(); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 78 | // Keep in sync with .github/workflows/docs.yml |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 79 | cmd!(sh, "rustup run {NIGHTLY} cargo doc --no-deps --workspace --features docsrs") |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 80 | .env("RUSTDOCFLAGS", rustdocflags) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 81 | .args(extra_args) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 82 | .run()?; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 83 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 84 | Ok(()) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 85 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 86 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 87 | thread_local! { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 88 | /// The shared shell API. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 89 | static SH: Rc<Shell> = Rc::new(Shell::new().unwrap()) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 90 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 91 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 92 | /// Get a reference to the shared shell API. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 93 | fn sh() -> Rc<Shell> { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 94 | SH.with(|sh| sh.clone()) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 95 | } |