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

50
rust/Cargo.lock generated
View file

@ -8,6 +8,15 @@ version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0"
[[package]]
name = "convert_case"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca"
dependencies = [
"unicode-segmentation",
]
[[package]]
name = "linked_list_allocator"
version = "0.10.5"
@ -34,6 +43,16 @@ dependencies = [
"linked_list_allocator",
]
[[package]]
name = "prettyplease"
version = "0.2.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e"
dependencies = [
"proc-macro2",
"syn 2.0.72",
]
[[package]]
name = "proc-macro2"
version = "1.0.86"
@ -78,6 +97,17 @@ dependencies = [
"unicode-ident",
]
[[package]]
name = "syn"
version = "2.0.72"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "testbed"
version = "0.1.0"
@ -92,6 +122,12 @@ version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
[[package]]
name = "unicode-segmentation"
version = "1.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202"
[[package]]
name = "yellowstone"
version = "0.1.0"
@ -99,6 +135,7 @@ dependencies = [
"mammoth",
"yunq",
"yunq-derive",
"yunqc",
]
[[package]]
@ -115,5 +152,16 @@ version = "0.1.0"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 1.0.109",
]
[[package]]
name = "yunqc"
version = "0.1.0"
dependencies = [
"convert_case",
"prettyplease",
"proc-macro2",
"quote",
"syn 2.0.72",
]

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.");
}