forked from cornucopia-rs/cornucopia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_build.rs
27 lines (24 loc) · 831 Bytes
/
_build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
use cornucopia::{CodegenSettings, Error};
// This script will generate a new cornucopia file every time your schema or queries change.
// In this example, we generate the module in our project, but
// we could also generate it elsewhere and embed the generated
// file with a `include_str` statement in your project.
fn main() -> Result<(), Error> {
let queries_path = "queries";
let schema_file = "schema.sql";
let destination = "src/cornucopia.rs";
let settings = CodegenSettings {
is_async: true,
derive_ser: false,
};
println!("cargo:rerun-if-changed={queries_path}");
println!("cargo:rerun-if-changed={schema_file}");
cornucopia::generate_managed(
queries_path,
&[schema_file],
Some(destination),
false,
settings,
)?;
Ok(())
}