Use modules rather than include! for codegenned stuff

This commit is contained in:
Steven Fackler
2016-02-21 13:37:29 -08:00
parent ed789cfad8
commit c185bcf43f
6 changed files with 31 additions and 4 deletions

View File

@@ -17,6 +17,7 @@ pub fn build(path: &Path) {
let codes = parse_codes();
make_header(&mut file);
make_enum(&codes, &mut file);
make_map(&codes, &mut file);
make_impl(&codes, &mut file);
@@ -69,6 +70,14 @@ fn variant_name(code: &str) -> Option<String> {
}
}
fn make_header(file: &mut BufWriter<File>) {
write!(file,
"// Autogenerated file - DO NOT EDIT
use phf;
"
).unwrap();
}
fn make_enum(codes: &[Code], file: &mut BufWriter<File>) {
write!(file,
r#"/// SQLSTATE error codes

View File

@@ -24,6 +24,7 @@ pub fn build(path: &Path) {
let ranges = parse_ranges();
let types = parse_types(&ranges);
make_header(&mut file);
make_enum(&mut file, &types);
make_display_impl(&mut file);
make_impl(&mut file, &types);
@@ -113,6 +114,16 @@ fn parse_types(ranges: &BTreeMap<u32, u32>) -> BTreeMap<u32, Type> {
types
}
fn make_header(w: &mut BufWriter<File>) {
write!(w,
"// Autogenerated file - DO NOT EDIT
use std::fmt;
use types::{{Oid, Kind, Other}};
"
).unwrap();
}
fn make_enum(w: &mut BufWriter<File>, types: &BTreeMap<u32, Type>) {
write!(w,
"/// A Postgres type.