From 11a56c3e9141045d92ad913495c2387b636f5d9b Mon Sep 17 00:00:00 2001 From: Erick Tryzelaar Date: Wed, 13 Jun 2012 08:30:54 -0700 Subject: [PATCH 1/4] Add a couple more to_json impls. --- src/libstd/json.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/libstd/json.rs b/src/libstd/json.rs index 1ac6a547659..a5a5ac31035 100644 --- a/src/libstd/json.rs +++ b/src/libstd/json.rs @@ -510,6 +510,14 @@ impl of to_json for json { fn to_json() -> json { self } } +impl of to_json for @json { + fn to_json() -> json { *self } +} + +impl of to_json for int { + fn to_json() -> json { num(self as float) } +} + impl of to_json for i8 { fn to_json() -> json { num(self as float) } } @@ -526,6 +534,10 @@ impl of to_json for i64 { fn to_json() -> json { num(self as float) } } +impl of to_json for uint { + fn to_json() -> json { num(self as float) } +} + impl of to_json for u8 { fn to_json() -> json { num(self as float) } } From 065fa9a4621291c12cc69a3f07e1992ce1c7f6a3 Mon Sep 17 00:00:00 2001 From: Erick Tryzelaar Date: Wed, 13 Jun 2012 09:34:43 -0700 Subject: [PATCH 2/4] Make cargo a little more ideomatic --- src/cargo/cargo.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/cargo/cargo.rs b/src/cargo/cargo.rs index 2bfde838bce..a41fcc4e47b 100644 --- a/src/cargo/cargo.rs +++ b/src/cargo/cargo.rs @@ -557,8 +557,8 @@ fn load_source_info(c: cargo, src: source) { if !os::path_exists(srcfile) { ret; } let srcstr = io::read_whole_file_str(srcfile); alt json::from_str(result::get(srcstr)) { - ok(json::dict(_s)) { - let o = parse_source(src.name, json::dict(_s)); + ok(json::dict(s)) { + let o = parse_source(src.name, json::dict(s)); src.key = o.key; src.keyfp = o.keyfp; @@ -635,7 +635,7 @@ fn build_cargo_options(argv: [str]) -> options { fn configure(opts: options) -> cargo { let home = alt get_cargo_root() { - ok(_home) { _home } + ok(home) { home } err(_err) { result::get(get_cargo_sysroot()) } }; @@ -647,11 +647,11 @@ fn configure(opts: options) -> cargo { let p = result::get(get_cargo_dir()); - let sources = map::str_hash::(); + let sources = map::str_hash(); try_parse_sources(path::connect(home, "sources.json"), sources); try_parse_sources(path::connect(home, "local-sources.json"), sources); - let dep_cache = map::str_hash::(); + let dep_cache = map::str_hash(); let mut c = { pgp: pgp::supported(), @@ -799,7 +799,7 @@ fn install_source(c: cargo, path: str) { let wd_base = c.workdir + path::path_sep(); let wd = alt tempfile::mkdtemp(wd_base, "") { - some(_wd) { _wd } + some(wd) { wd } none { fail #fmt("needed temp dir: %s", wd_base); } }; @@ -819,8 +819,8 @@ fn install_source(c: cargo, path: str) { fn install_git(c: cargo, wd: str, url: str, ref: option) { run::program_output("git", ["clone", url, wd]); - if option::is_some::(ref) { - let r = option::get::(ref); + if option::is_some(ref) { + let r = option::get(ref); os::change_dir(wd); run::run_program("git", ["checkout", r]); } @@ -1021,8 +1021,8 @@ fn cmd_uninstall(c: cargo) { fn install_query(c: cargo, wd: str, target: str) { alt c.dep_cache.find(target) { - some(_inst) { - if _inst { + some(inst) { + if inst { ret; } } @@ -1082,7 +1082,7 @@ fn install_query(c: cargo, wd: str, target: str) { fn cmd_install(c: cargo) unsafe { let wd_base = c.workdir + path::path_sep(); let wd = alt tempfile::mkdtemp(wd_base, "") { - some(_wd) { _wd } + some(wd) { wd } none { fail #fmt("needed temp dir: %s", wd_base); } }; From dd17a98a09f4e01220bbb4e9585d939fdbcc89fa Mon Sep 17 00:00:00 2001 From: Erick Tryzelaar Date: Wed, 13 Jun 2012 09:35:10 -0700 Subject: [PATCH 3/4] Fix cargo not making ./.cargo dir --- src/cargo/cargo.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cargo/cargo.rs b/src/cargo/cargo.rs index a41fcc4e47b..598d4cd7148 100644 --- a/src/cargo/cargo.rs +++ b/src/cargo/cargo.rs @@ -668,9 +668,9 @@ fn configure(opts: options) -> cargo { }; need_dir(c.root); + need_dir(c.installdir); need_dir(c.sourcedir); need_dir(c.workdir); - need_dir(c.installdir); need_dir(c.libdir); need_dir(c.bindir); From 78daa1540c62d9264816b344b429e6a63db7971a Mon Sep 17 00:00:00 2001 From: Erick Tryzelaar Date: Wed, 13 Jun 2012 09:36:33 -0700 Subject: [PATCH 4/4] cargo: Recursively copy install fragments This is useful on OS X in order to handle the .dSYM files. --- src/cargo/cargo.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cargo/cargo.rs b/src/cargo/cargo.rs index 598d4cd7148..6f32d0118f5 100644 --- a/src/cargo/cargo.rs +++ b/src/cargo/cargo.rs @@ -1536,7 +1536,7 @@ fn cmd_search(c: cargo) { fn install_to_dir(srcfile: str, destdir: str) { let newfile = path::connect(destdir, path::basename(srcfile)); - let status = run::run_program("cp", [srcfile, newfile]); + let status = run::run_program("cp", ["-r", srcfile, newfile]); if status == 0 { info(#fmt["installed: '%s'", newfile]); } else {