Skip to content

Commit 146096f

Browse files
committed
Introduce cargo xtasks pattern
1 parent c7b2e34 commit 146096f

File tree

8 files changed

+62
-10
lines changed

8 files changed

+62
-10
lines changed

.cargo/config.toml

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
[alias]
2+
xtask = "run --quiet --package xtask --"
3+
14
# On Windows MSVC, statically link the C runtime so that the resulting EXE does
25
# not depend on the vcruntime DLL.
36
[target.'cfg(windows)']

Cargo.lock

+13-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ members = [
88
"utils/create-output-dir",
99
"utils/scarb-test-support",
1010
"utils/test-for-each-example",
11+
"xtask",
1112
]
1213

1314
[workspace.package]
@@ -83,6 +84,7 @@ typed-builder = "0.14.0"
8384
url = { version = "2.3.1", features = ["serde"] }
8485
walkdir = "2.3.3"
8586
which = "4.4.0"
87+
xshell = "0.2.5"
8688
xxhash-rust = { version = "0.8.6", features = ["xxh3"] }
8789
zip = { version = "0.6.6", default-features = false, features = ["deflate"] }
8890

pkg/archive/package.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ mkdir -p \
1414
"$STAGING/bin/" \
1515
"$STAGING/doc/"
1616

17-
for crate in $(pkg/list-binaries.sh); do
17+
for crate in $(cargo xtask list-binaries); do
1818
cp "target/$TARGET/release/${crate}${bin_ext}" "$STAGING/bin/"
1919
done
2020

pkg/list-binaries.sh

-5
This file was deleted.

xtask/Cargo.toml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[package]
2+
name = "xtask"
3+
version = "1.0.0"
4+
edition.workspace = true
5+
publish = false
6+
7+
[dependencies]
8+
anyhow.workspace = true
9+
clap.workspace = true
10+
xshell.workspace = true

xtask/src/list_binaries.rs

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
use anyhow::Result;
2+
use std::fs;
3+
4+
pub fn main() -> Result<()> {
5+
println!("scarb");
6+
for entry in fs::read_dir("extensions")? {
7+
let entry = entry?;
8+
println!("{}", entry.file_name().to_string_lossy());
9+
}
10+
Ok(())
11+
}

xtask/src/main.rs

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
use anyhow::Result;
2+
use clap::{Parser, Subcommand};
3+
4+
mod list_binaries;
5+
6+
#[derive(Parser)]
7+
struct Args {
8+
#[command(subcommand)]
9+
command: Command,
10+
}
11+
12+
#[derive(Subcommand, Clone, Debug)]
13+
pub enum Command {
14+
ListBinaries,
15+
}
16+
17+
fn main() -> Result<()> {
18+
let args = Args::parse();
19+
match args.command {
20+
Command::ListBinaries => list_binaries::main(),
21+
}
22+
}

0 commit comments

Comments
 (0)