Rust workspace for VIctory: PE analysis, loader, HLE skeleton, DXBC/DXIL parsing with a GFX10 decoder, conversion cache, CLI and asset-policy enforcement. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
57 lines
1.5 KiB
Rust
57 lines
1.5 KiB
Rust
//! Repository maintenance. Run with `cargo xtask <command>`.
|
|
|
|
mod policy;
|
|
|
|
use std::path::{Path, PathBuf};
|
|
use std::process::Command;
|
|
|
|
use anyhow::{Context, Result};
|
|
use clap::{Parser, Subcommand};
|
|
|
|
#[derive(Parser)]
|
|
#[command(name = "xtask")]
|
|
struct Cli {
|
|
#[command(subcommand)]
|
|
command: Cmd,
|
|
}
|
|
|
|
#[derive(Subcommand)]
|
|
enum Cmd {
|
|
/// Enforce the asset policy: the repository holds only small text files
|
|
/// we wrote. Checks tracked and untracked-but-not-ignored files.
|
|
Policy {
|
|
/// Check only what is staged for commit (used by the pre-commit hook).
|
|
#[arg(long)]
|
|
staged: bool,
|
|
},
|
|
/// Point git at .githooks/ so every commit runs the policy check.
|
|
InstallHooks,
|
|
}
|
|
|
|
fn main() -> Result<()> {
|
|
let root = workspace_root();
|
|
match Cli::parse().command {
|
|
Cmd::Policy { staged } => policy::run(&root, staged),
|
|
Cmd::InstallHooks => {
|
|
let status = Command::new("git")
|
|
.args(["config", "core.hooksPath", ".githooks"])
|
|
.current_dir(&root)
|
|
.status()
|
|
.context("running git")?;
|
|
anyhow::ensure!(
|
|
status.success(),
|
|
"git config failed (is this a git repository?)"
|
|
);
|
|
println!("hooks installed: commits now run `cargo xtask policy --staged`");
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
|
|
fn workspace_root() -> PathBuf {
|
|
Path::new(env!("CARGO_MANIFEST_DIR"))
|
|
.parent()
|
|
.expect("xtask lives in the workspace")
|
|
.into()
|
|
}
|