parent
96221c8a47
commit
1b74977a03
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -1,3 +1,6 @@
|
||||
[submodule "submodules/rust-openssl"]
|
||||
path = submodules/rust-openssl
|
||||
url = git://github.com/sfackler/rust-openssl
|
||||
[submodule "submodules/rust-phf"]
|
||||
path = submodules/rust-phf
|
||||
url = git://github.com/sfackler/rust-phf
|
||||
|
19
Makefile
19
Makefile
@ -7,6 +7,8 @@ POSTGRES = $(BUILDDIR)/$(shell $(RUSTC) --crate-file-name $(POSTGRES_LIB))
|
||||
POSTGRES_TEST = $(BUILDDIR)/$(shell $(RUSTC) --test --crate-file-name $(POSTGRES_LIB))
|
||||
OPENSSL_DIR = submodules/rust-openssl
|
||||
OPENSSL = $(OPENSSL_DIR)/$(shell $(MAKE) -s -C $(OPENSSL_DIR) print-target)
|
||||
PHF_DIR = submodules/rust-phf
|
||||
PHF = $(PHF_DIR)/$(shell $(MAKE) -s -C $(PHF_DIR) print-targets)
|
||||
|
||||
all: $(POSTGRES)
|
||||
|
||||
@ -16,21 +18,24 @@ all: $(POSTGRES)
|
||||
$(BUILDDIR):
|
||||
mkdir -p $@
|
||||
|
||||
$(BUILDDIR)/rust-openssl-trigger: submodules/rust-openssl-trigger | $(BUILDDIR)
|
||||
$(BUILDDIR)/submodule-trigger: submodules/submodule-trigger | $(BUILDDIR)
|
||||
git submodule init
|
||||
git submodule update
|
||||
touch $@
|
||||
|
||||
$(OPENSSL): $(BUILDDIR)/rust-openssl-trigger | $(BUILDDIR)
|
||||
$(OPENSSL): $(BUILDDIR)/submodule-trigger | $(BUILDDIR)
|
||||
$(MAKE) -C $(OPENSSL_DIR)
|
||||
|
||||
$(POSTGRES): $(POSTGRES_LIB) $(OPENSSL) | $(BUILDDIR)
|
||||
$(RUSTC) $(RUSTFLAGS) --dep-info $(@D)/postgres.d --out-dir $(@D) \
|
||||
-L $(dir $(OPENSSL)) $<
|
||||
$(PHF): $(BUILDDIR)/submodule-trigger | $(BUILDDIR)
|
||||
$(MAKE) -C $(PHF_DIR)
|
||||
|
||||
$(POSTGRES_TEST): $(POSTGRES_LIB) $(OPENSSL) | $(BUILDDIR)
|
||||
$(POSTGRES): $(POSTGRES_LIB) $(OPENSSL) $(PHF) | $(BUILDDIR)
|
||||
$(RUSTC) $(RUSTFLAGS) --dep-info $(@D)/postgres.d --out-dir $(@D) \
|
||||
-L $(dir $(OPENSSL)) $(foreach file,$(PHF),-L $(dir $(file))) $<
|
||||
|
||||
$(POSTGRES_TEST): $(POSTGRES_LIB) $(OPENSSL) $(PHF) | $(BUILDDIR)
|
||||
$(RUSTC) $(RUSTFLAGS) --dep-info $(@D)/postgres_test.d --out-dir $(@D) \
|
||||
-L $(dir $(OPENSSL)) --test $<
|
||||
-L $(dir $(OPENSSL)) $(foreach file,$(PHF),-L $(dir $(file))) --test $<
|
||||
|
||||
check: $(POSTGRES_TEST)
|
||||
$<
|
||||
|
15
error.rs
15
error.rs
@ -3,22 +3,27 @@
|
||||
use std::hashmap::HashMap;
|
||||
|
||||
use openssl::ssl::error::SslError;
|
||||
use phf::PhfMap;
|
||||
|
||||
macro_rules! make_errors(
|
||||
($($code:pat => $error:ident),+) => (
|
||||
($($code:expr => $error:ident),+) => (
|
||||
/// SQLSTATE error codes
|
||||
#[deriving(ToStr, Eq)]
|
||||
#[deriving(ToStr, Eq, Clone)]
|
||||
#[allow(missing_doc)]
|
||||
pub enum PostgresSqlState {
|
||||
$($error,)+
|
||||
UnknownSqlState(~str)
|
||||
}
|
||||
|
||||
static STATE_MAP: PhfMap<PostgresSqlState> = phf_map!(
|
||||
$($code => $error),+
|
||||
);
|
||||
|
||||
impl FromStr for PostgresSqlState {
|
||||
fn from_str(s: &str) -> Option<PostgresSqlState> {
|
||||
Some(match s {
|
||||
$($code => $error,)+
|
||||
state => UnknownSqlState(state.to_owned())
|
||||
Some(match STATE_MAP.find_str(&s) {
|
||||
Some(state) => state.clone(),
|
||||
None => UnknownSqlState(s.to_owned())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
5
lib.rs
5
lib.rs
@ -61,11 +61,14 @@ fn main() {
|
||||
|
||||
#[warn(missing_doc)];
|
||||
|
||||
#[feature(macro_rules, struct_variant, globs)];
|
||||
#[feature(macro_rules, struct_variant, globs, phase)];
|
||||
#[macro_escape];
|
||||
|
||||
extern mod extra;
|
||||
extern mod openssl;
|
||||
#[phase(syntax)]
|
||||
extern mod phf_mac;
|
||||
extern mod phf;
|
||||
|
||||
use extra::container::Deque;
|
||||
use extra::hex::ToHex;
|
||||
|
@ -1 +0,0 @@
|
||||
Sat Jan 18 13:39:47 PST 2014
|
1
submodules/rust-phf
Submodule
1
submodules/rust-phf
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 52ded831cfdb9ebc87e888228edc1644338aa8d6
|
1
submodules/submodule-trigger
Normal file
1
submodules/submodule-trigger
Normal file
@ -0,0 +1 @@
|
||||
Sat Jan 18 14:10:50 PST 2014
|
Loading…
Reference in New Issue
Block a user