Skip to content

Commit

Permalink
working on getting this to build with the new cargo
Browse files Browse the repository at this point in the history
  • Loading branch information
dwrensha committed Nov 8, 2014
1 parent 1c4224f commit 33ac799
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
name = "capnp-rpc"
version = "0.1.0"
authors = [ "David Renshaw <dwrenshaw@gmail.com>" ]
build = "make generated"
build = "build.rs"

[lib]

Expand Down
28 changes: 28 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
use std::os;
use std::io::Command;

fn main() {

// CAPNP_INCLUDE_DIR=$(shell dirname $(shell which capnp))/../include

let include_dir = {
let output = Command::new("which").arg("capnp")
.output().unwrap().output;
let path = Path::new(output.as_slice());
let mut path1 = Path::new(path.dirname());
path1.push("../include");
format!("{}", path1.display())
};

let out_dir = os::getenv("OUT_DIR").unwrap();

let _output = Command::new("capnp")
.arg("compile")
.arg(format!("-orust:{}", out_dir))
.arg(format!("--src-prefix={}/capnp", include_dir))
.arg(format!("{}/capnp/rpc.capnp", include_dir))
.arg(format!("{}/capnp/rpc-twoparty.capnp", include_dir))
.output()
.unwrap();

}
4 changes: 2 additions & 2 deletions src/ez_rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl EzRpcClient {

let addr : ip::SocketAddr = std::from_str::FromStr::from_str(server_address).expect("bad server address");

let tcp = try!(tcp::TcpStream::connect(format!("{}", addr.ip).as_slice(), addr.port));
let tcp = try!(tcp::TcpStream::connect(addr));

let connection_state = RpcConnectionState::new();

Expand Down Expand Up @@ -132,7 +132,7 @@ impl EzRpcServer {

let addr : ip::SocketAddr = std::from_str::FromStr::from_str(bind_address).expect("bad bind address");

let tcp_listener = try!(tcp::TcpListener::bind(format!("{}", addr.ip).as_slice(), addr.port));
let tcp_listener = try!(tcp::TcpListener::bind(addr));

let tcp_acceptor = try!(tcp_listener.listen());

Expand Down
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ extern crate core;
extern crate capnp;
extern crate sync;

extern crate capnp_rpc_include_generated;

pub use capnp_rpc_include_generated::rpc_capnp;
pub mod rpc_capnp {
include!(concat!(env!("OUT_DIR"), "/rpc_capnp.rs"))
}

pub mod capability;
pub mod ez_rpc;
Expand Down
4 changes: 3 additions & 1 deletion src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ use std::any::AnyRefExt;
use std::vec::Vec;
use std::collections::hash_map::HashMap;
use std::collections::binary_heap::BinaryHeap;
use std::ops::IndexMut;

use sync::{Arc, Mutex};

use rpc_capnp::{message, return_, cap_descriptor, message_target, payload, promised_answer};
Expand Down Expand Up @@ -507,7 +509,7 @@ impl RpcConnectionState {
match receiver {
Nobody => {}
QuestionReceiver(id) => {
let erase_it = match questions.slots.get_mut(id as uint) {
let erase_it = match questions.slots.index_mut(&(id as uint)) {
&Some(ref mut q) => {
q.chan.send_opt(
box RpcResponse::new(message) as Box<ResponseHook+Send>).is_ok();
Expand Down

0 comments on commit 33ac799

Please sign in to comment.