Split yunq compliation to library and use it in build process.

This commit is contained in:
Drew Galbraith 2024-07-28 18:08:34 -07:00
parent 370ba9ae40
commit 1e073d5060
7 changed files with 89 additions and 28 deletions

View file

@ -8,3 +8,6 @@ mammoth = { path = "../mammoth" }
yunq = {path = "../yunq"}
yunq-derive = {path = "../yunq-derive"}
[build-dependencies]
yunqc = {path = "../../../yunq/rust"}

View file

@ -1,18 +1,14 @@
use std::process::Command;
use std::fs;
fn main() {
let input_file = "../../../sys/yellowstone/lib/yellowstone/yellowstone.yunq";
println!("cargo::rerun-if-changed={input_file}");
let input = fs::read_to_string(input_file).expect("Failed to read input file");
let code = yunqc::codegen(&input).expect("Failed to generate yunq code.");
let out = std::env::var("OUT_DIR").unwrap() + "/yunq.rs";
let status = Command::new("cargo")
.current_dir("../../../yunq/rust")
.arg("run")
.arg("--")
.arg("--input-path")
.arg("../../sys/yellowstone/lib/yellowstone/yellowstone.yunq")
.arg("--output-path")
.arg(out)
.status()
.expect("Failed to start execution");
assert!(status.success());
fs::write(out, code).expect("Failed to write generated code.");
}