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 {
|
|
|
|
fn generate(
|
|
|
|
&self,
|
|
|
|
m: &mut context::ModuleContext,
|
|
|
|
_definition_name: &str,
|
|
|
|
_definition: &Definition,
|
|
|
|
) {
|
|
|
|
if m.mode.is_some() {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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");
|
|
|
|
|
|
|
|
let mut c = CompilerConfig::new(gen_dir, "crate::schemas".to_owned());
|
2021-08-13 01:06:09 +00:00
|
|
|
c.plugins.push(Box::new(syndicate_plugins::PatternPlugin));
|
2021-07-06 18:56:36 +00:00
|
|
|
c.module_aliases.insert(vec!["EntityRef".to_owned()], "crate::actor".to_owned());
|
|
|
|
|
2021-07-22 14:53:56 +00:00
|
|
|
let inputs = expand_inputs(&vec!["protocols/schema-bundle.bin".to_owned()])?;
|
2021-07-06 18:56:36 +00:00
|
|
|
c.load_schemas_and_bundles(&inputs)?;
|
|
|
|
compile(&c)
|
|
|
|
}
|