Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[xtask] move downloader to a separate binary #6171

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ members = [
"cockroach-admin/types",
"common",
"dev-tools/crdb-seed",
"dev-tools/downloader",
"dev-tools/omdb",
"dev-tools/omicron-dev",
"dev-tools/openapi-manager",
Expand Down Expand Up @@ -122,6 +123,7 @@ default-members = [
"cockroach-admin/types",
"common",
"dev-tools/crdb-seed",
"dev-tools/downloader",
"dev-tools/omdb",
"dev-tools/omicron-dev",
"dev-tools/openapi-manager",
Expand Down
24 changes: 24 additions & 0 deletions dev-tools/downloader/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[package]
name = "xtask-downloader"
version = "0.1.0"
edition = "2021"
license = "MPL-2.0"

[lints]
workspace = true

[dependencies]
anyhow.workspace = true
camino.workspace = true
clap.workspace = true
flate2.workspace = true
futures.workspace = true
omicron-workspace-hack.workspace = true
reqwest.workspace = true
sha2.workspace = true
slog.workspace = true
slog-async.workspace = true
slog-term.workspace = true
strum.workspace = true
tar.workspace = true
tokio.workspace = true
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

//! Subcommand: cargo xtask download
//!
//! This is a separate binary because it requires many dependencies that other
//! parts of `cargo xtask` do not.

use anyhow::{bail, Context, Result};
use camino::{Utf8Path, Utf8PathBuf};
Expand Down
12 changes: 12 additions & 0 deletions dev-tools/downloader/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

use clap::Parser;
use xtask_downloader::{run_cmd, DownloadArgs};

#[tokio::main]
async fn main() -> anyhow::Result<()> {
let args = DownloadArgs::parse();
run_cmd(args).await
}
25 changes: 14 additions & 11 deletions dev-tools/xtask/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,29 @@ license = "MPL-2.0"
workspace = true

[dependencies]
# Please read before adding a new dependency!
#
# cargo xtask is used for many developer flows, and it is important for devx
# that it be quick to build. If a particular task needs many dependencies,
# consider moving it out into a binary crate and building that separately.
# Additional binaries generally mean that you only pay for what you need.
#
# For example, xtask-downloader is a separate binary because it requires many
# additional dependencies, like `reqwest`, `tar`, and `tokio`.
#
# The combinatorial explosion of features that would ordinarily happen is not
# an issue for omicron due to the workspace-hack crate. (For build speed
# reasons, `xtask` does *not* depend on `omicron-workspace-hack`. But the
# downstream binaries do depend on it.)
anyhow.workspace = true
camino.workspace = true
cargo_toml = "0.20"
cargo_metadata.workspace = true
clap.workspace = true
flate2.workspace = true
futures.workspace = true
fs-err.workspace = true
macaddr.workspace = true
reqwest = { workspace = true, features = [ "default-tls" ] }
serde.workspace = true
sha2.workspace = true
slog.workspace = true
slog-async.workspace = true
slog-bunyan.workspace = true
slog-term.workspace = true
strum.workspace = true
swrite.workspace = true
tabled.workspace = true
tar.workspace = true
tokio = { workspace = true, features = ["full"] }
toml.workspace = true
usdt.workspace = true
8 changes: 3 additions & 5 deletions dev-tools/xtask/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use clap::{Parser, Subcommand};
mod check_features;
mod check_workspace_deps;
mod clippy;
mod download;
#[cfg_attr(not(target_os = "illumos"), allow(dead_code))]
mod external;
mod usdt;
Expand Down Expand Up @@ -47,7 +46,7 @@ enum Cmds {
/// Run configured clippy checks
Clippy(clippy::ClippyArgs),
/// Download binaries, OpenAPI specs, and other out-of-repo utilities.
Download(download::DownloadArgs),
Download(external::External),

/// Manage OpenAPI specifications.
///
Expand Down Expand Up @@ -86,8 +85,7 @@ enum Cmds {
},
}

#[tokio::main]
async fn main() -> Result<()> {
fn main() -> Result<()> {
let args = Args::parse();
match args.cmd {
Cmds::Argon2(external) => {
Expand All @@ -96,7 +94,7 @@ async fn main() -> Result<()> {
Cmds::Clippy(args) => clippy::run_cmd(args),
Cmds::CheckFeatures(args) => check_features::run_cmd(args),
Cmds::CheckWorkspaceDeps => check_workspace_deps::run_cmd(),
Cmds::Download(args) => download::run_cmd(args).await,
Cmds::Download(external) => external.exec_bin("xtask-downloader"),
Cmds::Openapi(external) => external.exec_bin("openapi-manager"),
#[cfg(target_os = "illumos")]
Cmds::Releng(external) => {
Expand Down
Loading