-Subproject commit add50d98e97ef30e7264ae70b83cf5ddedbf4450
+Subproject commit de700414aab1aaa4461618ce7a516cb24a8e6665
-Subproject commit 1702321fb1300aaf4182f4ba48d31f8eaf0a5a69
+Subproject commit e248cfbd6e336c3ea1a7273bea66e2fd3e3591f6
Err(err) => return handle_error(err)
};
- if cmd == ~"config-for-key" { execute_main_without_stdin(config_for_key) }
- else if cmd == ~"config-list" { execute_main_without_stdin(config_list) }
- else if cmd == ~"locate-project" { execute_main_without_stdin(locate_project) }
+ if cmd == "config-for-key".to_owned() { execute_main_without_stdin(config_for_key) }
+ else if cmd == "config-list".to_owned() { execute_main_without_stdin(config_list) }
+ else if cmd == "locate-project".to_owned() { execute_main_without_stdin(locate_project) }
}
fn process(mut args: ~[~str]) -> CargoResult<(~str, ~[~str])> {
args = args.tail().to_owned();
- let head = try!(args.head().to_cargo_error(~"No subcommand found", 1)).to_owned();
+ let head = try!(args.head().to_cargo_error("No subcommand found".to_owned(), 1)).to_owned();
let tail = args.tail().to_owned();
Ok((head, tail))
}
fn locate_project(_: NoFlags) -> CargoResult<Option<ProjectLocation>> {
- let root = try!(find_project(os::getcwd(), ~"Cargo.toml"));
+ let root = try!(find_project(os::getcwd(), "Cargo.toml".to_owned()));
let string = try!(root.as_str().to_cargo_error(format!("Your project path contains characters not representable in Unicode: {}", os::getcwd().display()), 1));
Ok(Some(ProjectLocation { root: string.to_owned() }))
}
project: project.clone(),
lib: lib,
bin: bin,
- target: ~"target",
+ target: "target".to_owned(),
dependencies: deps
})
}
fn json_from_stdin<T: RepresentsJSON>() -> CargoResult<T> {
let mut reader = io::stdin();
- let input = try!(reader.read_to_str().to_cargo_error(~"Cannot read stdin to a string", 1));
+ let input = try!(reader.read_to_str().to_cargo_error("Cannot read stdin to a string".to_owned(), 1));
let json = try!(json::from_str(input).to_cargo_error(format!("Cannot parse json: {}", input), 1));
let mut decoder = json::Decoder::new(json);
use ops::cargo_rustc;
use {CargoError,ToCargoError,CargoResult};
-#[deriving(Decodable)]
-struct Options {
- manifest_path: ~str
-}
-
-impl FlagConfig for Options {
- fn config(_: Option<Options>, c: FlagConfiguration) -> FlagConfiguration { c }
-}
-pub fn compile() -> CargoResult<()> {
- let options = try!(flags::<Options>());
- let manifest = try!(cargo_read_manifest(options.manifest_path));
+pub fn compile(manifest_path: &str) -> CargoResult<()> {
+ let manifest = try!(cargo_read_manifest(manifest_path));
let configs = try!(all_configs(os::getcwd()));
- let config_paths = configs.find(&~"paths").map(|v| v.clone()).unwrap_or_else(|| ConfigValue::new());
+ let config_paths = configs.find(&("paths".to_owned())).map(|v| v.clone()).unwrap_or_else(|| ConfigValue::new());
let paths = match config_paths.get_value() {
- &config::String(_) => return Err(CargoError::new(~"The path was configured as a String instead of a List", 1)),
+ &config::String(_) => return Err(CargoError::new("The path was configured as a String instead of a List".to_owned(), 1)),
&config::List(ref list) => list.iter().map(|path| Path::new(path.as_slice())).collect()
};
//call_rustc(~BufReader::new(manifest_bytes.as_slice()))
}
-fn flags<T: FlagConfig + Decodable<FlagDecoder, HammerError>>() -> CargoResult<T> {
- let mut decoder = FlagDecoder::new::<T>(std::os::args().tail());
- Decodable::decode(&mut decoder).to_cargo_error(|e: HammerError| e.message, 1)
-}
fn read_manifest(manifest_path: &str) -> CargoResult<Vec<u8>> {
- Ok((try!(exec_with_output("cargo-read-manifest", [~"--manifest-path", manifest_path.to_owned()], None))).output)
+ Ok((try!(exec_with_output("cargo-read-manifest", ["--manifest-path".to_owned(), manifest_path.to_owned()], None))).output)
}
fn call_rustc(mut manifest_data: ~Reader:) -> CargoResult<()> {
fn build_base_args(dst: &mut Args, src: &Path, target: &Path) {
dst.push(src.as_str().unwrap().to_owned());
- dst.push(~"--crate-type");
- dst.push(~"lib");
- dst.push(~"--out-dir");
+ dst.push("--crate-type".to_owned());
+ dst.push("lib".to_owned());
+ dst.push("--out-dir".to_owned());
dst.push(target.as_str().unwrap().to_owned());
}
for dep in deps.iter() {
let target = dep.get_root().join(Path::new(dep.get_target()));
- dst.push(~"-L");
+ dst.push("-L".to_owned());
dst.push(target.as_str().unwrap().to_owned());
}
}
let core::Manifest { root, lib, bin, .. } = manifest;
let (crate_type, out_dir) = if lib.len() > 0 {
- ( ~"lib", lib[0].path )
+ ( "lib".to_owned(), lib[0].path )
} else if bin.len() > 0 {
- ( ~"bin", bin[0].path )
+ ( "bin".to_owned(), bin[0].path )
} else {
- return Err(CargoError::new(~"bad manifest, no lib or bin specified", 1));
+ return Err(CargoError::new("bad manifest, no lib or bin specified".to_owned(), 1));
};
let root = Path::new(root);
- let target = join(&root, ~"target");
+ let target = join(&root, "target".to_owned());
let args = [
join(&root, out_dir),
- ~"--out-dir", target,
- ~"--crate-type", crate_type
+ "--out-dir".to_owned(), target,
+ "--crate-type".to_owned(), crate_type
];
match io::fs::mkdir_recursive(&root.join("target"), io::UserRWX) {
loop {
let possible = current.join(".cargo").join("config");
if possible.exists() {
- let file = try!(io::fs::File::open(&possible).to_cargo_error(~"", 1));
+ let file = try!(io::fs::File::open(&possible).to_cargo_error("".to_owned(), 1));
match walk(file) {
Ok(res) => return Ok(res),
_ => ()
if !current.pop() { break; }
}
- Err(CargoError::new(~"", 1))
+ Err(CargoError::new("".to_owned(), 1))
}
fn walk_tree(pwd: &Path, walk: |io::fs::File| -> CargoResult<()>) -> CargoResult<()> {
loop {
let possible = current.join(".cargo").join("config");
if possible.exists() {
- let file = try!(io::fs::File::open(&possible).to_cargo_error(~"", 1));
+ let file = try!(io::fs::File::open(&possible).to_cargo_error("".to_owned(), 1));
match walk(file) {
Err(_) => err = false,
_ => ()
}
}
- if err { return Err(CargoError::new(~"", 1)); }
+ if err { return Err(CargoError::new("".to_owned(), 1)); }
if !current.pop() { break; }
}
}
fn extract_config(file: io::fs::File, key: &str) -> CargoResult<ConfigValue> {
- let path = try!(file.path().as_str().to_cargo_error(~"", 1)).to_owned();
+ let path = try!(file.path().as_str().to_cargo_error("".to_owned(), 1)).to_owned();
let mut buf = io::BufferedReader::new(file);
- let root = try!(toml::parse_from_buffer(&mut buf).to_cargo_error(~"", 1));
- let val = try!(root.lookup(key).to_cargo_error(~"", 1));
+ let root = try!(toml::parse_from_buffer(&mut buf).to_cargo_error("".to_owned(), 1));
+ let val = try!(root.lookup(key).to_cargo_error("".to_owned(), 1));
let v = match val {
&toml::String(ref val) => String(val.to_owned()),
&toml::Array(ref val) => List(val.iter().map(|s: &toml::Value| s.to_str()).collect()),
- _ => return Err(CargoError::new(~"", 1))
+ _ => return Err(CargoError::new("".to_owned(), 1))
};
Ok(ConfigValue{ value: v, path: vec!(path) })
}
fn extract_all_configs(file: io::fs::File, map: &mut collections::HashMap<~str, ConfigValue>) -> CargoResult<()> {
- let path = try!(file.path().as_str().to_cargo_error(~"", 1)).to_owned();
+ let path = try!(file.path().as_str().to_cargo_error("".to_owned(), 1)).to_owned();
let mut buf = io::BufferedReader::new(file);
- let root = try!(toml::parse_from_buffer(&mut buf).to_cargo_error(~"", 1));
- let table = try!(root.get_table().to_cargo_error(~"", 1));
+ let root = try!(toml::parse_from_buffer(&mut buf).to_cargo_error("".to_owned(), 1));
+ let table = try!(root.get_table().to_cargo_error("".to_owned(), 1));
for (key, value) in table.iter() {
match value {
fn merge_array(existing: &mut ConfigValue, val: &[toml::Value], path: &str) -> CargoResult<()> {
match existing.value {
- String(_) => return Err(CargoError::new(~"", 1)),
+ String(_) => return Err(CargoError::new("".to_owned(), 1)),
List(ref mut list) => {
let new_list: Vec<CargoResult<~str>> = val.iter().map(|s: &toml::Value| toml_string(s)).collect();
if new_list.iter().any(|v| v.is_err()) {
- return Err(CargoError::new(~"", 1));
+ return Err(CargoError::new("".to_owned(), 1));
} else {
let new_list: Vec<~str> = new_list.move_iter().map(|v| v.unwrap()).collect();
list.push_all(new_list.as_slice());
fn toml_string(val: &toml::Value) -> CargoResult<~str> {
match val {
&toml::String(ref str) => Ok(str.to_owned()),
- _ => Err(CargoError::new(~"", 1))
+ _ => Err(CargoError::new("".to_owned(), 1))
}
}
config.args = self.args.as_slice();
config.cwd = Some(&self.cwd);
- let os_path = try!(os::getenv("PATH").to_cargo_error(~"Could not find the PATH environment variable", 1));
+ let os_path = try!(os::getenv("PATH").to_cargo_error("Could not find the PATH environment variable".to_owned(), 1));
let path = os_path + PATH_SEP + self.path.connect(PATH_SEP);
- let path = [(~"PATH", path)];
+ let path = [("PATH".to_owned(), path)];
config.env = Some(path.as_slice());
println!("{:?}", config);
- Process::configure(config).map(|mut ok| ok.wait_with_output()).to_cargo_error(~"Could not spawn process", 1)
+ Process::configure(config).map(|mut ok| ok.wait_with_output()).to_cargo_error("Could not spawn process".to_owned(), 1)
}
}