Add serde_codegen::expand to avoid public Syntex dependency
This commit is contained in:
parent
1917e54a6e
commit
3d2e3beafe
10
README.md
10
README.md
@ -142,10 +142,7 @@ pub fn main() {
|
|||||||
let src = Path::new("src/main.rs.in");
|
let src = Path::new("src/main.rs.in");
|
||||||
let dst = Path::new(&out_dir).join("main.rs");
|
let dst = Path::new(&out_dir).join("main.rs");
|
||||||
|
|
||||||
let mut registry = syntex::Registry::new();
|
serde_codegen::expand(&src, &dst).unwrap();
|
||||||
|
|
||||||
serde_codegen::register(&mut registry);
|
|
||||||
registry.expand("", &src, &dst).unwrap();
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -203,10 +200,7 @@ mod inner {
|
|||||||
let src = Path::new("src/main.rs.in");
|
let src = Path::new("src/main.rs.in");
|
||||||
let dst = Path::new(&out_dir).join("main.rs");
|
let dst = Path::new(&out_dir).join("main.rs");
|
||||||
|
|
||||||
let mut registry = syntex::Registry::new();
|
serde_codegen::expand(&src, &dst).unwrap();
|
||||||
|
|
||||||
serde_codegen::register(&mut registry);
|
|
||||||
registry.expand("", &src, &dst).unwrap();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,10 +12,7 @@ mod inner {
|
|||||||
let src = Path::new("src/main.rs.in");
|
let src = Path::new("src/main.rs.in");
|
||||||
let dst = Path::new(&out_dir).join("main.rs");
|
let dst = Path::new(&out_dir).join("main.rs");
|
||||||
|
|
||||||
let mut registry = syntex::Registry::new();
|
serde_codegen::expand(&src, &dst).unwrap();
|
||||||
|
|
||||||
serde_codegen::register(&mut registry);
|
|
||||||
registry.expand("", &src, &dst).unwrap();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,6 +22,11 @@ extern crate syntax;
|
|||||||
#[cfg(not(feature = "with-syntex"))]
|
#[cfg(not(feature = "with-syntex"))]
|
||||||
extern crate rustc_plugin;
|
extern crate rustc_plugin;
|
||||||
|
|
||||||
|
#[cfg(feature = "with-syntex")]
|
||||||
|
use std::io;
|
||||||
|
#[cfg(feature = "with-syntex")]
|
||||||
|
use std::path::Path;
|
||||||
|
|
||||||
#[cfg(not(feature = "with-syntex"))]
|
#[cfg(not(feature = "with-syntex"))]
|
||||||
use syntax::feature_gate::AttributeType;
|
use syntax::feature_gate::AttributeType;
|
||||||
|
|
||||||
@ -31,6 +36,13 @@ include!(concat!(env!("OUT_DIR"), "/lib.rs"));
|
|||||||
#[cfg(not(feature = "with-syntex"))]
|
#[cfg(not(feature = "with-syntex"))]
|
||||||
include!("lib.rs.in");
|
include!("lib.rs.in");
|
||||||
|
|
||||||
|
#[cfg(feature = "with-syntex")]
|
||||||
|
pub fn expand(src: &Path, dst: &Path) -> io::Result<()> {
|
||||||
|
let mut registry = syntex::Registry::new();
|
||||||
|
register(&mut registry);
|
||||||
|
registry.expand("", src, dst)
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(feature = "with-syntex")]
|
#[cfg(feature = "with-syntex")]
|
||||||
pub fn register(reg: &mut syntex::Registry) {
|
pub fn register(reg: &mut syntex::Registry) {
|
||||||
use syntax::{ast, fold};
|
use syntax::{ast, fold};
|
||||||
|
Loading…
Reference in New Issue
Block a user