fix: Build scripts were broken, this fixes them on new progenitor version

This commit is contained in:
Max Hausch
2024-02-13 21:42:05 +01:00
parent c08a116ed1
commit e4dfab0112
2 changed files with 18 additions and 12 deletions
+9 -6
View File
@@ -1,13 +1,16 @@
use std::{path::PathBuf, str::FromStr};
fn main() {
let src = PathBuf::from_str("openapi.json").unwrap();
let src = "openapi.json";
println!("cargo:rerun-if-changed={}", src);
let file = std::fs::File::open(src).unwrap();
let spec = serde_json::from_reader(file).unwrap();
let mut generator = progenitor::Generator::default();
let content = generator.generate_text(&spec).unwrap();
let tokens = generator.generate_tokens(&spec).unwrap();
let ast = syn::parse2(tokens).unwrap();
let content = prettyplease::unparse(&ast);
let out_file = std::path::Path::new(&std::env::var("OUT_DIR").unwrap()).to_path_buf();
std::fs::write(out_file.join("codegen.rs"), content).unwrap();
let mut out_file = std::path::Path::new(&std::env::var("OUT_DIR").unwrap()).to_path_buf();
out_file.push("codegen.rs");
std::fs::write(out_file, content).unwrap();
}
+9 -6
View File
@@ -1,13 +1,16 @@
use std::{path::PathBuf, str::FromStr};
fn main() {
let src = PathBuf::from_str("openapi.json").unwrap();
let src = "openapi.json";
println!("cargo:rerun-if-changed={}", src);
let file = std::fs::File::open(src).unwrap();
let spec = serde_json::from_reader(file).unwrap();
let mut generator = progenitor::Generator::default();
let content = generator.generate_text(&spec).unwrap();
let tokens = generator.generate_tokens(&spec).unwrap();
let ast = syn::parse2(tokens).unwrap();
let content = prettyplease::unparse(&ast);
let out_file = std::path::Path::new(&std::env::var("OUT_DIR").unwrap()).to_path_buf();
std::fs::write(out_file.join("codegen.rs"), content).unwrap();
let mut out_file = std::path::Path::new(&std::env::var("OUT_DIR").unwrap()).to_path_buf();
out_file.push("codegen.rs");
std::fs::write(out_file, content).unwrap();
}