let unixlibname = format!("lib{}.a", name);
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
.opts
.addl_lib_search_paths
// The default library location, we need this to find the runtime.
// The location of crates will be determined as needed.
// 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 mut args = vec!(stage);
debug!("preparing the RPATH!");
- let sysroot = sess.filesearch.sysroot;
+ let sysroot = sess.filesearch().sysroot;
let output = out_filename;
let libs = sess.cstore.get_used_crates(cstore::RequireDynamic);
let libs = libs.move_iter().filter_map(|(_, l)| l.map(|p| p.clone())).collect();
fn get_sysroot_absolute_rt_lib(sess: &Session) -> Path {
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
}
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 opt_level = {
if (debugging_opts & session::NO_OPT) != 0 {
matches.opt_present("crate-file-name"));
let cg = build_codegen_options(matches);
- let sopts = @session::Options {
+ @session::Options {
crate_types: crate_types,
gc: gc,
optimize: opt_level,
debuginfo: debuginfo,
lint_opts: lint_opts,
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,
target_triple: target,
cfg: cfg,
write_dependency_info: write_dependency_info,
print_metas: print_metas,
cg: cg,
- };
- return sopts;
+ }
}
pub fn build_codegen_options(matches: &getopts::Matches)
let target_cfg = build_target_config(sopts);
let p_s = parse::new_parse_sess_special_handler(span_diagnostic_handler, codemap);
let cstore = @CStore::new(token::get_ident_interner());
- let filesearch = @filesearch::FileSearch::new(
- &sopts.maybe_sysroot,
- sopts.target_triple,
- sopts.addl_lib_search_paths);
+ let default_sysroot = match sopts.maybe_sysroot {
+ Some(_) => None,
+ None => Some(filesearch::get_or_default_sysroot())
+ };
// Make the path absolute, if necessary
let local_crate_source_file = local_crate_source_file.map(|path|
entry_type: Cell::new(None),
macro_registrar_fn: RefCell::new(None),
span_diagnostic: span_diagnostic_handler,
- filesearch: filesearch,
+ default_sysroot: default_sysroot,
building_library: Cell::new(false),
local_crate_source_file: local_crate_source_file,
working_dir: os::getcwd(),
// This was mutable for rustpkg, which updates search paths based on the
// parsed code. It remains mutable in case its replacements wants to use
// this.
- addl_lib_search_paths: @RefCell<HashSet<Path>>,
- maybe_sysroot: Option<@Path>,
+ addl_lib_search_paths: RefCell<HashSet<Path>>,
+ maybe_sysroot: Option<Path>,
target_triple: ~str,
// User-specified cfg meta items. The compiler itself will add additional
// items to the crate config, and during parsing the entire crate config
entry_type: Cell<Option<EntryFnType>>,
span_diagnostic: @diagnostic::SpanHandler,
macro_registrar_fn: RefCell<Option<ast::DefId>>,
- filesearch: @filesearch::FileSearch,
+ default_sysroot: Option<Path>,
building_library: Cell<bool>,
// 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.
pub fn show_span(&self) -> bool {
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
debuginfo: NoDebugInfo,
lint_opts: 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,
target_triple: host_triple(),
cfg: Vec::new(),
#[allow(non_camel_case_types)];
use std::cell::RefCell;
-use std::option;
use std::os;
use std::io::fs;
use std::vec_ng::Vec;
/// a file found in that directory.
pub type pick<'a> = 'a |path: &Path| -> FileMatch;
-pub struct FileSearch {
- sysroot: @Path,
- addl_lib_search_paths: @RefCell<HashSet<Path>>,
- target_triple: ~str
+pub struct FileSearch<'a> {
+ sysroot: &'a Path,
+ addl_lib_search_paths: &'a RefCell<HashSet<Path>>,
+ target_triple: &'a str
}
-impl FileSearch {
+impl<'a> FileSearch<'a> {
pub fn for_each_lib_search_path(&self, f: |&Path| -> FileMatch) {
let mut visited_dirs = HashSet::new();
let mut found = false;
});
}
- pub fn new(maybe_sysroot: &Option<@Path>,
- target_triple: &str,
- addl_lib_search_paths: @RefCell<HashSet<Path>>) -> FileSearch {
- let sysroot = get_sysroot(maybe_sysroot);
+ pub fn new(sysroot: &'a Path,
+ target_triple: &'a str,
+ addl_lib_search_paths: &'a RefCell<HashSet<Path>>) -> FileSearch<'a> {
debug!("using sysroot = {}", sysroot.display());
- FileSearch{
+ FileSearch {
sysroot: sysroot,
addl_lib_search_paths: addl_lib_search_paths,
- target_triple: target_triple.to_owned()
+ target_triple: target_triple
}
}
}
}
match canonicalize(os::self_exe_name()) {
- option::Some(p) => { let mut p = p; p.pop(); p.pop(); p }
- option::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()
+ Some(mut p) => { p.pop(); p.pop(); p }
+ None => fail!("can't determine value for sysroot")
}
}
}
fn find_library_crate(&mut self) -> Option<Library> {
- let filesearch = self.sess.filesearch;
+ let filesearch = self.sess.filesearch();
let (dyprefix, dysuffix) = self.dylibname();
// want: crate_name.dir_part() + prefix + crate_name.file_part + "-"
let input = FileInput(cpath.clone());
let sessopts = @driver::session::Options {
- maybe_sysroot: Some(@os::self_exe_path().unwrap().dir_path()),
- addl_lib_search_paths: @RefCell::new(libs),
+ maybe_sysroot: Some(os::self_exe_path().unwrap().dir_path()),
+ addl_lib_search_paths: RefCell::new(libs),
crate_types: vec!(driver::session::CrateTypeDylib),
.. (*rustc::driver::session::basic_options()).clone()
};
}
let input = matches.free[0].as_slice();
- let libs = matches.opt_strs("L").map(|s| Path::new(s.as_slice()));
- let libs = @RefCell::new(libs.move_iter().collect());
+ let libs = matches.opt_strs("L").map(|s| Path::new(s.as_slice())).move_iter().collect();
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();
}
/// 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 mut collector = Collector::new(input.to_owned(), libs, true, true);
use passes;
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 = driver::FileInput(input_path.clone());
let sessopts = @session::Options {
- maybe_sysroot: Some(@os::self_exe_path().unwrap().dir_path()),
- addl_lib_search_paths: libs,
+ maybe_sysroot: Some(os::self_exe_path().unwrap().dir_path()),
+ addl_lib_search_paths: RefCell::new(libs.clone()),
crate_types: vec!(session::CrateTypeDylib),
.. (*session::basic_options()).clone()
};
let input = driver::StrInput(test);
let sessopts = @session::Options {
- maybe_sysroot: Some(@os::self_exe_path().unwrap().dir_path()),
- addl_lib_search_paths: @RefCell::new(libs),
+ maybe_sysroot: Some(os::self_exe_path().unwrap().dir_path()),
+ addl_lib_search_paths: RefCell::new(libs),
crate_types: vec!(session::CrateTypeExecutable),
output_types: vec!(link::OutputTypeExe),
cg: session::CodegenOptions {
pub struct Collector {
tests: ~[testing::TestDescAndFn],
priv names: ~[~str],
- priv libs: @RefCell<HashSet<Path>>,
+ priv libs: HashSet<Path>,
priv cnt: uint,
priv use_headers: bool,
priv current_header: Option<~str>,
}
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 {
Collector {
tests: ~[],
format!("{}_{}", self.names.connect("::"), self.cnt)
};
self.cnt += 1;
- let libs = self.libs.borrow();
- let libs = (*libs.get()).clone();
+ let libs = self.libs.clone();
let cratename = self.cratename.to_owned();
let loose_feature_gating = self.loose_feature_gating;
debug!("Creating test {}: {}", name, test);