Skip to content

Commit fc3297f

Browse files
committed
auto merge of #8499 : nickdesaulniers/rust/issue7169, r=graydon
review? @brson tests are green
2 parents 435020e + 0932ab3 commit fc3297f

File tree

6 files changed

+27
-32
lines changed

6 files changed

+27
-32
lines changed

src/librustc/driver/driver.rs

+13-16
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,14 @@ pub fn source_name(input: &input) -> @str {
6565
}
6666
}
6767
68-
pub fn default_configuration(sess: Session, argv0: @str, input: &input) ->
68+
pub fn default_configuration(sess: Session) ->
6969
ast::CrateConfig {
70-
let (libc, tos) = match sess.targ_cfg.os {
71-
session::os_win32 => (@"msvcrt.dll", @"win32"),
72-
session::os_macos => (@"libc.dylib", @"macos"),
73-
session::os_linux => (@"libc.so.6", @"linux"),
74-
session::os_android => (@"libc.so", @"android"),
75-
session::os_freebsd => (@"libc.so.7", @"freebsd")
70+
let tos = match sess.targ_cfg.os {
71+
session::os_win32 => @"win32",
72+
session::os_macos => @"macos",
73+
session::os_linux => @"linux",
74+
session::os_android => @"android",
75+
session::os_freebsd => @"freebsd"
7676
};
7777

7878
// ARM is bi-endian, however using NDK seems to default
@@ -92,10 +92,7 @@ pub fn default_configuration(sess: Session, argv0: @str, input: &input) ->
9292
mk(@"target_arch", arch),
9393
mk(@"target_endian", end),
9494
mk(@"target_word_size", wordsz),
95-
mk(@"target_libc", libc),
96-
// Build bindings.
97-
mk(@"build_compiler", argv0),
98-
mk(@"build_input", source_name(input))];
95+
];
9996
}
10097

10198
pub fn append_configuration(cfg: &mut ast::CrateConfig, name: @str) {
@@ -104,11 +101,11 @@ pub fn append_configuration(cfg: &mut ast::CrateConfig, name: @str) {
104101
}
105102
}
106103

