Files
husk-milter/build.rs
T
Malte Meiboom 8de999411d Polish the code
- Reject user ids containing ANSI control characters when creating a new
  signing key.
- Prevent adding certificates twice when querying online sources if they
  contain multiple encryption keys.
- Dedup introducers if there are multiple authenticating paths.
- When listing locals, skip the signing key.
- Check if a mail can be encrypted at all due to available certificates.
  If not tell the MTA that the processing is done.
- Make `Introducer` comparable (`PartialEq`, `Eq` and `Hash`).
- minor polishing
2026-07-24 13:41:07 +02:00

50 lines
1.2 KiB
Rust

//! build
use anyhow::Result;
use clap::CommandFactory;
use clap::ValueEnum;
use clap_complete::Shell;
use std::env;
use std::fs;
use std::path::PathBuf;
// include the cli definition
pub mod cli {
include!("src/cli/cli_args.rs");
}
const ASSET_OUT_ENV_NAME: &str = "ASSET_OUT_DIR";
/// Returns a path to a directory suitable as a target for generated
/// files.
fn out_dir(section: &str) -> Result<PathBuf> {
println!("cargo:rerun-if-env-changed={}", ASSET_OUT_ENV_NAME);
let outdir: PathBuf = env::var_os(ASSET_OUT_ENV_NAME)
.unwrap_or_else(|| env::var_os("OUT_DIR")
.expect("OUT_DIR not set")
).into();
if outdir.exists() && ! outdir.is_dir() {
return Err(anyhow::anyhow!("{:?} is not a directory", outdir));
}
let path = outdir.join(section);
fs::create_dir_all(&path)?;
Ok(path)
}
fn main() -> Result<()> {
let mut husk = cli::CliArgs::command();
// shell completions
let shell_completion_path = out_dir("shell_completions")?;
for shell in Shell::value_variants() {
clap_complete::generate_to(*shell, &mut husk, "husk", &shell_completion_path)?;
}
println!("cargo:warning=shell completions written to {}", shell_completion_path.display());
Ok(())
}