2021-07-06 18:56:36 +00:00
|
|
|
use preserves_schema::compiler::*;
|
|
|
|
|
2021-08-13 01:06:09 +00:00
|
|
|
mod syndicate_plugins {
|
|
|
|
use preserves_schema::compiler::*;
|
|
|
|
use preserves_schema::gen::schema::*;
|
|
|
|
// use preserves_schema::syntax::block::constructors::*;
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub(super) struct PatternPlugin;
|
|
|
|
|
|
|
|
impl Plugin for PatternPlugin {
|
2021-09-19 14:53:37 +00:00
|
|
|
fn generate_definition(
|
2021-08-13 01:06:09 +00:00
|
|
|
&self,
|
2021-09-19 14:53:37 +00:00
|
|
|
_m: &mut context::ModuleContext,
|
2021-08-13 01:06:09 +00:00
|
|
|
_definition_name: &str,
|
|
|
|
_definition: &Definition,
|
|
|
|
) {
|
|
|
|
// TODO: Emit code for building instances of sturdy.Pattern and sturdy.Template
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-11 02:07:48 +00:00
|
|
|
fn main() -> std::io::Result<()> {
|
|
|
|
let buildroot = std::path::PathBuf::from(std::env::var_os("OUT_DIR").unwrap());
|
2021-07-06 18:56:36 +00:00
|
|
|
|
|
|
|
let mut gen_dir = buildroot.clone();
|
|
|
|
gen_dir.push("src/schemas");
|
|
|
|
|
2023-11-18 15:29:25 +00:00
|
|
|
let mut c = CompilerConfig::new("crate::schemas".to_owned());
|
2021-08-13 01:06:09 +00:00
|
|
|
c.plugins.push(Box::new(syndicate_plugins::PatternPlugin));
|
2021-09-19 14:53:37 +00:00
|
|
|
c.add_external_module(ExternalModule::new(vec!["EntityRef".to_owned()], "crate::actor"));
|
2021-07-06 18:56:36 +00:00
|
|
|
|
2022-02-04 13:15:28 +00:00
|
|
|
let inputs = expand_inputs(&vec!["protocols/schema-bundle.bin".to_owned()])?;
|
2023-01-28 21:45:48 +00:00
|
|
|
c.load_schemas_and_bundles(&inputs, &vec![])?;
|
2023-11-18 15:29:25 +00:00
|
|
|
compile(&c, &mut CodeCollector::files(gen_dir))
|
2021-07-06 18:56:36 +00:00
|
|
|
}
|