107-
pub fn build_configuration(sess: Session, argv0: @str, input: &input) ->
104+
pub fn build_configuration(sess: Session) ->
108105
ast::CrateConfig {
109106
// Combine the configuration requested by the session (command line) with
110107
// some default and generated configuration items
111-
let default_cfg = default_configuration(sess, argv0, input);
108+
let default_cfg = default_configuration(sess);
112109
let mut user_cfg = sess.opts.cfg.clone();
113110
// If the user wants a test runner, then add the test cfg
114111
if sess.opts.test { append_configuration(&mut user_cfg, @"test") }
@@ -980,7 +977,7 @@ pub fn list_metadata(sess: Session, path: &Path, out: @io::Writer) {
980977
mod test {
981978

982979
use driver::driver::{build_configuration, build_session};
983-
use driver::driver::{build_session_options, optgroups, str_input};
980+
use driver::driver::{build_session_options, optgroups};
984981

985982
use extra::getopts::groups::getopts;
986983
use extra::getopts;
@@ -998,7 +995,7 @@ mod test {
998995
let sessopts = build_session_options(
999996
@"rustc", matches, diagnostic::emit);
1000997
let sess = build_session(sessopts, diagnostic::emit);
1001-
let cfg = build_configuration(sess, @"whatever", &str_input(@""));
998+
let cfg = build_configuration(sess);
1002999
assert!((attr::contains_name(cfg, "test")));
10031000
}
10041001

@@ -1016,7 +1013,7 @@ mod test {
10161013
let sessopts = build_session_options(
10171014
@"rustc", matches, diagnostic::emit);
10181015
let sess = build_session(sessopts, diagnostic::emit);
1019-
let cfg = build_configuration(sess, @"whatever", &str_input(@""));
1016+
let cfg = build_configuration(sess);
10201017
let mut test_items = cfg.iter().filter(|m| "test" == m.name());
10211018
assert!(test_items.next().is_some());
10221019
assert!(test_items.next().is_none());

src/librustc/rustc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ pub fn run_compiler(args: &~[~str], demitter: diagnostic::Emitter) {
252252
let sess = build_session(sopts, demitter);
253253
let odir = getopts::opt_maybe_str(matches, "out-dir").map_move(|o| Path(o));
254254
let ofile = getopts::opt_maybe_str(matches, "o").map_move(|o| Path(o));
255-
let cfg = build_configuration(sess, binary, &input);
255+
let cfg = build_configuration(sess);
256256
let pretty = do getopts::opt_default(matches, "pretty", "normal").map_move |a| {
257257
parse_pretty(sess, a)
258258
};

src/librustdoc/parse.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
//! AST-parsing helpers
1212
13-
14-
use rustc::driver::driver::{file_input, str_input};
1513
use rustc::driver::driver;
1614
use rustc::driver::session;
1715
use syntax::ast;
@@ -29,14 +27,15 @@ pub fn from_str(source: @str) -> @ast::Crate {
2927
3028
pub fn from_file_sess(sess: session::Session, file: &Path) -> @ast::Crate {
3129
parse::parse_crate_from_file(
32-
file, cfg(sess, file_input((*file).clone())), sess.parse_sess)
30+
file, cfg(sess), sess.parse_sess)
3331
}
3432
3533
pub fn from_str_sess(sess: session::Session, source: @str) -> @ast::Crate {
3634
parse::parse_crate_from_source_str(
37-
@"-", source, cfg(sess, str_input(source)), sess.parse_sess)
35+
@"-", source, cfg(sess), sess.parse_sess)
3836
}
3937

40-
fn cfg(sess: session::Session, input: driver::input) -> ast::CrateConfig {
41-
driver::build_configuration(sess, @"rustdoc", &input)
38+
fn cfg(sess: session::Session) -> ast::CrateConfig {
39+
driver::build_configuration(sess)
4240
}
41+

src/librusti/rusti.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ fn run(mut program: ~Program, binary: ~str, lib_search_paths: ~[~str],
142142
// Stage 1: parse the input and filter it into the program (as necessary)
143143
//
144144
debug!("parsing: %s", input);
145-
let crate = parse_input(sess, binary, input);
145+
let crate = parse_input(sess, binary);
146146
let mut to_run = ~[]; // statements to run (emitted back into code)
147147
let new_locals = @mut ~[]; // new locals being defined
148148
let mut result = None; // resultant expression (to print via pp)
@@ -222,7 +222,7 @@ fn run(mut program: ~Program, binary: ~str, lib_search_paths: ~[~str],
222222
let test = program.test_code(input, &result, *new_locals);
223223
debug!("testing with ^^^^^^ %?", (||{ println(test) })());
224224
let dinput = driver::str_input(test.to_managed());
225-
let cfg = driver::build_configuration(sess, binary, &dinput);
225+
let cfg = driver::build_configuration(sess);
226226

227227
let crate = driver::phase_1_parse_input(sess, cfg.clone(), &dinput);
228228
let expanded_crate = driver::phase_2_configure_and_expand(sess, cfg, crate);
@@ -241,7 +241,7 @@ fn run(mut program: ~Program, binary: ~str, lib_search_paths: ~[~str],
241241
let code = program.code(input, &result);
242242
debug!("actually running ^^^^^^ %?", (||{ println(code) })());
243243
let input = driver::str_input(code.to_managed());
244-
let cfg = driver::build_configuration(sess, binary, &input);
244+
let cfg = driver::build_configuration(sess);
245245
let outputs = driver::build_output_filenames(&input, &None, &None, [], sess);
246246
let sess = driver::build_session(options, diagnostic::emit);
247247

@@ -266,11 +266,10 @@ fn run(mut program: ~Program, binary: ~str, lib_search_paths: ~[~str],
266266
//
267267
return (program, jit::consume_engine());
268268

269-
fn parse_input(sess: session::Session, binary: @str,
270-
input: &str) -> @ast::Crate {
269+
fn parse_input(sess: session::Session, input: &str) -> @ast::Crate {
271270
let code = fmt!("fn main() {\n %s \n}", input);
272271
let input = driver::str_input(code.to_managed());
273-
let cfg = driver::build_configuration(sess, binary, &input);
272+
let cfg = driver::build_configuration(sess);
274273
driver::phase_1_parse_input(sess, cfg.clone(), &input)
275274
}
276275

@@ -308,7 +307,7 @@ fn compile_crate(src_filename: ~str, binary: ~str) -> Option<bool> {
308307
let input = driver::file_input(src_path.clone());
309308
let sess = driver::build_session(options, diagnostic::emit);
310309
*sess.building_library = true;
311-
let cfg = driver::build_configuration(sess, binary, &input);
310+
let cfg = driver::build_configuration(sess);
312311
let outputs = driver::build_output_filenames(
313312
&input, &None, &None, [], sess);
314313
// If the library already exists and is newer than the source

src/librustpkg/rustpkg.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ impl<'self> PkgScript<'self> {
108108
};
109109
let input = driver::file_input(script);
110110
let sess = driver::build_session(options, diagnostic::emit);
111-
let cfg = driver::build_configuration(sess, binary, &input);
111+
let cfg = driver::build_configuration(sess);
112112
let crate = driver::phase_1_parse_input(sess, cfg.clone(), &input);
113113
let crate = driver::phase_2_configure_and_expand(sess, cfg.clone(), crate);
114114
let work_dir = build_pkg_id_in_workspace(id, workspace);

src/librustpkg/util.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ pub fn compile_input(ctxt: &Ctx,
225225

226226
// Infer dependencies that rustpkg needs to build, by scanning for
227227
// `extern mod` directives.
228-
let cfg = driver::build_configuration(sess, binary, &input);
228+
let cfg = driver::build_configuration(sess);
229229
let mut crate = driver::phase_1_parse_input(sess, cfg.clone(), &input);
230230
crate = driver::phase_2_configure_and_expand(sess, cfg, crate);
231231

0 commit comments

Comments
 (0)