Skip to content

Commit 61edb0c

Browse files
committed
Separate the driver into its own crate that uses trans, typeck.
1 parent 93eb433 commit 61edb0c

File tree

11 files changed

+100
-61
lines changed

11 files changed

+100
-61
lines changed

mk/crates.mk

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ TARGET_CRATES := libc std flate arena term \
5353
serialize getopts collections test time rand \
5454
log regex graphviz core rbml alloc rustrt \
5555
unicode
56-
HOST_CRATES := syntax rustc rustc_typeck rustc_trans rustdoc regex_macros fmt_macros \
57-
rustc_llvm rustc_back
56+
RUSTC_CRATES := rustc rustc_typeck rustc_driver rustc_trans rustc_back rustc_llvm
57+
HOST_CRATES := syntax $(RUSTC_CRATES) rustdoc regex_macros fmt_macros
5858
CRATES := $(TARGET_CRATES) $(HOST_CRATES)
5959
TOOLS := compiletest rustdoc rustc
6060

@@ -67,14 +67,16 @@ DEPS_std := core libc rand alloc collections rustrt unicode \
6767
native:rust_builtin native:backtrace
6868
DEPS_graphviz := std
6969
DEPS_syntax := std term serialize log fmt_macros arena libc
70+
DEPS_rustc_driver := arena flate getopts graphviz libc rustc rustc_back \
71+
rustc_typeck log syntax serialize rustc_llvm rustc_trans
7072
DEPS_rustc_trans := arena flate getopts graphviz libc rustc rustc_back \
71-
rustc_typeck log syntax serialize rustc_llvm
73+
log syntax serialize rustc_llvm
7274
DEPS_rustc_typeck := rustc syntax
7375
DEPS_rustc := syntax flate arena serialize getopts rbml \
7476
time log graphviz rustc_llvm rustc_back
7577
DEPS_rustc_llvm := native:rustllvm libc std
7678
DEPS_rustc_back := std syntax rustc_llvm flate log libc
77-
DEPS_rustdoc := rustc rustc_trans native:hoedown serialize getopts \
79+
DEPS_rustdoc := rustc rustc_driver native:hoedown serialize getopts \
7880
test time
7981
DEPS_flate := std native:miniz
8082
DEPS_arena := std
@@ -96,7 +98,7 @@ DEPS_fmt_macros = std
9698

9799
TOOL_DEPS_compiletest := test getopts
98100
TOOL_DEPS_rustdoc := rustdoc
99-
TOOL_DEPS_rustc := rustc_trans
101+
TOOL_DEPS_rustc := rustc_driver
100102
TOOL_SOURCE_compiletest := $(S)src/compiletest/compiletest.rs
101103
TOOL_SOURCE_rustdoc := $(S)src/driver/driver.rs
102104
TOOL_SOURCE_rustc := $(S)src/driver/driver.rs
@@ -115,8 +117,9 @@ ONLY_RLIB_unicode := 1
115117
DOC_CRATES := $(filter-out rustc, \
116118
$(filter-out rustc_trans, \
117119
$(filter-out rustc_typeck, \
118-
$(filter-out syntax, $(CRATES)))))
119-
COMPILER_DOC_CRATES := rustc rustc_trans rustc_typeck syntax
120+
$(filter-out rustc_driver, \
121+
$(filter-out syntax, $(CRATES))))))
122+
COMPILER_DOC_CRATES := rustc rustc_trans rustc_typeck rustc_driver syntax
120123

121124
# This macro creates some simple definitions for each crate being built, just
122125
# some munging of all of the parameters above.

src/driver/driver.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@
1212
extern crate "rustdoc" as this;
1313

1414
#[cfg(rustc)]
15-
extern crate "rustc_trans" as this;
15+
extern crate "rustc_driver" as this;
1616

1717
fn main() { this::main() }

src/librustc_trans/driver/driver.rs renamed to src/librustc_driver/driver.rs

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,29 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use back::link;
12-
use back::write;
13-
use session::Session;
14-
use session::config::{mod, Input, OutputFilenames};
15-
use lint;
16-
use metadata::creader;
17-
use middle::{stability, ty, reachable};
18-
use middle::dependency_format;
19-
use middle;
20-
use plugin::load::Plugins;
21-
use plugin::registry::Registry;
22-
use plugin;
11+
use rustc::session::Session;
12+
use rustc::session::config::{mod, Input, OutputFilenames};
13+
use rustc::lint;
14+
use rustc::metadata::creader;
15+
use rustc::middle::{stability, ty, reachable};
16+
use rustc::middle::dependency_format;
17+
use rustc::middle;
18+
use rustc::plugin::load::Plugins;
19+
use rustc::plugin::registry::Registry;
20+
use rustc::plugin;
21+
use rustc::util::common::time;
22+
use rustc_trans::back::link;
23+
use rustc_trans::back::write;
24+
use rustc_trans::save;
25+
use rustc_trans::trans;
2326
use rustc_typeck as typeck;
24-
use trans;
25-
26-
use util::common::time;
2727

2828
use serialize::{json, Encodable};
2929

3030
use std::io;
3131
use std::io::fs;
3232
use std::os;
3333
use arena::TypedArena;
34-
use save;
3534
use syntax::ast;
3635
use syntax::ast_map;
3736
use syntax::attr;

src/librustc_trans/driver/mod.rs renamed to src/librustc_driver/lib.rs

Lines changed: 48 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -8,30 +8,62 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
pub use syntax::diagnostic;
11+
//! The Rust compiler.
12+
//!
13+
//! # Note
14+
//!
15+
//! This API is completely unstable and subject to change.
16+
17+
#![crate_name = "rustc_driver"]
18+
#![experimental]
19+
#![crate_type = "dylib"]
20+
#![crate_type = "rlib"]
21+
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
22+
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
23+
html_root_url = "http://doc.rust-lang.org/nightly/")]
24+
25+
#![feature(default_type_params, globs, if_let, import_shadowing, macro_rules, phase, quote)]
26+
#![feature(slicing_syntax, unsafe_destructor)]
27+
#![feature(rustc_diagnostic_macros)]
28+
29+
extern crate arena;
30+
extern crate flate;
31+
extern crate getopts;
32+
extern crate graphviz;
33+
extern crate libc;
34+
extern crate rustc;
35+
extern crate rustc_typeck;
36+
extern crate rustc_back;
37+
extern crate rustc_trans;
38+
#[phase(plugin, link)] extern crate log;
39+
#[phase(plugin, link)] extern crate syntax;
40+
extern crate serialize;
41+
extern crate "rustc_llvm" as llvm;
1242

13-
use back::link;
14-
use session::{config, Session, build_session};
15-
use session::config::Input;
16-
use lint::Lint;
17-
use lint;
18-
use metadata;
43+
pub use syntax::diagnostic;
1944

45+
use rustc_trans::back::link;
46+
use rustc::session::{config, Session, build_session};
47+
use rustc::session::config::Input;
48+
use rustc::lint::Lint;
49+
use rustc::lint;
50+
use rustc::metadata;
2051
use rustc::DIAGNOSTICS;
2152

2253
use std::any::AnyRefExt;
2354
use std::io;
2455
use std::os;
2556
use std::task::TaskBuilder;
2657

27-
use session::early_error;
58+
use rustc::session::early_error;
2859

2960
use syntax::ast;
3061
use syntax::parse;
3162
use syntax::diagnostic::Emitter;
3263
use syntax::diagnostics;
3364

34-
use getopts;
65+
#[cfg(test)]
66+
pub mod test;
3567

3668
pub mod driver;
3769
pub mod pretty;
@@ -507,3 +539,9 @@ pub fn monitor(f: proc():Send) {
507539
}
508540
}
509541

542+
pub fn main() {
543+
let args = std::os::args();
544+
let result = run(args);
545+
std::os::set_exit_status(result);
546+
}
547+

src/librustc_driver/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+

src/librustc_trans/driver/pretty.rs renamed to src/librustc_driver/pretty.rs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,18 @@ pub use self::PpSourceMode::*;
1515
pub use self::PpMode::*;
1616
use self::NodesMatchingUII::*;
1717

18-
use back::link;
19-
20-
use session::Session;
21-
use session::config::{mod, Input};
22-
use driver::driver::{mod};
23-
24-
use middle::ty;
25-
use middle::borrowck::{mod, FnPartsWithCFG};
26-
use middle::borrowck::graphviz as borrowck_dot;
27-
use middle::cfg;
28-
use middle::cfg::graphviz::LabelledCFG;
29-
30-
use util::ppaux;
18+
use rustc_trans::back::link;
19+
20+
use driver;
21+
22+
use rustc::middle::ty;
23+
use rustc::middle::borrowck::{mod, FnPartsWithCFG};
24+
use rustc::middle::borrowck::graphviz as borrowck_dot;
25+
use rustc::middle::cfg;
26+
use rustc::middle::cfg::graphviz::LabelledCFG;
27+
use rustc::session::Session;
28+
use rustc::session::config::{mod, Input};
29+
use rustc::util::ppaux;
3130

3231
use syntax::ast;
3332
use syntax::ast_map::{mod, blocks, NodePrinter};
File renamed without changes.

src/librustc_trans/lib.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ extern crate getopts;
3232
extern crate graphviz;
3333
extern crate libc;
3434
extern crate rustc;
35-
extern crate rustc_typeck;
3635
extern crate rustc_back;
3736
#[phase(plugin, link)] extern crate log;
3837
#[phase(plugin, link)] extern crate syntax;
@@ -66,17 +65,7 @@ pub mod back {
6665

6766
pub mod trans;
6867
pub mod save;
69-
pub mod driver;
7068

7169
pub mod lib {
7270
pub use llvm;
7371
}
74-
75-
pub fn main() {
76-
let args = std::os::args();
77-
let result = driver::run(args);
78-
std::os::set_exit_status(result);
79-
}
80-
81-
#[cfg(test)]
82-
pub mod test;

src/librustdoc/core.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010
pub use self::MaybeTyped::*;
1111

12-
use rustc_trans::driver::driver;
12+
use rustc_driver::driver;
1313
use rustc::session::{mod, config};
1414
use rustc::middle::{privacy, ty};
1515
use rustc::lint;

src/librustdoc/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ extern crate getopts;
2121
extern crate libc;
2222
extern crate rustc;
2323
extern crate rustc_trans;
24+
extern crate rustc_driver;
2425
extern crate serialize;
2526
extern crate syntax;
2627
extern crate "test" as testing;
@@ -163,7 +164,7 @@ pub fn main_args(args: &[String]) -> int {
163164
usage(args[0].as_slice());
164165
return 0;
165166
} else if matches.opt_present("version") {
166-
match rustc_trans::driver::version("rustdoc", &matches) {
167+
match rustc_driver::version("rustdoc", &matches) {
167168
Some(err) => {
168169
println!("{}", err);
169170
return 1

src/librustdoc/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use std::string::String;
1919
use std::collections::{HashSet, HashMap};
2020
use testing;
2121
use rustc::session::{mod, config};
22-
use rustc_trans::driver::driver;
22+
use rustc_driver::driver;
2323
use syntax::ast;
2424
use syntax::codemap::{CodeMap, dummy_spanned};
2525
use syntax::diagnostic;

0 commit comments

Comments
 (0)