Skip to content

Commit 33d4e3d

Browse files
committed
---
yaml --- r: 145007 b: refs/heads/try2 c: b4b375c h: refs/heads/master i: 145005: b519da8 145003: 13002ca 144999: 75d13a1 144991: 255a20a v: v3
1 parent 845c16a commit 33d4e3d

File tree

4 files changed

+53
-10
lines changed

4 files changed

+53
-10
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 19c07352319e1953bdff52618a540dd915a0abbd
8+
refs/heads/try2: b4b375cbae22f3c0996c02c9b3d998c001b3a837
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/librustpkg/path_util.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,3 +399,12 @@ pub fn find_dir_using_rust_path_hack(p: &PkgId) -> Option<Path> {
399399
}
400400
None
401401
}
402+
403+
/// True if the user set RUST_PATH to something non-empty --
404+
/// as opposed to the default paths that rustpkg adds automatically
405+
pub fn user_set_rust_path() -> bool {
406+
match os::getenv("RUST_PATH") {
407+
None | Some(~"") => false,
408+
Some(_) => true
409+
}
410+
}

branches/try2/src/librustpkg/rustpkg.rs

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,10 @@ pub trait CtxMethods {
181181
/// second is a list of declared and discovered inputs
182182
fn install(&self, src: PkgSrc) -> (~[Path], ~[(~str, ~str)]);
183183
/// Returns a list of installed files
184-
fn install_no_build(&self, workspace: &Path, id: &PkgId) -> ~[Path];
184+
fn install_no_build(&self,
185+
source_workspace: &Path,
186+
target_workspace: &Path,
187+
id: &PkgId) -> ~[Path];
185188
fn prefer(&self, _id: &str, _vers: Option<~str>);
186189
fn test(&self);
187190
fn uninstall(&self, _id: &str, _vers: Option<~str>);
@@ -464,28 +467,40 @@ impl CtxMethods for BuildContext {
464467
// install to the first workspace in the RUST_PATH if there's
465468
// a non-default RUST_PATH. This code installs to the same
466469
// workspace the package was built in.
467-
debug!("install: destination workspace = %s, id = %s",
468-
destination_workspace, id_str);
469-
let result = subself.install_no_build(&Path(destination_workspace), &sub_id);
470+
let actual_workspace = if path_util::user_set_rust_path() {
471+
default_workspace()
472+
}
473+
else {
474+
Path(destination_workspace)
475+
};
476+
debug!("install: destination workspace = %s, id = %s, installing to %s",
477+
destination_workspace, id_str, actual_workspace.to_str());
478+
let result = subself.install_no_build(&Path(destination_workspace),
479+
&actual_workspace,
480+
&sub_id);
470481
debug!("install: id = %s, about to call discover_outputs, %?",
471482
id_str, result.to_str());
472483

473484
discover_outputs(exec, result.clone());
474485
sub_files.write(|r| { *r = result.clone(); });
475486
sub_inputs.write(|r| { *r = *r + exec.lookup_discovered_inputs() });
487+
note(fmt!("Installed package %s to %s", id_str, actual_workspace.to_str()));
476488
}
477489
};
478490
(installed_files.unwrap(), inputs.unwrap())
479491
}
480492

481-
fn install_no_build(&self, workspace: &Path, id: &PkgId) -> ~[Path] {
493+
fn install_no_build(&self,
494+
source_workspace: &Path,
495+
target_workspace: &Path,
496+
id: &PkgId) -> ~[Path] {
482497
use conditions::copy_failed::cond;
483498

484499
// Now copy stuff into the install dirs
485-
let maybe_executable = built_executable_in_workspace(id, workspace);
486-
let maybe_library = built_library_in_workspace(id, workspace);
487-
let target_exec = target_executable_in_workspace(id, workspace);
488-
let target_lib = maybe_library.map(|_p| target_library_in_workspace(id, workspace));
500+
let maybe_executable = built_executable_in_workspace(id, source_workspace);
501+
let maybe_library = built_library_in_workspace(id, source_workspace);
502+
let target_exec = target_executable_in_workspace(id, target_workspace);
503+
let target_lib = maybe_library.map(|_p| target_library_in_workspace(id, target_workspace));
489504

490505
debug!("target_exec = %s target_lib = %? \
491506
maybe_executable = %? maybe_library = %?",

branches/try2/src/librustpkg/tests.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1603,6 +1603,25 @@ fn test_recursive_deps() {
16031603
assert_lib_exists(&b_workspace, &Path("c"), NoVersion);
16041604
}
16051605
1606+
#[test]
1607+
fn test_install_to_rust_path() {
1608+
let p_id = PkgId::new("foo");
1609+
let second_workspace = create_local_package(&p_id);
1610+
let first_workspace = mk_empty_workspace(&Path("p"), &NoVersion, "dest");
1611+
let rust_path = Some(~[(~"RUST_PATH",
1612+
fmt!("%s:%s", first_workspace.to_str(),
1613+
second_workspace.to_str()))]);
1614+
debug!("RUST_PATH=%s:%s", first_workspace.to_str(), second_workspace.to_str());
1615+
command_line_test_with_env([test_sysroot().to_str(),
1616+
~"install",
1617+
~"foo"],
1618+
&os::getcwd(), rust_path);
1619+
assert!(!built_executable_exists(&first_workspace, "foo"));
1620+
assert!(built_executable_exists(&second_workspace, "foo"));
1621+
assert_executable_exists(&first_workspace, "foo");
1622+
assert!(!executable_exists(&second_workspace, "foo"));
1623+
}
1624+
16061625
/// Returns true if p exists and is executable
16071626
fn is_executable(p: &Path) -> bool {
16081627
use std::libc::consts::os::posix88::{S_IXUSR};

0 commit comments

Comments
 (0)