diff options
| author | bors <bors@rust-lang.org> | 2013-09-25 12:45:54 -0700 | 
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-09-25 12:45:54 -0700 | 
| commit | af25f58ac3da45899ed65b3af965150c8a90dcda (patch) | |
| tree | eca071107edf532e600606f68f602e7e3d8f56d4 /src/librustpkg/path_util.rs | |
| parent | 0186473bd2ec34a56496c7b513ee380cbf30a6a3 (diff) | |
| parent | 667adad26f9cc1cfa4eeba8aee15035da7544f8c (diff) | |
| download | rust-af25f58ac3da45899ed65b3af965150c8a90dcda.tar.gz rust-af25f58ac3da45899ed65b3af965150c8a90dcda.zip | |
auto merge of #9498 : catamorphism/rust/rust-path-hack-fix, r=cmr,metajack
r? @metajack
Diffstat (limited to 'src/librustpkg/path_util.rs')
| -rw-r--r-- | src/librustpkg/path_util.rs | 23 | 
1 files changed, 18 insertions, 5 deletions
| diff --git a/src/librustpkg/path_util.rs b/src/librustpkg/path_util.rs index 3ed1b7a3a9c..7061345341f 100644 --- a/src/librustpkg/path_util.rs +++ b/src/librustpkg/path_util.rs @@ -421,11 +421,16 @@ fn dir_has_file(dir: &Path, file: &str) -> bool { pub fn find_dir_using_rust_path_hack(p: &PkgId) -> Option<Path> { let rp = rust_path(); for dir in rp.iter() { - debug!("In find_dir_using_rust_path_hack: checking dir %s", dir.to_str()); - if dir_has_file(dir, "lib.rs") || dir_has_file(dir, "main.rs") - || dir_has_file(dir, "test.rs") || dir_has_file(dir, "bench.rs") { - debug!("Did find id %s in dir %s", p.to_str(), dir.to_str()); - return Some(dir.clone()); + // Require that the parent directory match the package ID + // Note that this only matches if the package ID being searched for + // has a name that's a single component + if dir.is_parent_of(&p.path) || dir.is_parent_of(&versionize(&p.path, &p.version)) { + debug!("In find_dir_using_rust_path_hack: checking dir %s", dir.to_str()); + if dir_has_file(dir, "lib.rs") || dir_has_file(dir, "main.rs") + || dir_has_file(dir, "test.rs") || dir_has_file(dir, "bench.rs") { + debug!("Did find id %s in dir %s", p.to_str(), dir.to_str()); + return Some(dir.clone()); + } } debug!("Didn't find id %s in dir %s", p.to_str(), dir.to_str()) } @@ -440,3 +445,11 @@ pub fn user_set_rust_path() -> bool { Some(_) => true } } + +/// Append the version string onto the end of the path's filename +fn versionize(p: &Path, v: &Version) -> Path { + let q = p.file_path().to_str(); + p.with_filename(fmt!("%s-%s", q, v.to_str())) +} + + | 
