auto merge of #9179 : catamorphism/rust/rustpkg-package-id, r=catamorphism,metajack

r? @metajack - This solves the problem you were having earlier with things like ```extern mod geom = "rust-geom";``` (or something like that).
This commit is contained in:
bors 2013-09-14 21:45:49 -07:00
commit ccadbd3b7c
2 changed files with 51 additions and 4 deletions

View File

@ -1111,6 +1111,55 @@ fn test_extern_mod() {
assert!(os::path_exists(&exec_file) && is_executable(&exec_file));
}
#[test]
fn test_extern_mod_simpler() {
let dir = mkdtemp(&os::tmpdir(), "test_extern_mod_simpler").expect("test_extern_mod_simpler");
let main_file = dir.push("main.rs");
let lib_depend_dir = mkdtemp(&os::tmpdir(), "foo").expect("test_extern_mod_simpler");
let aux_dir = lib_depend_dir.push_many(["src", "rust-awesomeness"]);
assert!(os::mkdir_recursive(&aux_dir, U_RWX));
let aux_pkg_file = aux_dir.push("lib.rs");
writeFile(&aux_pkg_file, "pub mod bar { pub fn assert_true() { assert!(true); } }\n");
assert!(os::path_exists(&aux_pkg_file));
writeFile(&main_file,
"extern mod test = \"rust-awesomeness\";\nuse test::bar;\
fn main() { bar::assert_true(); }\n");
command_line_test([~"install", ~"rust-awesomeness"], &lib_depend_dir);
let exec_file = dir.push("out");
// Be sure to extend the existing environment
let env = Some([(~"RUST_PATH", lib_depend_dir.to_str())] + os::env());
let rustpkg_exec = rustpkg_exec();
let rustc = rustpkg_exec.with_filename("rustc");
debug!("RUST_PATH=%s %s %s \n --sysroot %s -o %s",
lib_depend_dir.to_str(),
rustc.to_str(),
main_file.to_str(),
test_sysroot().to_str(),
exec_file.to_str());
let mut prog = run::Process::new(rustc.to_str(), [main_file.to_str(),
~"--sysroot", test_sysroot().to_str(),
~"-o", exec_file.to_str()],
run::ProcessOptions {
env: env,
dir: Some(&dir),
in_fd: None,
out_fd: None,
err_fd: None
});
let outp = prog.finish_with_output();
if outp.status != 0 {
fail!("output was %s, error was %s",
str::from_utf8(outp.output),
str::from_utf8(outp.error));
}
assert!(os::path_exists(&exec_file) && is_executable(&exec_file));
}
#[test]
fn test_import_rustpkg() {
let p_id = PkgId::new("foo");

View File

@ -268,10 +268,8 @@ pub fn compile_input(context: &BuildContext,
let link_options =
~[attr::mk_name_value_item_str(@"name", name_to_use),
attr::mk_name_value_item_str(@"vers", pkg_id.version.to_str().to_managed())] +
if pkg_id.is_complex() {
~[attr::mk_name_value_item_str(@"package_id",
pkg_id.path.to_str().to_managed())]
} else { ~[] };
~[attr::mk_name_value_item_str(@"package_id",
pkg_id.path.to_str().to_managed())];
debug!("link options: %?", link_options);
crate = @ast::Crate {