De-@ filesearch.
This commit is contained in:
parent
eeb37b76af
commit
f77c744142
11 changed files with 53 additions and 54 deletions
|
@ -206,7 +206,7 @@ impl<'a> Archive<'a> {
|
||||||
let unixlibname = format!("lib{}.a", name);
|
let unixlibname = format!("lib{}.a", name);
|
||||||
|
|
||||||
let mut rustpath = filesearch::rust_path();
|
let mut rustpath = filesearch::rust_path();
|
||||||
rustpath.push(self.sess.filesearch.get_target_lib_path());
|
rustpath.push(self.sess.filesearch().get_target_lib_path());
|
||||||
let addl_lib_search_paths = self.sess
|
let addl_lib_search_paths = self.sess
|
||||||
.opts
|
.opts
|
||||||
.addl_lib_search_paths
|
.addl_lib_search_paths
|
||||||
|
|
|
@ -1075,7 +1075,7 @@ fn link_args(sess: &Session,
|
||||||
// The default library location, we need this to find the runtime.
|
// The default library location, we need this to find the runtime.
|
||||||
// The location of crates will be determined as needed.
|
// The location of crates will be determined as needed.
|
||||||
// FIXME (#9639): This needs to handle non-utf8 paths
|
// FIXME (#9639): This needs to handle non-utf8 paths
|
||||||
let lib_path = sess.filesearch.get_target_lib_path();
|
let lib_path = sess.filesearch().get_target_lib_path();
|
||||||
let stage: ~str = ~"-L" + lib_path.as_str().unwrap();
|
let stage: ~str = ~"-L" + lib_path.as_str().unwrap();
|
||||||
|
|
||||||
let mut args = vec!(stage);
|
let mut args = vec!(stage);
|
||||||
|
|
|
@ -40,7 +40,7 @@ pub fn get_rpath_flags(sess: &Session, out_filename: &Path) -> Vec<~str> {
|
||||||
|
|
||||||
debug!("preparing the RPATH!");
|
debug!("preparing the RPATH!");
|
||||||
|
|
||||||
let sysroot = sess.filesearch.sysroot;
|
let sysroot = sess.filesearch().sysroot;
|
||||||
let output = out_filename;
|
let output = out_filename;
|
||||||
let libs = sess.cstore.get_used_crates(cstore::RequireDynamic);
|
let libs = sess.cstore.get_used_crates(cstore::RequireDynamic);
|
||||||
let libs = libs.move_iter().filter_map(|(_, l)| l.map(|p| p.clone())).collect();
|
let libs = libs.move_iter().filter_map(|(_, l)| l.map(|p| p.clone())).collect();
|
||||||
|
@ -56,7 +56,7 @@ pub fn get_rpath_flags(sess: &Session, out_filename: &Path) -> Vec<~str> {
|
||||||
|
|
||||||
fn get_sysroot_absolute_rt_lib(sess: &Session) -> Path {
|
fn get_sysroot_absolute_rt_lib(sess: &Session) -> Path {
|
||||||
let r = filesearch::relative_target_lib_path(sess.opts.target_triple);
|
let r = filesearch::relative_target_lib_path(sess.opts.target_triple);
|
||||||
let mut p = sess.filesearch.sysroot.join(&r);
|
let mut p = sess.filesearch().sysroot.join(&r);
|
||||||
p.push(os::dll_filename("rustrt"));
|
p.push(os::dll_filename("rustrt"));
|
||||||
p
|
p
|
||||||
}
|
}
|
||||||
|
|
|
@ -871,7 +871,7 @@ pub fn build_session_options(matches: &getopts::Matches)
|
||||||
output_types.push(link::OutputTypeExe);
|
output_types.push(link::OutputTypeExe);
|
||||||
}
|
}
|
||||||
|
|
||||||
let sysroot_opt = matches.opt_str("sysroot").map(|m| @Path::new(m));
|
let sysroot_opt = matches.opt_str("sysroot").map(|m| Path::new(m));
|
||||||
let target = matches.opt_str("target").unwrap_or(host_triple());
|
let target = matches.opt_str("target").unwrap_or(host_triple());
|
||||||
let opt_level = {
|
let opt_level = {
|
||||||
if (debugging_opts & session::NO_OPT) != 0 {
|
if (debugging_opts & session::NO_OPT) != 0 {
|
||||||
|
@ -932,14 +932,14 @@ pub fn build_session_options(matches: &getopts::Matches)
|
||||||
matches.opt_present("crate-file-name"));
|
matches.opt_present("crate-file-name"));
|
||||||
let cg = build_codegen_options(matches);
|
let cg = build_codegen_options(matches);
|
||||||
|
|
||||||
let sopts = @session::Options {
|
@session::Options {
|
||||||
crate_types: crate_types,
|
crate_types: crate_types,
|
||||||
gc: gc,
|
gc: gc,
|
||||||
optimize: opt_level,
|
optimize: opt_level,
|
||||||
debuginfo: debuginfo,
|
debuginfo: debuginfo,
|
||||||
lint_opts: lint_opts,
|
lint_opts: lint_opts,
|
||||||
output_types: output_types,
|
output_types: output_types,
|
||||||
addl_lib_search_paths: @RefCell::new(addl_lib_search_paths),
|
addl_lib_search_paths: RefCell::new(addl_lib_search_paths),
|
||||||
maybe_sysroot: sysroot_opt,
|
maybe_sysroot: sysroot_opt,
|
||||||
target_triple: target,
|
target_triple: target,
|
||||||
cfg: cfg,
|
cfg: cfg,
|
||||||
|
@ -951,8 +951,7 @@ pub fn build_session_options(matches: &getopts::Matches)
|
||||||
write_dependency_info: write_dependency_info,
|
write_dependency_info: write_dependency_info,
|
||||||
print_metas: print_metas,
|
print_metas: print_metas,
|
||||||
cg: cg,
|
cg: cg,
|
||||||
};
|
}
|
||||||
return sopts;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn build_codegen_options(matches: &getopts::Matches)
|
pub fn build_codegen_options(matches: &getopts::Matches)
|
||||||
|
@ -1006,10 +1005,10 @@ pub fn build_session_(sopts: @session::Options,
|
||||||
let target_cfg = build_target_config(sopts);
|
let target_cfg = build_target_config(sopts);
|
||||||
let p_s = parse::new_parse_sess_special_handler(span_diagnostic_handler, codemap);
|
let p_s = parse::new_parse_sess_special_handler(span_diagnostic_handler, codemap);
|
||||||
let cstore = @CStore::new(token::get_ident_interner());
|
let cstore = @CStore::new(token::get_ident_interner());
|
||||||
let filesearch = @filesearch::FileSearch::new(
|
let default_sysroot = match sopts.maybe_sysroot {
|
||||||
&sopts.maybe_sysroot,
|
Some(_) => None,
|
||||||
sopts.target_triple,
|
None => Some(filesearch::get_or_default_sysroot())
|
||||||
sopts.addl_lib_search_paths);
|
};
|
||||||
|
|
||||||
// Make the path absolute, if necessary
|
// Make the path absolute, if necessary
|
||||||
let local_crate_source_file = local_crate_source_file.map(|path|
|
let local_crate_source_file = local_crate_source_file.map(|path|
|
||||||
|
@ -1031,7 +1030,7 @@ pub fn build_session_(sopts: @session::Options,
|
||||||
entry_type: Cell::new(None),
|
entry_type: Cell::new(None),
|
||||||
macro_registrar_fn: RefCell::new(None),
|
macro_registrar_fn: RefCell::new(None),
|
||||||
span_diagnostic: span_diagnostic_handler,
|
span_diagnostic: span_diagnostic_handler,
|
||||||
filesearch: filesearch,
|
default_sysroot: default_sysroot,
|
||||||
building_library: Cell::new(false),
|
building_library: Cell::new(false),
|
||||||
local_crate_source_file: local_crate_source_file,
|
local_crate_source_file: local_crate_source_file,
|
||||||
working_dir: os::getcwd(),
|
working_dir: os::getcwd(),
|
||||||
|
|
|
@ -134,8 +134,8 @@ pub struct Options {
|
||||||
// This was mutable for rustpkg, which updates search paths based on the
|
// This was mutable for rustpkg, which updates search paths based on the
|
||||||
// parsed code. It remains mutable in case its replacements wants to use
|
// parsed code. It remains mutable in case its replacements wants to use
|
||||||
// this.
|
// this.
|
||||||
addl_lib_search_paths: @RefCell<HashSet<Path>>,
|
addl_lib_search_paths: RefCell<HashSet<Path>>,
|
||||||
maybe_sysroot: Option<@Path>,
|
maybe_sysroot: Option<Path>,
|
||||||
target_triple: ~str,
|
target_triple: ~str,
|
||||||
// User-specified cfg meta items. The compiler itself will add additional
|
// User-specified cfg meta items. The compiler itself will add additional
|
||||||
// items to the crate config, and during parsing the entire crate config
|
// items to the crate config, and during parsing the entire crate config
|
||||||
|
@ -184,7 +184,7 @@ pub struct Session {
|
||||||
entry_type: Cell<Option<EntryFnType>>,
|
entry_type: Cell<Option<EntryFnType>>,
|
||||||
span_diagnostic: @diagnostic::SpanHandler,
|
span_diagnostic: @diagnostic::SpanHandler,
|
||||||
macro_registrar_fn: RefCell<Option<ast::DefId>>,
|
macro_registrar_fn: RefCell<Option<ast::DefId>>,
|
||||||
filesearch: @filesearch::FileSearch,
|
default_sysroot: Option<Path>,
|
||||||
building_library: Cell<bool>,
|
building_library: Cell<bool>,
|
||||||
// The name of the root source file of the crate, in the local file system. The path is always
|
// The name of the root source file of the crate, in the local file system. The path is always
|
||||||
// expected to be absolute. `None` means that there is no source file.
|
// expected to be absolute. `None` means that there is no source file.
|
||||||
|
@ -314,6 +314,17 @@ impl Session {
|
||||||
pub fn show_span(&self) -> bool {
|
pub fn show_span(&self) -> bool {
|
||||||
self.debugging_opt(SHOW_SPAN)
|
self.debugging_opt(SHOW_SPAN)
|
||||||
}
|
}
|
||||||
|
pub fn filesearch<'a>(&'a self) -> filesearch::FileSearch<'a> {
|
||||||
|
let sysroot = match self.opts.maybe_sysroot {
|
||||||
|
Some(ref sysroot) => sysroot,
|
||||||
|
None => self.default_sysroot.as_ref()
|
||||||
|
.expect("missing sysroot and default_sysroot in Session")
|
||||||
|
};
|
||||||
|
filesearch::FileSearch::new(
|
||||||
|
sysroot,
|
||||||
|
self.opts.target_triple,
|
||||||
|
&self.opts.addl_lib_search_paths)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Some reasonable defaults
|
/// Some reasonable defaults
|
||||||
|
@ -325,7 +336,7 @@ pub fn basic_options() -> @Options {
|
||||||
debuginfo: NoDebugInfo,
|
debuginfo: NoDebugInfo,
|
||||||
lint_opts: Vec::new(),
|
lint_opts: Vec::new(),
|
||||||
output_types: Vec::new(),
|
output_types: Vec::new(),
|
||||||
addl_lib_search_paths: @RefCell::new(HashSet::new()),
|
addl_lib_search_paths: RefCell::new(HashSet::new()),
|
||||||
maybe_sysroot: None,
|
maybe_sysroot: None,
|
||||||
target_triple: host_triple(),
|
target_triple: host_triple(),
|
||||||
cfg: Vec::new(),
|
cfg: Vec::new(),
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
#[allow(non_camel_case_types)];
|
#[allow(non_camel_case_types)];
|
||||||
|
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::option;
|
|
||||||
use std::os;
|
use std::os;
|
||||||
use std::io::fs;
|
use std::io::fs;
|
||||||
use std::vec_ng::Vec;
|
use std::vec_ng::Vec;
|
||||||
|
@ -27,13 +26,13 @@ pub enum FileMatch { FileMatches, FileDoesntMatch }
|
||||||
/// a file found in that directory.
|
/// a file found in that directory.
|
||||||
pub type pick<'a> = 'a |path: &Path| -> FileMatch;
|
pub type pick<'a> = 'a |path: &Path| -> FileMatch;
|
||||||
|
|
||||||
pub struct FileSearch {
|
pub struct FileSearch<'a> {
|
||||||
sysroot: @Path,
|
sysroot: &'a Path,
|
||||||
addl_lib_search_paths: @RefCell<HashSet<Path>>,
|
addl_lib_search_paths: &'a RefCell<HashSet<Path>>,
|
||||||
target_triple: ~str
|
target_triple: &'a str
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FileSearch {
|
impl<'a> FileSearch<'a> {
|
||||||
pub fn for_each_lib_search_path(&self, f: |&Path| -> FileMatch) {
|
pub fn for_each_lib_search_path(&self, f: |&Path| -> FileMatch) {
|
||||||
let mut visited_dirs = HashSet::new();
|
let mut visited_dirs = HashSet::new();
|
||||||
let mut found = false;
|
let mut found = false;
|
||||||
|
@ -127,15 +126,14 @@ impl FileSearch {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(maybe_sysroot: &Option<@Path>,
|
pub fn new(sysroot: &'a Path,
|
||||||
target_triple: &str,
|
target_triple: &'a str,
|
||||||
addl_lib_search_paths: @RefCell<HashSet<Path>>) -> FileSearch {
|
addl_lib_search_paths: &'a RefCell<HashSet<Path>>) -> FileSearch<'a> {
|
||||||
let sysroot = get_sysroot(maybe_sysroot);
|
|
||||||
debug!("using sysroot = {}", sysroot.display());
|
debug!("using sysroot = {}", sysroot.display());
|
||||||
FileSearch{
|
FileSearch {
|
||||||
sysroot: sysroot,
|
sysroot: sysroot,
|
||||||
addl_lib_search_paths: addl_lib_search_paths,
|
addl_lib_search_paths: addl_lib_search_paths,
|
||||||
target_triple: target_triple.to_owned()
|
target_triple: target_triple
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -179,15 +177,8 @@ pub fn get_or_default_sysroot() -> Path {
|
||||||
}
|
}
|
||||||
|
|
||||||
match canonicalize(os::self_exe_name()) {
|
match canonicalize(os::self_exe_name()) {
|
||||||
option::Some(p) => { let mut p = p; p.pop(); p.pop(); p }
|
Some(mut p) => { p.pop(); p.pop(); p }
|
||||||
option::None => fail!("can't determine value for sysroot")
|
None => fail!("can't determine value for sysroot")
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_sysroot(maybe_sysroot: &Option<@Path>) -> @Path {
|
|
||||||
match *maybe_sysroot {
|
|
||||||
option::Some(sr) => sr,
|
|
||||||
option::None => @get_or_default_sysroot()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -110,7 +110,7 @@ impl<'a> Context<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn find_library_crate(&mut self) -> Option<Library> {
|
fn find_library_crate(&mut self) -> Option<Library> {
|
||||||
let filesearch = self.sess.filesearch;
|
let filesearch = self.sess.filesearch();
|
||||||
let (dyprefix, dysuffix) = self.dylibname();
|
let (dyprefix, dysuffix) = self.dylibname();
|
||||||
|
|
||||||
// want: crate_name.dir_part() + prefix + crate_name.file_part + "-"
|
// want: crate_name.dir_part() + prefix + crate_name.file_part + "-"
|
||||||
|
|
|
@ -64,8 +64,8 @@ fn get_ast_and_resolve(cpath: &Path,
|
||||||
let input = FileInput(cpath.clone());
|
let input = FileInput(cpath.clone());
|
||||||
|
|
||||||
let sessopts = @driver::session::Options {
|
let sessopts = @driver::session::Options {
|
||||||
maybe_sysroot: Some(@os::self_exe_path().unwrap().dir_path()),
|
maybe_sysroot: Some(os::self_exe_path().unwrap().dir_path()),
|
||||||
addl_lib_search_paths: @RefCell::new(libs),
|
addl_lib_search_paths: RefCell::new(libs),
|
||||||
crate_types: vec!(driver::session::CrateTypeDylib),
|
crate_types: vec!(driver::session::CrateTypeDylib),
|
||||||
.. (*rustc::driver::session::basic_options()).clone()
|
.. (*rustc::driver::session::basic_options()).clone()
|
||||||
};
|
};
|
||||||
|
|
|
@ -155,8 +155,7 @@ pub fn main_args(args: &[~str]) -> int {
|
||||||
}
|
}
|
||||||
let input = matches.free[0].as_slice();
|
let input = matches.free[0].as_slice();
|
||||||
|
|
||||||
let libs = matches.opt_strs("L").map(|s| Path::new(s.as_slice()));
|
let libs = matches.opt_strs("L").map(|s| Path::new(s.as_slice())).move_iter().collect();
|
||||||
let libs = @RefCell::new(libs.move_iter().collect());
|
|
||||||
|
|
||||||
let test_args = matches.opt_strs("test-args");
|
let test_args = matches.opt_strs("test-args");
|
||||||
let test_args = test_args.iter().flat_map(|s| s.words()).map(|s| s.to_owned()).to_owned_vec();
|
let test_args = test_args.iter().flat_map(|s| s.words()).map(|s| s.to_owned()).to_owned_vec();
|
||||||
|
|
|
@ -160,7 +160,7 @@ pub fn render(input: &str, mut output: Path, matches: &getopts::Matches) -> int
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Run any tests/code examples in the markdown file `input`.
|
/// Run any tests/code examples in the markdown file `input`.
|
||||||
pub fn test(input: &str, libs: @RefCell<HashSet<Path>>, mut test_args: ~[~str]) -> int {
|
pub fn test(input: &str, libs: HashSet<Path>, mut test_args: ~[~str]) -> int {
|
||||||
let input_str = load_or_return!(input, 1, 2);
|
let input_str = load_or_return!(input, 1, 2);
|
||||||
|
|
||||||
let mut collector = Collector::new(input.to_owned(), libs, true, true);
|
let mut collector = Collector::new(input.to_owned(), libs, true, true);
|
||||||
|
|
|
@ -34,13 +34,13 @@ use html::markdown;
|
||||||
use passes;
|
use passes;
|
||||||
use visit_ast::RustdocVisitor;
|
use visit_ast::RustdocVisitor;
|
||||||
|
|
||||||
pub fn run(input: &str, libs: @RefCell<HashSet<Path>>, mut test_args: ~[~str]) -> int {
|
pub fn run(input: &str, libs: HashSet<Path>, mut test_args: ~[~str]) -> int {
|
||||||
let input_path = Path::new(input);
|
let input_path = Path::new(input);
|
||||||
let input = driver::FileInput(input_path.clone());
|
let input = driver::FileInput(input_path.clone());
|
||||||
|
|
||||||
let sessopts = @session::Options {
|
let sessopts = @session::Options {
|
||||||
maybe_sysroot: Some(@os::self_exe_path().unwrap().dir_path()),
|
maybe_sysroot: Some(os::self_exe_path().unwrap().dir_path()),
|
||||||
addl_lib_search_paths: libs,
|
addl_lib_search_paths: RefCell::new(libs.clone()),
|
||||||
crate_types: vec!(session::CrateTypeDylib),
|
crate_types: vec!(session::CrateTypeDylib),
|
||||||
.. (*session::basic_options()).clone()
|
.. (*session::basic_options()).clone()
|
||||||
};
|
};
|
||||||
|
@ -92,8 +92,8 @@ fn runtest(test: &str, cratename: &str, libs: HashSet<Path>, should_fail: bool,
|
||||||
let input = driver::StrInput(test);
|
let input = driver::StrInput(test);
|
||||||
|
|
||||||
let sessopts = @session::Options {
|
let sessopts = @session::Options {
|
||||||
maybe_sysroot: Some(@os::self_exe_path().unwrap().dir_path()),
|
maybe_sysroot: Some(os::self_exe_path().unwrap().dir_path()),
|
||||||
addl_lib_search_paths: @RefCell::new(libs),
|
addl_lib_search_paths: RefCell::new(libs),
|
||||||
crate_types: vec!(session::CrateTypeExecutable),
|
crate_types: vec!(session::CrateTypeExecutable),
|
||||||
output_types: vec!(link::OutputTypeExe),
|
output_types: vec!(link::OutputTypeExe),
|
||||||
cg: session::CodegenOptions {
|
cg: session::CodegenOptions {
|
||||||
|
@ -194,7 +194,7 @@ fn maketest(s: &str, cratename: &str, loose_feature_gating: bool) -> ~str {
|
||||||
pub struct Collector {
|
pub struct Collector {
|
||||||
tests: ~[testing::TestDescAndFn],
|
tests: ~[testing::TestDescAndFn],
|
||||||
priv names: ~[~str],
|
priv names: ~[~str],
|
||||||
priv libs: @RefCell<HashSet<Path>>,
|
priv libs: HashSet<Path>,
|
||||||
priv cnt: uint,
|
priv cnt: uint,
|
||||||
priv use_headers: bool,
|
priv use_headers: bool,
|
||||||
priv current_header: Option<~str>,
|
priv current_header: Option<~str>,
|
||||||
|
@ -204,7 +204,7 @@ pub struct Collector {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Collector {
|
impl Collector {
|
||||||
pub fn new(cratename: ~str, libs: @RefCell<HashSet<Path>>,
|
pub fn new(cratename: ~str, libs: HashSet<Path>,
|
||||||
use_headers: bool, loose_feature_gating: bool) -> Collector {
|
use_headers: bool, loose_feature_gating: bool) -> Collector {
|
||||||
Collector {
|
Collector {
|
||||||
tests: ~[],
|
tests: ~[],
|
||||||
|
@ -227,8 +227,7 @@ impl Collector {
|
||||||
format!("{}_{}", self.names.connect("::"), self.cnt)
|
format!("{}_{}", self.names.connect("::"), self.cnt)
|
||||||
};
|
};
|
||||||
self.cnt += 1;
|
self.cnt += 1;
|
||||||
let libs = self.libs.borrow();
|
let libs = self.libs.clone();
|
||||||
let libs = (*libs.get()).clone();
|
|
||||||
let cratename = self.cratename.to_owned();
|
let cratename = self.cratename.to_owned();
|
||||||
let loose_feature_gating = self.loose_feature_gating;
|
let loose_feature_gating = self.loose_feature_gating;
|
||||||
debug!("Creating test {}: {}", name, test);
|
debug!("Creating test {}: {}", name, test);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue