Move used_libraries from session to cstore
This commit is contained in:
parent
1386420cad
commit
4bfa269fe7
@ -355,7 +355,7 @@ fn build_session(@session::options sopts) -> session::session {
|
||||
auto target_cfg = build_target_config();
|
||||
auto cstore = cstore::mk_cstore();
|
||||
ret session::session(target_cfg, sopts, cstore,
|
||||
[], [], codemap::new_codemap(), 0u);
|
||||
[], codemap::new_codemap(), 0u);
|
||||
}
|
||||
|
||||
fn parse_pretty(session::session sess, &str name) -> pp_mode {
|
||||
@ -517,7 +517,8 @@ fn main(vec[str] args) {
|
||||
};
|
||||
}
|
||||
|
||||
for (str cratepath in cstore::get_used_crate_files(sess.get_cstore())) {
|
||||
auto cstore = sess.get_cstore();
|
||||
for (str cratepath in cstore::get_used_crate_files(cstore)) {
|
||||
auto dir = fs::dirname(cratepath);
|
||||
if (dir != "") {
|
||||
gcc_args += ["-L" + dir];
|
||||
@ -527,7 +528,7 @@ fn main(vec[str] args) {
|
||||
}
|
||||
|
||||
gcc_args += sess.get_used_link_args();
|
||||
auto used_libs = sess.get_used_libraries();
|
||||
auto used_libs = cstore::get_used_libraries(cstore);
|
||||
for (str l in used_libs) {
|
||||
gcc_args += ["-l" + l];
|
||||
}
|
||||
|
@ -46,7 +46,6 @@ type crate_metadata = rec(str name, vec[u8] data);
|
||||
obj session(@config targ_cfg,
|
||||
@options opts,
|
||||
metadata::cstore::cstore cstore,
|
||||
mutable vec[str] used_libraries,
|
||||
mutable vec[str] used_link_args,
|
||||
codemap::codemap cm,
|
||||
mutable uint err_count) {
|
||||
@ -105,23 +104,6 @@ obj session(@config targ_cfg,
|
||||
fn get_used_link_args() -> vec[str] {
|
||||
ret used_link_args;
|
||||
}
|
||||
fn add_used_library(&str lib) -> bool {
|
||||
if (lib == "") {
|
||||
ret false;
|
||||
}
|
||||
// A program has a small number of libraries, so a vector is probably
|
||||
// a good data structure in here.
|
||||
for (str l in used_libraries) {
|
||||
if (l == lib) {
|
||||
ret false;
|
||||
}
|
||||
}
|
||||
used_libraries += [lib];
|
||||
ret true;
|
||||
}
|
||||
fn get_used_libraries() -> vec[str] {
|
||||
ret used_libraries;
|
||||
}
|
||||
fn get_codemap() -> codemap::codemap { ret cm; }
|
||||
fn lookup_pos(uint pos) -> codemap::loc {
|
||||
ret codemap::lookup_pos(cm, pos);
|
||||
|
@ -180,7 +180,8 @@ fn visit_item(env e, &@ast::item i) {
|
||||
m.abi != ast::native_abi_cdecl) {
|
||||
ret;
|
||||
}
|
||||
if (!e.sess.add_used_library(m.native_name)) {
|
||||
auto cstore = e.sess.get_cstore();
|
||||
if (!cstore::add_used_library(cstore, m.native_name)) {
|
||||
ret;
|
||||
}
|
||||
for (ast::attribute a in
|
||||
|
@ -38,6 +38,21 @@ fn get_used_crate_files(&cstore cstore) -> vec[str] {
|
||||
ret cstore.used_crate_files;
|
||||
}
|
||||
|
||||
fn add_used_library(&cstore cstore, &str lib) -> bool {
|
||||
if (lib == "") { ret false; }
|
||||
|
||||
if (vec::member(lib, cstore.used_libraries)) {
|
||||
ret false;
|
||||
}
|
||||
|
||||
cstore.used_libraries += [lib];
|
||||
ret true;
|
||||
}
|
||||
|
||||
fn get_used_libraries(&cstore cstore) -> vec[str] {
|
||||
ret cstore.used_libraries;
|
||||
}
|
||||
|
||||
// Local Variables:
|
||||
// mode: rust
|
||||
// fill-column: 78;
|
||||
|
Loading…
Reference in New Issue
Block a user