Skip to content

Always write a package_id attribute into the link metadata #9179

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions src/librustpkg/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
6 changes: 2 additions & 4 deletions src/librustpkg/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down