Skip to content

Commit ccadbd3

Browse files
committed
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).
2 parents a2231dc + a7e49d6 commit ccadbd3

File tree

2 files changed

+51
-4
lines changed

2 files changed

+51
-4
lines changed

src/librustpkg/tests.rs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,6 +1111,55 @@ fn test_extern_mod() {
11111111
assert!(os::path_exists(&exec_file) && is_executable(&exec_file));
11121112
}
11131113

1114+
#[test]
1115+
fn test_extern_mod_simpler() {
1116+
let dir = mkdtemp(&os::tmpdir(), "test_extern_mod_simpler").expect("test_extern_mod_simpler");
1117+
let main_file = dir.push("main.rs");
1118+
let lib_depend_dir = mkdtemp(&os::tmpdir(), "foo").expect("test_extern_mod_simpler");
1119+
let aux_dir = lib_depend_dir.push_many(["src", "rust-awesomeness"]);
1120+
assert!(os::mkdir_recursive(&aux_dir, U_RWX));
1121+
let aux_pkg_file = aux_dir.push("lib.rs");
1122+
1123+
writeFile(&aux_pkg_file, "pub mod bar { pub fn assert_true() { assert!(true); } }\n");
1124+
assert!(os::path_exists(&aux_pkg_file));
1125+
1126+
writeFile(&main_file,
1127+
"extern mod test = \"rust-awesomeness\";\nuse test::bar;\
1128+
fn main() { bar::assert_true(); }\n");
1129+
1130+
command_line_test([~"install", ~"rust-awesomeness"], &lib_depend_dir);
1131+
1132+
let exec_file = dir.push("out");
1133+
// Be sure to extend the existing environment
1134+
let env = Some([(~"RUST_PATH", lib_depend_dir.to_str())] + os::env());
1135+
let rustpkg_exec = rustpkg_exec();
1136+
let rustc = rustpkg_exec.with_filename("rustc");
1137+
debug!("RUST_PATH=%s %s %s \n --sysroot %s -o %s",
1138+
lib_depend_dir.to_str(),
1139+
rustc.to_str(),
1140+
main_file.to_str(),
1141+
test_sysroot().to_str(),
1142+
exec_file.to_str());
1143+
1144+
let mut prog = run::Process::new(rustc.to_str(), [main_file.to_str(),
1145+
~"--sysroot", test_sysroot().to_str(),
1146+
~"-o", exec_file.to_str()],
1147+
run::ProcessOptions {
1148+
env: env,
1149+
dir: Some(&dir),
1150+
in_fd: None,
1151+
out_fd: None,
1152+
err_fd: None
1153+
});
1154+
let outp = prog.finish_with_output();
1155+
if outp.status != 0 {
1156+
fail!("output was %s, error was %s",
1157+
str::from_utf8(outp.output),
1158+
str::from_utf8(outp.error));
1159+
}
1160+
assert!(os::path_exists(&exec_file) && is_executable(&exec_file));
1161+
}
1162+
11141163
#[test]
11151164
fn test_import_rustpkg() {
11161165
let p_id = PkgId::new("foo");

src/librustpkg/util.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,10 +268,8 @@ pub fn compile_input(context: &BuildContext,
268268
let link_options =
269269
~[attr::mk_name_value_item_str(@"name", name_to_use),
270270
attr::mk_name_value_item_str(@"vers", pkg_id.version.to_str().to_managed())] +
271-
if pkg_id.is_complex() {
272-
~[attr::mk_name_value_item_str(@"package_id",
273-
pkg_id.path.to_str().to_managed())]
274-
} else { ~[] };
271+
~[attr::mk_name_value_item_str(@"package_id",
272+
pkg_id.path.to_str().to_managed())];
275273

276274
debug!("link options: %?", link_options);
277275
crate = @ast::Crate {

0 commit comments

Comments
 (0)