Files
matrix-rust-sdk/xtask/src/main.rs
Doug 7125730917 ci(xtask): Switch to xtask for swift; run swift tasks on macOS
Merge pull request #1023 from matrix-org/doug/swift-linux: Run Swift tests on macOS
2022-10-17 14:12:43 +02:00

68 lines
1.6 KiB
Rust

mod ci;
mod fixup;
mod swift;
mod workspace;
use ci::CiArgs;
use clap::{Parser, Subcommand};
use fixup::FixupArgs;
use swift::SwiftArgs;
use xshell::cmd;
type Result<T, E = Box<dyn std::error::Error>> = std::result::Result<T, E>;
#[derive(Parser)]
struct Xtask {
#[clap(subcommand)]
cmd: Command,
}
#[derive(Subcommand)]
enum Command {
/// Run continuous integration checks
Ci(CiArgs),
/// Fix up automatic checks
Fixup(FixupArgs),
/// Build the SDKs documentation
Doc {
/// Opens the docs in a browser after the operation
#[clap(long)]
open: bool,
},
Swift(SwiftArgs),
}
fn main() -> Result<()> {
match Xtask::parse().cmd {
Command::Ci(ci) => ci.run(),
Command::Fixup(cfg) => cfg.run(),
Command::Doc { open } => build_docs(open.then_some("--open"), DenyWarnings::No),
Command::Swift(cfg) => cfg.run(),
}
}
enum DenyWarnings {
Yes,
No,
}
fn build_docs(
extra_args: impl IntoIterator<Item = &'static str>,
deny_warnings: DenyWarnings,
) -> Result<()> {
let mut rustdocflags = "--enable-index-page -Zunstable-options --cfg docsrs".to_owned();
if let DenyWarnings::Yes = deny_warnings {
rustdocflags += " -Dwarnings";
}
// Keep in sync with .github/workflows/docs.yml
cmd!("rustup run nightly cargo doc --no-deps --workspace --features docsrs")
// Work around https://github.com/rust-lang/cargo/issues/10744
.env("CARGO_TARGET_APPLIES_TO_HOST", "true")
.env("RUSTDOCFLAGS", rustdocflags)
.args(extra_args)
.run()?;
Ok(())
}