aboutsummaryrefslogtreecommitdiff
path: root/dev_tools
diff options
context:
space:
mode:
Diffstat (limited to 'dev_tools')
-rw-r--r--dev_tools/src/bin/ci.rs29
-rw-r--r--dev_tools/src/lib.rs43
2 files changed, 71 insertions, 1 deletions
diff --git a/dev_tools/src/bin/ci.rs b/dev_tools/src/bin/ci.rs
index ce8f058..3298452 100644
--- a/dev_tools/src/bin/ci.rs
+++ b/dev_tools/src/bin/ci.rs
@@ -1,7 +1,13 @@
use std::io::Write as _;
use std::process::exit;
-use tools::{cargo_tomls, eprintln_cargo_style, println_cargo_style, run_cmd};
+use tools::{
+ cargo_tomls, eprintln_cargo_style, println_cargo_style, run_cmd, wprintln_cargo_style,
+};
+
+fn get_ignore_dirs() -> Vec<String> {
+ vec![".temp".to_string()]
+}
fn main() {
#[cfg(windows)]
@@ -92,8 +98,15 @@ fn test_docs_code_blocks() -> Result<(), i32> {
}
fn build_all() -> Result<(), i32> {
+ let ignore_dirs = get_ignore_dirs();
let cargo_tomls = cargo_tomls();
for cargo_toml in cargo_tomls {
+ let path = cargo_toml.parent().unwrap_or(std::path::Path::new(""));
+ let path_str = path.to_string_lossy();
+ if ignore_dirs.iter().any(|d| path_str.contains(d.as_str())) {
+ wprintln_cargo_style!("Skipping: {} (ignored dir)", cargo_toml.to_string_lossy());
+ continue;
+ }
println_cargo_style!("Build: {}", cargo_toml.to_string_lossy());
run_cmd!(
"cargo build --manifest-path {}",
@@ -105,8 +118,15 @@ fn build_all() -> Result<(), i32> {
}
fn clippy_all() -> Result<(), i32> {
+ let ignore_dirs = get_ignore_dirs();
let cargo_tomls = cargo_tomls();
for cargo_toml in cargo_tomls {
+ let path = cargo_toml.parent().unwrap_or(std::path::Path::new(""));
+ let path_str = path.to_string_lossy();
+ if ignore_dirs.iter().any(|d| path_str.contains(d.as_str())) {
+ println_cargo_style!("Skipping: {} (ignored dir)", cargo_toml.to_string_lossy());
+ continue;
+ }
println_cargo_style!("Clippy: {}", cargo_toml.to_string_lossy());
run_cmd!(
"cargo clippy --manifest-path {} -- -D warnings",
@@ -118,8 +138,15 @@ fn clippy_all() -> Result<(), i32> {
}
fn test_all() -> Result<(), i32> {
+ let ignore_dirs = get_ignore_dirs();
let cargo_tomls = cargo_tomls();
for cargo_toml in cargo_tomls {
+ let path = cargo_toml.parent().unwrap_or(std::path::Path::new(""));
+ let path_str = path.to_string_lossy();
+ if ignore_dirs.iter().any(|d| path_str.contains(d.as_str())) {
+ println_cargo_style!("Skipping: {} (ignored dir)", cargo_toml.to_string_lossy());
+ continue;
+ }
println_cargo_style!("Testing: {}", cargo_toml.to_string_lossy());
run_cmd!(
"cargo test --manifest-path {}",
diff --git a/dev_tools/src/lib.rs b/dev_tools/src/lib.rs
index ce897df..13ed71f 100644
--- a/dev_tools/src/lib.rs
+++ b/dev_tools/src/lib.rs
@@ -44,6 +44,16 @@ macro_rules! eprintln_cargo_style {
};
}
+#[macro_export]
+macro_rules! wprintln_cargo_style {
+ ($fmt:literal, $($arg:tt)*) => {
+ $crate::wprintln_cargo_style(format!($fmt, $($arg)*))
+ };
+ ($cmd:expr) => {
+ $crate::wprintln_cargo_style($cmd)
+ };
+}
+
/// Print a message in cargo style format, with bold green prefix.
///
/// # Panics
@@ -81,6 +91,39 @@ pub fn eprintln_cargo_style(str: impl Into<String>) {
println!("{}: {}", "error".bold().bright_red(), str.into());
}
+/// Print a message in cargo style format, with bold yellow prefix (warning style).
+///
+/// # Panics
+///
+/// Panics if the prefix (text before the first `:`) exceeds 12 characters.
+pub fn wprintln_cargo_style(str: impl Into<String>) {
+ let s = str.into();
+ let (prefix, content) = if let Some(pos) = s.find(':') {
+ (
+ s[..pos].trim().to_string(),
+ s[pos + 1..].trim_start().to_string(),
+ )
+ } else {
+ (String::new(), s.trim().to_string())
+ };
+
+ assert!(
+ prefix.len() <= 12,
+ "prefix length exceeds 12: '{}' has length {}",
+ prefix,
+ prefix.len()
+ );
+
+ let padding = " ".repeat(12 - prefix.len());
+
+ println!(
+ "{}{} {}",
+ padding,
+ prefix.bold().bright_yellow(),
+ content.trim()
+ );
+}
+
/// Run a shell command and return its exit status.
///
/// # Panics