Provides the functionality of diesel_codegen
using Syntex for usage on stable.
Add diesel_codegen_syntex
to your Cargo.toml
, specifying which backends you use.
diesel_codegen_syntex = { version = "0.9.0", features = ["postgres"] }
Next, move the mod
declarations of any modules that need codegen to a separate file, such as lib.in.rs
, like so:
// main.in.rs mod schema; mod models;
// main.rs include!(concat!(env!("OUT_DIR"), "/main.rs"));
Finally, add a build file which calls diesel_codgen_syntex::expand
// build.rs fn main() { let out_dir = env::var("OUT_DIR").unwrap(); let src = Path::new("src/main.in.rs"); let dst = Path::new(&out_dir).join("main.rs"); diesel_codegen_syntex::expand(&src, &dst).unwrap(); }
For more examples, please see section 4 of the getting started guide