mirror of https://github.com/rust-lang/rust.git
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:
commit
ccadbd3b7c
|
@ -1111,6 +1111,55 @@ fn test_extern_mod() {
|
||||||
assert!(os::path_exists(&exec_file) && is_executable(&exec_file));
|
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]
|
#[test]
|
||||||
fn test_import_rustpkg() {
|
fn test_import_rustpkg() {
|
||||||
let p_id = PkgId::new("foo");
|
let p_id = PkgId::new("foo");
|
||||||
|
|
|
@ -268,10 +268,8 @@ pub fn compile_input(context: &BuildContext,
|
||||||
let link_options =
|
let link_options =
|
||||||
~[attr::mk_name_value_item_str(@"name", name_to_use),
|
~[attr::mk_name_value_item_str(@"name", name_to_use),
|
||||||
attr::mk_name_value_item_str(@"vers", pkg_id.version.to_str().to_managed())] +
|
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",
|
||||||
~[attr::mk_name_value_item_str(@"package_id",
|
pkg_id.path.to_str().to_managed())];
|
||||||
pkg_id.path.to_str().to_managed())]
|
|
||||||
} else { ~[] };
|
|
||||||
|
|
||||||
debug!("link options: %?", link_options);
|
debug!("link options: %?", link_options);
|
||||||
crate = @ast::Crate {
|
crate = @ast::Crate {
|
||||||
|
|
Loading…
Reference in New Issue