Use persistent codegen for SqlState and Type
Makes it easier to detect changes and speeds up the build.
This commit is contained in:
parent
f6c0ce1c40
commit
ed789cfad8
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,3 +1,3 @@
|
||||
/target/
|
||||
target/
|
||||
Cargo.lock
|
||||
.cargo/
|
||||
|
@ -8,8 +8,7 @@ repository = "https://github.com/sfackler/rust-postgres"
|
||||
documentation = "https://sfackler.github.io/rust-postgres/doc/v0.11.3/postgres"
|
||||
readme = "README.md"
|
||||
keywords = ["database", "postgres", "postgresql", "sql"]
|
||||
build = "build/main.rs"
|
||||
include = ["src/*", "build/*", "Cargo.toml", "LICENSE", "README.md", "THIRD_PARTY"]
|
||||
include = ["src/*", "Cargo.toml", "LICENSE", "README.md", "THIRD_PARTY"]
|
||||
|
||||
[lib]
|
||||
name = "postgres"
|
||||
@ -21,10 +20,6 @@ bench = false
|
||||
name = "test"
|
||||
path = "tests/test.rs"
|
||||
|
||||
[build-dependencies]
|
||||
phf_codegen = "0.7"
|
||||
regex = "0.1"
|
||||
|
||||
[dependencies]
|
||||
bufstream = "0.1"
|
||||
byteorder = ">= 0.3, < 0.5"
|
||||
|
8
codegen/Cargo.toml
Normal file
8
codegen/Cargo.toml
Normal file
@ -0,0 +1,8 @@
|
||||
[package]
|
||||
name = "codegen"
|
||||
version = "0.1.0"
|
||||
authors = ["Steven Fackler <sfackler@gmail.com>"]
|
||||
|
||||
[dependencies]
|
||||
phf_codegen = "0.7"
|
||||
regex = "0.1"
|
@ -2,15 +2,15 @@ extern crate phf_codegen;
|
||||
extern crate regex;
|
||||
|
||||
use std::ascii::AsciiExt;
|
||||
use std::path::Path;
|
||||
|
||||
mod sqlstate;
|
||||
mod types;
|
||||
|
||||
fn main() {
|
||||
sqlstate::build();
|
||||
types::build();
|
||||
|
||||
println!("cargo:rerun-if-changed=build");
|
||||
let path = Path::new("../src");
|
||||
sqlstate::build(path);
|
||||
types::build(path);
|
||||
}
|
||||
|
||||
fn snake_to_camel(s: &str) -> String {
|
@ -1,8 +1,6 @@
|
||||
use std::env;
|
||||
use std::fs::File;
|
||||
use std::io::{Write, BufWriter};
|
||||
use std::path::Path;
|
||||
use std::convert::AsRef;
|
||||
use phf_codegen;
|
||||
|
||||
use snake_to_camel;
|
||||
@ -14,11 +12,8 @@ struct Code {
|
||||
variant: String,
|
||||
}
|
||||
|
||||
pub fn build() {
|
||||
let path = env::var_os("OUT_DIR").unwrap();
|
||||
let path: &Path = path.as_ref();
|
||||
let path = path.join("sqlstate.rs");
|
||||
let mut file = BufWriter::new(File::create(&path).unwrap());
|
||||
pub fn build(path: &Path) {
|
||||
let mut file = BufWriter::new(File::create(path.join("error/sqlstate.rs")).unwrap());
|
||||
|
||||
let codes = parse_codes();
|
||||
|
@ -1,7 +1,6 @@
|
||||
use regex::Regex;
|
||||
use std::ascii::AsciiExt;
|
||||
use std::collections::BTreeMap;
|
||||
use std::env;
|
||||
use std::fs::File;
|
||||
use std::io::{Write, BufWriter};
|
||||
use std::path::Path;
|
||||
@ -19,11 +18,8 @@ struct Type {
|
||||
doc: String,
|
||||
}
|
||||
|
||||
pub fn build() {
|
||||
let path = env::var_os("OUT_DIR").unwrap();
|
||||
let path: &Path = path.as_ref();
|
||||
let path = path.join("type.rs");
|
||||
let mut file = BufWriter::new(File::create(&path).unwrap());
|
||||
pub fn build(path: &Path) {
|
||||
let mut file = BufWriter::new(File::create(path.join("types/types.rs")).unwrap());
|
||||
|
||||
let ranges = parse_ranges();
|
||||
let types = parse_types(&ranges);
|
@ -11,7 +11,7 @@ use std::collections::HashMap;
|
||||
|
||||
use {Result, DbErrorNew};
|
||||
|
||||
include!(concat!(env!("OUT_DIR"), "/sqlstate.rs"));
|
||||
include!("sqlstate.rs");
|
||||
|
||||
/// A Postgres error or notice.
|
||||
#[derive(Clone, PartialEq, Eq)]
|
1022
src/error/sqlstate.rs
Normal file
1022
src/error/sqlstate.rs
Normal file
File diff suppressed because it is too large
Load Diff
@ -149,7 +149,7 @@ impl FieldNew for Field {
|
||||
}
|
||||
}
|
||||
|
||||
include!(concat!(env!("OUT_DIR"), "/type.rs"));
|
||||
include!("types.rs");
|
||||
|
||||
/// Information about an unknown type.
|
||||
#[derive(PartialEq, Eq, Clone)]
|
||||
|
1477
src/types/types.rs
Normal file
1477
src/types/types.rs
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user