auto merge of #9267 : Kimundi/rust/master, r=huonw
This commit is contained in:
commit
99ec14dbb0
|
@ -91,10 +91,10 @@ pub fn parse_config(args: ~[~str]) -> config {
|
||||||
let matches =
|
let matches =
|
||||||
&match getopts::groups::getopts(args_, groups) {
|
&match getopts::groups::getopts(args_, groups) {
|
||||||
Ok(m) => m,
|
Ok(m) => m,
|
||||||
Err(f) => fail!(getopts::fail_str(f))
|
Err(f) => fail!(f.to_err_msg())
|
||||||
};
|
};
|
||||||
|
|
||||||
if getopts::opt_present(matches, "h") || getopts::opt_present(matches, "help") {
|
if matches.opt_present("h") || matches.opt_present("help") {
|
||||||
let message = fmt!("Usage: %s [OPTIONS] [TESTNAME...]", argv0);
|
let message = fmt!("Usage: %s [OPTIONS] [TESTNAME...]", argv0);
|
||||||
println(getopts::groups::usage(message, groups));
|
println(getopts::groups::usage(message, groups));
|
||||||
println("");
|
println("");
|
||||||
|
@ -102,53 +102,51 @@ pub fn parse_config(args: ~[~str]) -> config {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn opt_path(m: &getopts::Matches, nm: &str) -> Path {
|
fn opt_path(m: &getopts::Matches, nm: &str) -> Path {
|
||||||
Path(getopts::opt_str(m, nm))
|
Path(m.opt_str(nm).unwrap())
|
||||||
}
|
}
|
||||||
|
|
||||||
config {
|
config {
|
||||||
compile_lib_path: getopts::opt_str(matches, "compile-lib-path"),
|
compile_lib_path: matches.opt_str("compile-lib-path").unwrap(),
|
||||||
run_lib_path: getopts::opt_str(matches, "run-lib-path"),
|
run_lib_path: matches.opt_str("run-lib-path").unwrap(),
|
||||||
rustc_path: opt_path(matches, "rustc-path"),
|
rustc_path: opt_path(matches, "rustc-path"),
|
||||||
clang_path: getopts::opt_maybe_str(matches, "clang-path").map_move(|s| Path(s)),
|
clang_path: matches.opt_str("clang-path").map_move(|s| Path(s)),
|
||||||
llvm_bin_path: getopts::opt_maybe_str(matches, "llvm-bin-path").map_move(|s| Path(s)),
|
llvm_bin_path: matches.opt_str("llvm-bin-path").map_move(|s| Path(s)),
|
||||||
src_base: opt_path(matches, "src-base"),
|
src_base: opt_path(matches, "src-base"),
|
||||||
build_base: opt_path(matches, "build-base"),
|
build_base: opt_path(matches, "build-base"),
|
||||||
aux_base: opt_path(matches, "aux-base"),
|
aux_base: opt_path(matches, "aux-base"),
|
||||||
stage_id: getopts::opt_str(matches, "stage-id"),
|
stage_id: matches.opt_str("stage-id").unwrap(),
|
||||||
mode: str_mode(getopts::opt_str(matches, "mode")),
|
mode: str_mode(matches.opt_str("mode").unwrap()),
|
||||||
run_ignored: getopts::opt_present(matches, "ignored"),
|
run_ignored: matches.opt_present("ignored"),
|
||||||
filter:
|
filter:
|
||||||
if !matches.free.is_empty() {
|
if !matches.free.is_empty() {
|
||||||
Some(matches.free[0].clone())
|
Some(matches.free[0].clone())
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
},
|
},
|
||||||
logfile: getopts::opt_maybe_str(matches, "logfile").map_move(|s| Path(s)),
|
logfile: matches.opt_str("logfile").map_move(|s| Path(s)),
|
||||||
save_metrics: getopts::opt_maybe_str(matches, "save-metrics").map_move(|s| Path(s)),
|
save_metrics: matches.opt_str("save-metrics").map_move(|s| Path(s)),
|
||||||
ratchet_metrics:
|
ratchet_metrics:
|
||||||
getopts::opt_maybe_str(matches, "ratchet-metrics").map_move(|s| Path(s)),
|
matches.opt_str("ratchet-metrics").map_move(|s| Path(s)),
|
||||||
ratchet_noise_percent:
|
ratchet_noise_percent:
|
||||||
getopts::opt_maybe_str(matches,
|
matches.opt_str("ratchet-noise-percent").and_then(|s| from_str::<f64>(s)),
|
||||||
"ratchet-noise-percent").map_move(|s|
|
runtool: matches.opt_str("runtool"),
|
||||||
from_str::<f64>(s).unwrap()),
|
rustcflags: matches.opt_str("rustcflags"),
|
||||||
runtool: getopts::opt_maybe_str(matches, "runtool"),
|
jit: matches.opt_present("jit"),
|
||||||
rustcflags: getopts::opt_maybe_str(matches, "rustcflags"),
|
target: opt_str2(matches.opt_str("target")).to_str(),
|
||||||
jit: getopts::opt_present(matches, "jit"),
|
adb_path: opt_str2(matches.opt_str("adb-path")).to_str(),
|
||||||
target: opt_str2(getopts::opt_maybe_str(matches, "target")).to_str(),
|
|
||||||
adb_path: opt_str2(getopts::opt_maybe_str(matches, "adb-path")).to_str(),
|
|
||||||
adb_test_dir:
|
adb_test_dir:
|
||||||
opt_str2(getopts::opt_maybe_str(matches, "adb-test-dir")).to_str(),
|
opt_str2(matches.opt_str("adb-test-dir")).to_str(),
|
||||||
adb_device_status:
|
adb_device_status:
|
||||||
if (opt_str2(getopts::opt_maybe_str(matches, "target")) ==
|
if (opt_str2(matches.opt_str("target")) ==
|
||||||
~"arm-linux-androideabi") {
|
~"arm-linux-androideabi") {
|
||||||
if (opt_str2(getopts::opt_maybe_str(matches, "adb-test-dir")) !=
|
if (opt_str2(matches.opt_str("adb-test-dir")) !=
|
||||||
~"(none)" &&
|
~"(none)" &&
|
||||||
opt_str2(getopts::opt_maybe_str(matches, "adb-test-dir")) !=
|
opt_str2(matches.opt_str("adb-test-dir")) !=
|
||||||
~"") { true }
|
~"") { true }
|
||||||
else { false }
|
else { false }
|
||||||
} else { false },
|
} else { false },
|
||||||
test_shard: test::opt_shard(getopts::opt_maybe_str(matches, "test-shard")),
|
test_shard: test::opt_shard(matches.opt_str("test-shard")),
|
||||||
verbose: getopts::opt_present(matches, "verbose")
|
verbose: matches.opt_present("verbose")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -226,11 +226,11 @@ pub fn parse_opts(args: &[~str]) -> OptRes {
|
||||||
let matches =
|
let matches =
|
||||||
match groups::getopts(args_, optgroups()) {
|
match groups::getopts(args_, optgroups()) {
|
||||||
Ok(m) => m,
|
Ok(m) => m,
|
||||||
Err(f) => return Err(getopts::fail_str(f))
|
Err(f) => return Err(f.to_err_msg())
|
||||||
};
|
};
|
||||||
|
|
||||||
if getopts::opt_present(&matches, "h") { usage(args[0], "h"); }
|
if matches.opt_present("h") { usage(args[0], "h"); }
|
||||||
if getopts::opt_present(&matches, "help") { usage(args[0], "help"); }
|
if matches.opt_present("help") { usage(args[0], "help"); }
|
||||||
|
|
||||||
let filter =
|
let filter =
|
||||||
if matches.free.len() > 0 {
|
if matches.free.len() > 0 {
|
||||||
|
@ -239,25 +239,25 @@ pub fn parse_opts(args: &[~str]) -> OptRes {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
let run_ignored = getopts::opt_present(&matches, "ignored");
|
let run_ignored = matches.opt_present("ignored");
|
||||||
|
|
||||||
let logfile = getopts::opt_maybe_str(&matches, "logfile");
|
let logfile = matches.opt_str("logfile");
|
||||||
let logfile = logfile.map_move(|s| Path(s));
|
let logfile = logfile.map_move(|s| Path(s));
|
||||||
|
|
||||||
let run_benchmarks = getopts::opt_present(&matches, "bench");
|
let run_benchmarks = matches.opt_present("bench");
|
||||||
let run_tests = ! run_benchmarks ||
|
let run_tests = ! run_benchmarks ||
|
||||||
getopts::opt_present(&matches, "test");
|
matches.opt_present("test");
|
||||||
|
|
||||||
let ratchet_metrics = getopts::opt_maybe_str(&matches, "ratchet-metrics");
|
let ratchet_metrics = matches.opt_str("ratchet-metrics");
|
||||||
let ratchet_metrics = ratchet_metrics.map_move(|s| Path(s));
|
let ratchet_metrics = ratchet_metrics.map_move(|s| Path(s));
|
||||||
|
|
||||||
let ratchet_noise_percent = getopts::opt_maybe_str(&matches, "ratchet-noise-percent");
|
let ratchet_noise_percent = matches.opt_str("ratchet-noise-percent");
|
||||||
let ratchet_noise_percent = ratchet_noise_percent.map_move(|s| from_str::<f64>(s).unwrap());
|
let ratchet_noise_percent = ratchet_noise_percent.map_move(|s| from_str::<f64>(s).unwrap());
|
||||||
|
|
||||||
let save_metrics = getopts::opt_maybe_str(&matches, "save-metrics");
|
let save_metrics = matches.opt_str("save-metrics");
|
||||||
let save_metrics = save_metrics.map_move(|s| Path(s));
|
let save_metrics = save_metrics.map_move(|s| Path(s));
|
||||||
|
|
||||||
let test_shard = getopts::opt_maybe_str(&matches, "test-shard");
|
let test_shard = matches.opt_str("test-shard");
|
||||||
let test_shard = opt_shard(test_shard);
|
let test_shard = opt_shard(test_shard);
|
||||||
|
|
||||||
let test_opts = TestOpts {
|
let test_opts = TestOpts {
|
||||||
|
|
|
@ -30,7 +30,6 @@ use std::io;
|
||||||
use std::os;
|
use std::os;
|
||||||
use std::vec;
|
use std::vec;
|
||||||
use extra::getopts::groups::{optopt, optmulti, optflag, optflagopt};
|
use extra::getopts::groups::{optopt, optmulti, optflag, optflagopt};
|
||||||
use extra::getopts::{opt_present};
|
|
||||||
use extra::getopts;
|
use extra::getopts;
|
||||||
use syntax::ast;
|
use syntax::ast;
|
||||||
use syntax::abi;
|
use syntax::abi;
|
||||||
|
@ -606,15 +605,15 @@ pub fn build_session_options(binary: @str,
|
||||||
matches: &getopts::Matches,
|
matches: &getopts::Matches,
|
||||||
demitter: diagnostic::Emitter)
|
demitter: diagnostic::Emitter)
|
||||||
-> @session::options {
|
-> @session::options {
|
||||||
let crate_type = if opt_present(matches, "lib") {
|
let crate_type = if matches.opt_present("lib") {
|
||||||
session::lib_crate
|
session::lib_crate
|
||||||
} else if opt_present(matches, "bin") {
|
} else if matches.opt_present("bin") {
|
||||||
session::bin_crate
|
session::bin_crate
|
||||||
} else {
|
} else {
|
||||||
session::unknown_crate
|
session::unknown_crate
|
||||||
};
|
};
|
||||||
let parse_only = opt_present(matches, "parse-only");
|
let parse_only = matches.opt_present("parse-only");
|
||||||
let no_trans = opt_present(matches, "no-trans");
|
let no_trans = matches.opt_present("no-trans");
|
||||||
|
|
||||||
let lint_levels = [lint::allow, lint::warn,
|
let lint_levels = [lint::allow, lint::warn,
|
||||||
lint::deny, lint::forbid];
|
lint::deny, lint::forbid];
|
||||||
|
@ -627,8 +626,8 @@ pub fn build_session_options(binary: @str,
|
||||||
// to_ascii_move and to_str_move to not do a unnecessary copy.
|
// to_ascii_move and to_str_move to not do a unnecessary copy.
|
||||||
let level_short = level_name.slice_chars(0, 1);
|
let level_short = level_name.slice_chars(0, 1);
|
||||||
let level_short = level_short.to_ascii().to_upper().to_str_ascii();
|
let level_short = level_short.to_ascii().to_upper().to_str_ascii();
|
||||||
let flags = vec::append(getopts::opt_strs(matches, level_short),
|
let flags = vec::append(matches.opt_strs(level_short),
|
||||||
getopts::opt_strs(matches, level_name));
|
matches.opt_strs(level_name));
|
||||||
for lint_name in flags.iter() {
|
for lint_name in flags.iter() {
|
||||||
let lint_name = lint_name.replace("-", "_");
|
let lint_name = lint_name.replace("-", "_");
|
||||||
match lint_dict.find_equiv(&lint_name) {
|
match lint_dict.find_equiv(&lint_name) {
|
||||||
|
@ -644,7 +643,7 @@ pub fn build_session_options(binary: @str,
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut debugging_opts = 0u;
|
let mut debugging_opts = 0u;
|
||||||
let debug_flags = getopts::opt_strs(matches, "Z");
|
let debug_flags = matches.opt_strs("Z");
|
||||||
let debug_map = session::debugging_opts_map();
|
let debug_map = session::debugging_opts_map();
|
||||||
for debug_flag in debug_flags.iter() {
|
for debug_flag in debug_flags.iter() {
|
||||||
let mut this_bit = 0u;
|
let mut this_bit = 0u;
|
||||||
|
@ -670,31 +669,31 @@ pub fn build_session_options(binary: @str,
|
||||||
let output_type =
|
let output_type =
|
||||||
if parse_only || no_trans {
|
if parse_only || no_trans {
|
||||||
link::output_type_none
|
link::output_type_none
|
||||||
} else if opt_present(matches, "S") &&
|
} else if matches.opt_present("S") &&
|
||||||
opt_present(matches, "emit-llvm") {
|
matches.opt_present("emit-llvm") {
|
||||||
link::output_type_llvm_assembly
|
link::output_type_llvm_assembly
|
||||||
} else if opt_present(matches, "S") {
|
} else if matches.opt_present("S") {
|
||||||
link::output_type_assembly
|
link::output_type_assembly
|
||||||
} else if opt_present(matches, "c") {
|
} else if matches.opt_present("c") {
|
||||||
link::output_type_object
|
link::output_type_object
|
||||||
} else if opt_present(matches, "emit-llvm") {
|
} else if matches.opt_present("emit-llvm") {
|
||||||
link::output_type_bitcode
|
link::output_type_bitcode
|
||||||
} else { link::output_type_exe };
|
} else { link::output_type_exe };
|
||||||
let sysroot_opt = getopts::opt_maybe_str(matches, "sysroot").map_move(|m| @Path(m));
|
let sysroot_opt = matches.opt_str("sysroot").map_move(|m| @Path(m));
|
||||||
let target = getopts::opt_maybe_str(matches, "target").unwrap_or(host_triple());
|
let target = matches.opt_str("target").unwrap_or(host_triple());
|
||||||
let target_cpu = getopts::opt_maybe_str(matches, "target-cpu").unwrap_or(~"generic");
|
let target_cpu = matches.opt_str("target-cpu").unwrap_or(~"generic");
|
||||||
let target_feature = getopts::opt_maybe_str(matches, "target-feature").unwrap_or(~"");
|
let target_feature = matches.opt_str("target-feature").unwrap_or(~"");
|
||||||
let save_temps = getopts::opt_present(matches, "save-temps");
|
let save_temps = matches.opt_present("save-temps");
|
||||||
let opt_level = {
|
let opt_level = {
|
||||||
if (debugging_opts & session::no_opt) != 0 {
|
if (debugging_opts & session::no_opt) != 0 {
|
||||||
No
|
No
|
||||||
} else if opt_present(matches, "O") {
|
} else if matches.opt_present("O") {
|
||||||
if opt_present(matches, "opt-level") {
|
if matches.opt_present("opt-level") {
|
||||||
early_error(demitter, ~"-O and --opt-level both provided");
|
early_error(demitter, ~"-O and --opt-level both provided");
|
||||||
}
|
}
|
||||||
Default
|
Default
|
||||||
} else if opt_present(matches, "opt-level") {
|
} else if matches.opt_present("opt-level") {
|
||||||
match getopts::opt_str(matches, "opt-level") {
|
match matches.opt_str("opt-level").unwrap() {
|
||||||
~"0" => No,
|
~"0" => No,
|
||||||
~"1" => Less,
|
~"1" => Less,
|
||||||
~"2" => Default,
|
~"2" => Default,
|
||||||
|
@ -720,18 +719,17 @@ pub fn build_session_options(binary: @str,
|
||||||
|
|
||||||
let statik = debugging_opts & session::statik != 0;
|
let statik = debugging_opts & session::statik != 0;
|
||||||
|
|
||||||
let addl_lib_search_paths = getopts::opt_strs(matches, "L").map(|s| Path(*s));
|
let addl_lib_search_paths = matches.opt_strs("L").map(|s| Path(*s));
|
||||||
let linker = getopts::opt_maybe_str(matches, "linker");
|
let linker = matches.opt_str("linker");
|
||||||
let linker_args = getopts::opt_strs(matches, "link-args").flat_map( |a| {
|
let linker_args = matches.opt_strs("link-args").flat_map( |a| {
|
||||||
a.split_iter(' ').map(|arg| arg.to_owned()).collect()
|
a.split_iter(' ').map(|arg| arg.to_owned()).collect()
|
||||||
});
|
});
|
||||||
|
|
||||||
let cfg = parse_cfgspecs(getopts::opt_strs(matches, "cfg"), demitter);
|
let cfg = parse_cfgspecs(matches.opt_strs("cfg"), demitter);
|
||||||
let test = opt_present(matches, "test");
|
let test = matches.opt_present("test");
|
||||||
let android_cross_path = getopts::opt_maybe_str(
|
let android_cross_path = matches.opt_str("android-cross-path");
|
||||||
matches, "android-cross-path");
|
|
||||||
|
|
||||||
let custom_passes = match getopts::opt_maybe_str(matches, "passes") {
|
let custom_passes = match matches.opt_str("passes") {
|
||||||
None => ~[],
|
None => ~[],
|
||||||
Some(s) => {
|
Some(s) => {
|
||||||
s.split_iter(|c: char| c == ' ' || c == ',').map(|s| {
|
s.split_iter(|c: char| c == ' ' || c == ',').map(|s| {
|
||||||
|
@ -739,7 +737,7 @@ pub fn build_session_options(binary: @str,
|
||||||
}).collect()
|
}).collect()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let llvm_args = match getopts::opt_maybe_str(matches, "llvm-args") {
|
let llvm_args = match matches.opt_str("llvm-args") {
|
||||||
None => ~[],
|
None => ~[],
|
||||||
Some(s) => {
|
Some(s) => {
|
||||||
s.split_iter(|c: char| c == ' ' || c == ',').map(|s| {
|
s.split_iter(|c: char| c == ' ' || c == ',').map(|s| {
|
||||||
|
@ -1020,7 +1018,6 @@ mod test {
|
||||||
use driver::driver::{build_session_options, optgroups};
|
use driver::driver::{build_session_options, optgroups};
|
||||||
|
|
||||||
use extra::getopts::groups::getopts;
|
use extra::getopts::groups::getopts;
|
||||||
use extra::getopts;
|
|
||||||
use syntax::attr;
|
use syntax::attr;
|
||||||
use syntax::diagnostic;
|
use syntax::diagnostic;
|
||||||
|
|
||||||
|
@ -1030,7 +1027,7 @@ mod test {
|
||||||
let matches =
|
let matches =
|
||||||
&match getopts([~"--test"], optgroups()) {
|
&match getopts([~"--test"], optgroups()) {
|
||||||
Ok(m) => m,
|
Ok(m) => m,
|
||||||
Err(f) => fail!("test_switch_implies_cfg_test: %s", getopts::fail_str(f))
|
Err(f) => fail!("test_switch_implies_cfg_test: %s", f.to_err_msg())
|
||||||
};
|
};
|
||||||
let sessopts = build_session_options(
|
let sessopts = build_session_options(
|
||||||
@"rustc", matches, diagnostic::emit);
|
@"rustc", matches, diagnostic::emit);
|
||||||
|
@ -1047,7 +1044,7 @@ mod test {
|
||||||
&match getopts([~"--test", ~"--cfg=test"], optgroups()) {
|
&match getopts([~"--test", ~"--cfg=test"], optgroups()) {
|
||||||
Ok(m) => m,
|
Ok(m) => m,
|
||||||
Err(f) => {
|
Err(f) => {
|
||||||
fail!("test_switch_implies_cfg_test_unless_cfg_test: %s", getopts::fail_str(f));
|
fail!("test_switch_implies_cfg_test_unless_cfg_test: %s", f.to_err_msg());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let sessopts = build_session_options(
|
let sessopts = build_session_options(
|
||||||
|
|
|
@ -40,7 +40,7 @@ use std::result;
|
||||||
use std::str;
|
use std::str;
|
||||||
use std::task;
|
use std::task;
|
||||||
use std::vec;
|
use std::vec;
|
||||||
use extra::getopts::{groups, opt_present};
|
use extra::getopts::groups;
|
||||||
use extra::getopts;
|
use extra::getopts;
|
||||||
use syntax::codemap;
|
use syntax::codemap;
|
||||||
use syntax::diagnostic;
|
use syntax::diagnostic;
|
||||||
|
@ -204,39 +204,39 @@ pub fn run_compiler(args: &[~str], demitter: diagnostic::Emitter) {
|
||||||
&match getopts::groups::getopts(args, optgroups()) {
|
&match getopts::groups::getopts(args, optgroups()) {
|
||||||
Ok(m) => m,
|
Ok(m) => m,
|
||||||
Err(f) => {
|
Err(f) => {
|
||||||
early_error(demitter, getopts::fail_str(f));
|
early_error(demitter, f.to_err_msg());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if opt_present(matches, "h") || opt_present(matches, "help") {
|
if matches.opt_present("h") || matches.opt_present("help") {
|
||||||
usage(binary);
|
usage(binary);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Display the available lint options if "-W help" or only "-W" is given.
|
// Display the available lint options if "-W help" or only "-W" is given.
|
||||||
let lint_flags = vec::append(getopts::opt_strs(matches, "W"),
|
let lint_flags = vec::append(matches.opt_strs("W"),
|
||||||
getopts::opt_strs(matches, "warn"));
|
matches.opt_strs("warn"));
|
||||||
|
|
||||||
let show_lint_options = lint_flags.iter().any(|x| x == &~"help") ||
|
let show_lint_options = lint_flags.iter().any(|x| x == &~"help") ||
|
||||||
(opt_present(matches, "W") && lint_flags.is_empty());
|
(matches.opt_present("W") && lint_flags.is_empty());
|
||||||
|
|
||||||
if show_lint_options {
|
if show_lint_options {
|
||||||
describe_warnings();
|
describe_warnings();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let r = getopts::opt_strs(matches, "Z");
|
let r = matches.opt_strs("Z");
|
||||||
if r.iter().any(|x| x == &~"help") {
|
if r.iter().any(|x| x == &~"help") {
|
||||||
describe_debug_flags();
|
describe_debug_flags();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if getopts::opt_maybe_str(matches, "passes") == Some(~"list") {
|
if matches.opt_str("passes") == Some(~"list") {
|
||||||
unsafe { lib::llvm::llvm::LLVMRustPrintPasses(); }
|
unsafe { lib::llvm::llvm::LLVMRustPrintPasses(); }
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if opt_present(matches, "v") || opt_present(matches, "version") {
|
if matches.opt_present("v") || matches.opt_present("version") {
|
||||||
version(binary);
|
version(binary);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -256,10 +256,10 @@ pub fn run_compiler(args: &[~str], demitter: diagnostic::Emitter) {
|
||||||
|
|
||||||
let sopts = build_session_options(binary, matches, demitter);
|
let sopts = build_session_options(binary, matches, demitter);
|
||||||
let sess = build_session(sopts, demitter);
|
let sess = build_session(sopts, demitter);
|
||||||
let odir = getopts::opt_maybe_str(matches, "out-dir").map_move(|o| Path(o));
|
let odir = matches.opt_str("out-dir").map_move(|o| Path(o));
|
||||||
let ofile = getopts::opt_maybe_str(matches, "o").map_move(|o| Path(o));
|
let ofile = matches.opt_str("o").map_move(|o| Path(o));
|
||||||
let cfg = build_configuration(sess);
|
let cfg = build_configuration(sess);
|
||||||
let pretty = do getopts::opt_default(matches, "pretty", "normal").map_move |a| {
|
let pretty = do matches.opt_default("pretty", "normal").map_move |a| {
|
||||||
parse_pretty(sess, a)
|
parse_pretty(sess, a)
|
||||||
};
|
};
|
||||||
match pretty {
|
match pretty {
|
||||||
|
@ -269,7 +269,7 @@ pub fn run_compiler(args: &[~str], demitter: diagnostic::Emitter) {
|
||||||
}
|
}
|
||||||
None::<PpMode> => {/* continue */ }
|
None::<PpMode> => {/* continue */ }
|
||||||
}
|
}
|
||||||
let ls = opt_present(matches, "ls");
|
let ls = matches.opt_present("ls");
|
||||||
if ls {
|
if ls {
|
||||||
match input {
|
match input {
|
||||||
file_input(ref ifile) => {
|
file_input(ref ifile) => {
|
||||||
|
|
|
@ -125,7 +125,7 @@ pub fn parse_config_(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(f) => {
|
Err(f) => {
|
||||||
Err(getopts::fail_str(f))
|
Err(f.to_err_msg())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -139,7 +139,7 @@ fn config_from_opts(
|
||||||
let config = default_config(input_crate);
|
let config = default_config(input_crate);
|
||||||
let result = result::Ok(config);
|
let result = result::Ok(config);
|
||||||
let result = do result.and_then |config| {
|
let result = do result.and_then |config| {
|
||||||
let output_dir = getopts::opt_maybe_str(matches, opt_output_dir());
|
let output_dir = matches.opt_str(opt_output_dir());
|
||||||
let output_dir = output_dir.map_move(|s| Path(s));
|
let output_dir = output_dir.map_move(|s| Path(s));
|
||||||
result::Ok(Config {
|
result::Ok(Config {
|
||||||
output_dir: output_dir.unwrap_or(config.output_dir.clone()),
|
output_dir: output_dir.unwrap_or(config.output_dir.clone()),
|
||||||
|
@ -147,7 +147,7 @@ fn config_from_opts(
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
let result = do result.and_then |config| {
|
let result = do result.and_then |config| {
|
||||||
let output_format = getopts::opt_maybe_str(matches, opt_output_format());
|
let output_format = matches.opt_str(opt_output_format());
|
||||||
do output_format.map_move_default(result::Ok(config.clone())) |output_format| {
|
do output_format.map_move_default(result::Ok(config.clone())) |output_format| {
|
||||||
do parse_output_format(output_format).and_then |output_format| {
|
do parse_output_format(output_format).and_then |output_format| {
|
||||||
result::Ok(Config {
|
result::Ok(Config {
|
||||||
|
@ -159,7 +159,7 @@ fn config_from_opts(
|
||||||
};
|
};
|
||||||
let result = do result.and_then |config| {
|
let result = do result.and_then |config| {
|
||||||
let output_style =
|
let output_style =
|
||||||
getopts::opt_maybe_str(matches, opt_output_style());
|
matches.opt_str(opt_output_style());
|
||||||
do output_style.map_move_default(result::Ok(config.clone())) |output_style| {
|
do output_style.map_move_default(result::Ok(config.clone())) |output_style| {
|
||||||
do parse_output_style(output_style).and_then |output_style| {
|
do parse_output_style(output_style).and_then |output_style| {
|
||||||
result::Ok(Config {
|
result::Ok(Config {
|
||||||
|
@ -171,7 +171,7 @@ fn config_from_opts(
|
||||||
};
|
};
|
||||||
let process_output = Cell::new(process_output);
|
let process_output = Cell::new(process_output);
|
||||||
let result = do result.and_then |config| {
|
let result = do result.and_then |config| {
|
||||||
let pandoc_cmd = getopts::opt_maybe_str(matches, opt_pandoc_cmd());
|
let pandoc_cmd = matches.opt_str(opt_pandoc_cmd());
|
||||||
let pandoc_cmd = maybe_find_pandoc(
|
let pandoc_cmd = maybe_find_pandoc(
|
||||||
&config, pandoc_cmd, process_output.take());
|
&config, pandoc_cmd, process_output.take());
|
||||||
do pandoc_cmd.and_then |pandoc_cmd| {
|
do pandoc_cmd.and_then |pandoc_cmd| {
|
||||||
|
|
|
@ -641,53 +641,53 @@ pub fn main_args(args: &[~str]) {
|
||||||
let matches = &match getopts::getopts(args, opts) {
|
let matches = &match getopts::getopts(args, opts) {
|
||||||
result::Ok(m) => m,
|
result::Ok(m) => m,
|
||||||
result::Err(f) => {
|
result::Err(f) => {
|
||||||
error(fmt!("%s", getopts::fail_str(f)));
|
error(fmt!("%s", f.to_err_msg()));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let mut help = getopts::opt_present(matches, "h") ||
|
let mut help = matches.opt_present("h") ||
|
||||||
getopts::opt_present(matches, "help");
|
matches.opt_present("help");
|
||||||
let no_link = getopts::opt_present(matches, "no-link");
|
let no_link = matches.opt_present("no-link");
|
||||||
let no_trans = getopts::opt_present(matches, "no-trans");
|
let no_trans = matches.opt_present("no-trans");
|
||||||
let supplied_sysroot = getopts::opt_val(matches, "sysroot");
|
let supplied_sysroot = matches.opt_val("sysroot");
|
||||||
let generate_asm = getopts::opt_present(matches, "S") ||
|
let generate_asm = matches.opt_present("S") ||
|
||||||
getopts::opt_present(matches, "assembly");
|
matches.opt_present("assembly");
|
||||||
let parse_only = getopts::opt_present(matches, "parse-only");
|
let parse_only = matches.opt_present("parse-only");
|
||||||
let pretty = getopts::opt_present(matches, "pretty");
|
let pretty = matches.opt_present("pretty");
|
||||||
let emit_llvm = getopts::opt_present(matches, "emit-llvm");
|
let emit_llvm = matches.opt_present("emit-llvm");
|
||||||
|
|
||||||
if getopts::opt_present(matches, "v") ||
|
if matches.opt_present("v") ||
|
||||||
getopts::opt_present(matches, "version") {
|
matches.opt_present("version") {
|
||||||
rustc::version(args[0]);
|
rustc::version(args[0]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let use_rust_path_hack = getopts::opt_present(matches, "r") ||
|
let use_rust_path_hack = matches.opt_present("r") ||
|
||||||
getopts::opt_present(matches, "rust-path-hack");
|
matches.opt_present("rust-path-hack");
|
||||||
|
|
||||||
let linker = getopts::opt_maybe_str(matches, "linker");
|
let linker = matches.opt_str("linker");
|
||||||
let link_args = getopts::opt_maybe_str(matches, "link-args");
|
let link_args = matches.opt_str("link-args");
|
||||||
let cfgs = getopts::opt_strs(matches, "cfg") + getopts::opt_strs(matches, "c");
|
let cfgs = matches.opt_strs("cfg") + matches.opt_strs("c");
|
||||||
let mut user_supplied_opt_level = true;
|
let mut user_supplied_opt_level = true;
|
||||||
let opt_level = match getopts::opt_maybe_str(matches, "opt-level") {
|
let opt_level = match matches.opt_str("opt-level") {
|
||||||
Some(~"0") => session::No,
|
Some(~"0") => session::No,
|
||||||
Some(~"1") => session::Less,
|
Some(~"1") => session::Less,
|
||||||
Some(~"2") => session::Default,
|
Some(~"2") => session::Default,
|
||||||
Some(~"3") => session::Aggressive,
|
Some(~"3") => session::Aggressive,
|
||||||
_ if getopts::opt_present(matches, "O") => session::Default,
|
_ if matches.opt_present("O") => session::Default,
|
||||||
_ => {
|
_ => {
|
||||||
user_supplied_opt_level = false;
|
user_supplied_opt_level = false;
|
||||||
session::No
|
session::No
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let save_temps = getopts::opt_present(matches, "save-temps");
|
let save_temps = matches.opt_present("save-temps");
|
||||||
let target = getopts::opt_maybe_str(matches, "target");
|
let target = matches.opt_str("target");
|
||||||
let target_cpu = getopts::opt_maybe_str(matches, "target-cpu");
|
let target_cpu = matches.opt_str("target-cpu");
|
||||||
let experimental_features = {
|
let experimental_features = {
|
||||||
let strs = getopts::opt_strs(matches, "Z");
|
let strs = matches.opt_strs("Z");
|
||||||
if getopts::opt_present(matches, "Z") {
|
if matches.opt_present("Z") {
|
||||||
Some(strs)
|
Some(strs)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -41,7 +41,6 @@ pub fn main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn main_args(args: &[~str]) {
|
pub fn main_args(args: &[~str]) {
|
||||||
use extra::getopts::*;
|
|
||||||
use extra::getopts::groups::*;
|
use extra::getopts::groups::*;
|
||||||
|
|
||||||
let opts = ~[
|
let opts = ~[
|
||||||
|
@ -56,20 +55,20 @@ pub fn main_args(args: &[~str]) {
|
||||||
|
|
||||||
let matches = getopts(args.tail(), opts).unwrap();
|
let matches = getopts(args.tail(), opts).unwrap();
|
||||||
|
|
||||||
if opt_present(&matches, "h") || opt_present(&matches, "help") {
|
if matches.opt_present("h") || matches.opt_present("help") {
|
||||||
println(usage(args[0], opts));
|
println(usage(args[0], opts));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let libs = Cell::new(opt_strs(&matches, "L").map(|s| Path(*s)));
|
let libs = Cell::new(matches.opt_strs("L").map(|s| Path(*s)));
|
||||||
|
|
||||||
let mut passes = if opt_present(&matches, "n") {
|
let mut passes = if matches.opt_present("n") {
|
||||||
~[]
|
~[]
|
||||||
} else {
|
} else {
|
||||||
~[~"collapse-docs", ~"clean-comments", ~"collapse-privacy" ]
|
~[~"collapse-docs", ~"clean-comments", ~"collapse-privacy" ]
|
||||||
};
|
};
|
||||||
|
|
||||||
opt_strs(&matches, "a").map(|x| passes.push(x.clone()));
|
matches.opt_strs("a").map(|x| passes.push(x.clone()));
|
||||||
|
|
||||||
if matches.free.len() != 1 {
|
if matches.free.len() != 1 {
|
||||||
println(usage(args[0], opts));
|
println(usage(args[0], opts));
|
||||||
|
@ -99,7 +98,7 @@ pub fn main_args(args: &[~str]) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
for pname in opt_strs(&matches, "p").move_iter() {
|
for pname in matches.opt_strs("p").move_iter() {
|
||||||
pm.load_plugin(pname);
|
pm.load_plugin(pname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ fn parse_opts(argv: ~[~str]) -> Config {
|
||||||
|
|
||||||
match getopts::getopts(opt_args, opts) {
|
match getopts::getopts(opt_args, opts) {
|
||||||
Ok(ref m) => {
|
Ok(ref m) => {
|
||||||
return Config {stress: getopts::opt_present(m, "stress")}
|
return Config {stress: m.opt_present("stress")}
|
||||||
}
|
}
|
||||||
Err(_) => { fail!(); }
|
Err(_) => { fail!(); }
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,8 +20,8 @@ pub fn main() {
|
||||||
|
|
||||||
match getopts(args, opts) {
|
match getopts(args, opts) {
|
||||||
Ok(ref m) =>
|
Ok(ref m) =>
|
||||||
assert!(!opt_present(m, "b")),
|
assert!(!m.opt_present("b")),
|
||||||
Err(ref f) => fail!(fail_str((*f).clone()))
|
Err(ref f) => fail!((*f).clone().to_err_msg())
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue