Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate typeck/trans into distinct crates. #19362

Merged
merged 15 commits into from
Dec 5, 2014
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Separate the driver into its own crate that uses trans, typeck.
  • Loading branch information
nikomatsakis committed Dec 4, 2014
commit 61edb0ccb791934fa86000a9e59a23a9fc1f983c
17 changes: 10 additions & 7 deletions mk/crates.mk
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ TARGET_CRATES := libc std flate arena term \
serialize getopts collections test time rand \
log regex graphviz core rbml alloc rustrt \
unicode
HOST_CRATES := syntax rustc rustc_typeck rustc_trans rustdoc regex_macros fmt_macros \
rustc_llvm rustc_back
RUSTC_CRATES := rustc rustc_typeck rustc_driver rustc_trans rustc_back rustc_llvm
HOST_CRATES := syntax $(RUSTC_CRATES) rustdoc regex_macros fmt_macros
CRATES := $(TARGET_CRATES) $(HOST_CRATES)
TOOLS := compiletest rustdoc rustc

Expand All @@ -67,14 +67,16 @@ DEPS_std := core libc rand alloc collections rustrt unicode \
native:rust_builtin native:backtrace
DEPS_graphviz := std
DEPS_syntax := std term serialize log fmt_macros arena libc
DEPS_rustc_driver := arena flate getopts graphviz libc rustc rustc_back \
rustc_typeck log syntax serialize rustc_llvm rustc_trans
DEPS_rustc_trans := arena flate getopts graphviz libc rustc rustc_back \
rustc_typeck log syntax serialize rustc_llvm
log syntax serialize rustc_llvm
DEPS_rustc_typeck := rustc syntax
DEPS_rustc := syntax flate arena serialize getopts rbml \
time log graphviz rustc_llvm rustc_back
DEPS_rustc_llvm := native:rustllvm libc std
DEPS_rustc_back := std syntax rustc_llvm flate log libc
DEPS_rustdoc := rustc rustc_trans native:hoedown serialize getopts \
DEPS_rustdoc := rustc rustc_driver native:hoedown serialize getopts \
test time
DEPS_flate := std native:miniz
DEPS_arena := std
Expand All @@ -96,7 +98,7 @@ DEPS_fmt_macros = std

TOOL_DEPS_compiletest := test getopts
TOOL_DEPS_rustdoc := rustdoc
TOOL_DEPS_rustc := rustc_trans
TOOL_DEPS_rustc := rustc_driver
TOOL_SOURCE_compiletest := $(S)src/compiletest/compiletest.rs
TOOL_SOURCE_rustdoc := $(S)src/driver/driver.rs
TOOL_SOURCE_rustc := $(S)src/driver/driver.rs
Expand All @@ -115,8 +117,9 @@ ONLY_RLIB_unicode := 1
DOC_CRATES := $(filter-out rustc, \
$(filter-out rustc_trans, \
$(filter-out rustc_typeck, \
$(filter-out syntax, $(CRATES)))))
COMPILER_DOC_CRATES := rustc rustc_trans rustc_typeck syntax
$(filter-out rustc_driver, \
$(filter-out syntax, $(CRATES))))))
COMPILER_DOC_CRATES := rustc rustc_trans rustc_typeck rustc_driver syntax

# This macro creates some simple definitions for each crate being built, just
# some munging of all of the parameters above.
Expand Down
2 changes: 1 addition & 1 deletion src/driver/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
extern crate "rustdoc" as this;

#[cfg(rustc)]
extern crate "rustc_trans" as this;
extern crate "rustc_driver" as this;

fn main() { this::main() }
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,29 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use back::link;
use back::write;
use session::Session;
use session::config::{mod, Input, OutputFilenames};
use lint;
use metadata::creader;
use middle::{stability, ty, reachable};
use middle::dependency_format;
use middle;
use plugin::load::Plugins;
use plugin::registry::Registry;
use plugin;
use rustc::session::Session;
use rustc::session::config::{mod, Input, OutputFilenames};
use rustc::lint;
use rustc::metadata::creader;
use rustc::middle::{stability, ty, reachable};
use rustc::middle::dependency_format;
use rustc::middle;
use rustc::plugin::load::Plugins;
use rustc::plugin::registry::Registry;
use rustc::plugin;
use rustc::util::common::time;
use rustc_trans::back::link;
use rustc_trans::back::write;
use rustc_trans::save;
use rustc_trans::trans;
use rustc_typeck as typeck;
use trans;

use util::common::time;

use serialize::{json, Encodable};

use std::io;
use std::io::fs;
use std::os;
use arena::TypedArena;
use save;
use syntax::ast;
use syntax::ast_map;
use syntax::attr;
Expand Down
58 changes: 48 additions & 10 deletions src/librustc_trans/driver/mod.rs → src/librustc_driver/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
Expand All @@ -8,30 +8,62 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

pub use syntax::diagnostic;
//! The Rust compiler.
//!
//! # Note
//!
//! This API is completely unstable and subject to change.

#![crate_name = "rustc_driver"]
#![experimental]
#![crate_type = "dylib"]
#![crate_type = "rlib"]
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
html_root_url = "http://doc.rust-lang.org/nightly/")]

#![feature(default_type_params, globs, if_let, import_shadowing, macro_rules, phase, quote)]
#![feature(slicing_syntax, unsafe_destructor)]
#![feature(rustc_diagnostic_macros)]

extern crate arena;
extern crate flate;
extern crate getopts;
extern crate graphviz;
extern crate libc;
extern crate rustc;
extern crate rustc_typeck;
extern crate rustc_back;
extern crate rustc_trans;
#[phase(plugin, link)] extern crate log;
#[phase(plugin, link)] extern crate syntax;
extern crate serialize;
extern crate "rustc_llvm" as llvm;

use back::link;
use session::{config, Session, build_session};
use session::config::Input;
use lint::Lint;
use lint;
use metadata;
pub use syntax::diagnostic;

use rustc_trans::back::link;
use rustc::session::{config, Session, build_session};
use rustc::session::config::Input;
use rustc::lint::Lint;
use rustc::lint;
use rustc::metadata;
use rustc::DIAGNOSTICS;

use std::any::AnyRefExt;
use std::io;
use std::os;
use std::task::TaskBuilder;

use session::early_error;
use rustc::session::early_error;

use syntax::ast;
use syntax::parse;
use syntax::diagnostic::Emitter;
use syntax::diagnostics;

use getopts;
#[cfg(test)]
pub mod test;

pub mod driver;
pub mod pretty;
Expand Down Expand Up @@ -507,3 +539,9 @@ pub fn monitor(f: proc():Send) {
}
}

pub fn main() {
let args = std::os::args();
let result = run(args);
std::os::set_exit_status(result);
}

10 changes: 10 additions & 0 deletions src/librustc_driver/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stray file?

Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,18 @@ pub use self::PpSourceMode::*;
pub use self::PpMode::*;
use self::NodesMatchingUII::*;

use back::link;

use session::Session;
use session::config::{mod, Input};
use driver::driver::{mod};

use middle::ty;
use middle::borrowck::{mod, FnPartsWithCFG};
use middle::borrowck::graphviz as borrowck_dot;
use middle::cfg;
use middle::cfg::graphviz::LabelledCFG;

use util::ppaux;
use rustc_trans::back::link;

use driver;

use rustc::middle::ty;
use rustc::middle::borrowck::{mod, FnPartsWithCFG};
use rustc::middle::borrowck::graphviz as borrowck_dot;
use rustc::middle::cfg;
use rustc::middle::cfg::graphviz::LabelledCFG;
use rustc::session::Session;
use rustc::session::config::{mod, Input};
use rustc::util::ppaux;

use syntax::ast;
use syntax::ast_map::{mod, blocks, NodePrinter};
Expand Down
File renamed without changes.
11 changes: 0 additions & 11 deletions src/librustc_trans/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ extern crate getopts;
extern crate graphviz;
extern crate libc;
extern crate rustc;
extern crate rustc_typeck;
extern crate rustc_back;
#[phase(plugin, link)] extern crate log;
#[phase(plugin, link)] extern crate syntax;
Expand Down Expand Up @@ -66,17 +65,7 @@ pub mod back {

pub mod trans;
pub mod save;
pub mod driver;

pub mod lib {
pub use llvm;
}

pub fn main() {
let args = std::os::args();
let result = driver::run(args);
std::os::set_exit_status(result);
}

#[cfg(test)]
pub mod test;
2 changes: 1 addition & 1 deletion src/librustdoc/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// except according to those terms.
pub use self::MaybeTyped::*;

use rustc_trans::driver::driver;
use rustc_driver::driver;
use rustc::session::{mod, config};
use rustc::middle::{privacy, ty};
use rustc::lint;
Expand Down
3 changes: 2 additions & 1 deletion src/librustdoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ extern crate getopts;
extern crate libc;
extern crate rustc;
extern crate rustc_trans;
extern crate rustc_driver;
extern crate serialize;
extern crate syntax;
extern crate "test" as testing;
Expand Down Expand Up @@ -163,7 +164,7 @@ pub fn main_args(args: &[String]) -> int {
usage(args[0].as_slice());
return 0;
} else if matches.opt_present("version") {
match rustc_trans::driver::version("rustdoc", &matches) {
match rustc_driver::version("rustdoc", &matches) {
Some(err) => {
println!("{}", err);
return 1
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use std::string::String;
use std::collections::{HashSet, HashMap};
use testing;
use rustc::session::{mod, config};
use rustc_trans::driver::driver;
use rustc_driver::driver;
use syntax::ast;
use syntax::codemap::{CodeMap, dummy_spanned};
use syntax::diagnostic;
Expand Down