From 2e43188036607eed5fce3c628304120dc86c5ba2 Mon Sep 17 00:00:00 2001 From: Jake Shadle Date: Tue, 31 Jan 2023 10:15:11 +0100 Subject: [PATCH] Automatically create outdir if it doesn't exist --- gen/cmd/src/main.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gen/cmd/src/main.rs b/gen/cmd/src/main.rs index b6aa8aa1f..2855488b7 100644 --- a/gen/cmd/src/main.rs +++ b/gen/cmd/src/main.rs @@ -283,6 +283,14 @@ fn main() -> miette::Result<()> { // Finally start to write the C++ and Rust out. let outdir: PathBuf = matches.value_of_os("outdir").unwrap().into(); + + if !outdir.exists() { + use miette::WrapErr as _; + std::fs::create_dir_all(&outdir) + .into_diagnostic() + .wrap_err_with(|| format!("Failed to create `outdir` '{}'", outdir.display()))?; + } + let mut writer = FileWriter { depfile: &depfile, outdir: &outdir,