Anki/build/runner/src/main.rs
Damien Elmes e9415b43f4 Migrate archive tool into runner
Also fix minilints declaring a stamp it wasn't creating. The same
approach is necessary with archives now too, as it no longer executes
under a standard "runner run".

For now, rustls is hard-coded - we could pass the desired TLS impl in
from the ./ninja script, but the runner is not recompiled frequently
anyway.
2023-06-23 17:41:31 +10:00

71 lines
1.9 KiB
Rust

// Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
//! A helper for invoking one or more commands in a cross-platform way,
//! silencing their output when they succeed. Most build actions implicitly use
//! the 'run' command; we define separate commands for more complicated actions.
mod archive;
mod build;
mod bundle;
mod paths;
mod pyenv;
mod rsync;
mod run;
mod yarn;
use anyhow::Result;
use archive::archive_command;
use archive::ArchiveArgs;
use build::run_build;
use build::BuildArgs;
use bundle::artifacts::build_artifacts;
use bundle::artifacts::BuildArtifactsArgs;
use bundle::binary::build_bundle_binary;
use bundle::folder::build_dist_folder;
use bundle::folder::BuildDistFolderArgs;
use clap::Parser;
use clap::Subcommand;
use pyenv::setup_pyenv;
use pyenv::PyenvArgs;
use rsync::rsync_files;
use rsync::RsyncArgs;
use run::run_commands;
use run::RunArgs;
use yarn::setup_yarn;
use yarn::YarnArgs;
#[derive(Parser)]
struct Cli {
#[command(subcommand)]
command: Command,
}
#[derive(Subcommand)]
enum Command {
Pyenv(PyenvArgs),
Yarn(YarnArgs),
Rsync(RsyncArgs),
Run(RunArgs),
Build(BuildArgs),
BuildArtifacts(BuildArtifactsArgs),
BuildBundleBinary,
BuildDistFolder(BuildDistFolderArgs),
#[clap(subcommand)]
Archive(ArchiveArgs),
}
fn main() -> Result<()> {
match Cli::parse().command {
Command::Pyenv(args) => setup_pyenv(args),
Command::Run(args) => run_commands(args)?,
Command::Rsync(args) => rsync_files(args),
Command::Yarn(args) => setup_yarn(args),
Command::Build(args) => run_build(args),
Command::BuildArtifacts(args) => build_artifacts(args),
Command::BuildBundleBinary => build_bundle_binary(),
Command::BuildDistFolder(args) => build_dist_folder(args),
Command::Archive(args) => archive_command(args)?,
};
Ok(())
}