Skip to content

Commit f0df090

Browse files
committed
---
yaml --- r: 81118 b: refs/heads/snap-stage3 c: 23a067d h: refs/heads/master v: v3
1 parent 759c5aa commit f0df090

File tree

7 files changed

+35
-137
lines changed

7 files changed

+35
-137
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 4c6bf4872012c010f84dc7fa2cdfe87522533f89
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: af25f58ac3da45899ed65b3af965150c8a90dcda
4+
refs/heads/snap-stage3: 23a067dc2ce107054e34fb2d2ceda1549aa35245
55
refs/heads/try: 70152ff55722878cde684ee6462c14c65f2c4729
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/libextra/bitv.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ impl Bitv {
523523
* with the most significant bits of each byte coming first. Each
524524
* bit becomes true if equal to 1 or false if equal to 0.
525525
*/
526-
pub fn from_utf8(bytes: &[u8]) -> Bitv {
526+
pub fn from_bytes(bytes: &[u8]) -> Bitv {
527527
from_fn(bytes.len() * 8, |i| {
528528
let b = bytes[i / 8] as uint;
529529
let offset = i % 8;
@@ -1275,8 +1275,8 @@ mod tests {
12751275
}
12761276
12771277
#[test]
1278-
fn test_from_utf8() {
1279-
let bitv = from_utf8([0b10110110, 0b00000000, 0b11111111]);
1278+
fn test_from_bytes() {
1279+
let bitv = from_bytes([0b10110110, 0b00000000, 0b11111111]);
12801280
let str = ~"10110110" + "00000000" + "11111111";
12811281
assert_eq!(bitv.to_str(), str);
12821282
}
@@ -1302,7 +1302,7 @@ mod tests {
13021302
#[test]
13031303
fn test_to_bools() {
13041304
let bools = ~[false, false, true, false, false, true, true, false];
1305-
assert_eq!(from_utf8([0b00100110]).to_bools(), bools);
1305+
assert_eq!(from_bytes([0b00100110]).to_bools(), bools);
13061306
}
13071307
13081308
#[test]

branches/snap-stage3/src/librustpkg/package_source.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ impl PkgSrc {
5959
use conditions::nonexistent_package::cond;
6060

6161
debug!("Checking package source for package ID %s, \
62-
workspace = %s use_rust_path_hack = %?",
63-
id.to_str(), workspace.to_str(), use_rust_path_hack);
62+
workspace = %s", id.to_str(), workspace.to_str());
6463

6564
let mut to_try = ~[];
6665
if use_rust_path_hack {

branches/snap-stage3/src/librustpkg/path_util.rs

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -421,16 +421,11 @@ fn dir_has_file(dir: &Path, file: &str) -> bool {
421421
pub fn find_dir_using_rust_path_hack(p: &PkgId) -> Option<Path> {
422422
let rp = rust_path();
423423
for dir in rp.iter() {
424-
// Require that the parent directory match the package ID
425-
// Note that this only matches if the package ID being searched for
426-
// has a name that's a single component
427-
if dir.is_parent_of(&p.path) || dir.is_parent_of(&versionize(&p.path, &p.version)) {
428-
debug!("In find_dir_using_rust_path_hack: checking dir %s", dir.to_str());
429-
if dir_has_file(dir, "lib.rs") || dir_has_file(dir, "main.rs")
430-
|| dir_has_file(dir, "test.rs") || dir_has_file(dir, "bench.rs") {
431-
debug!("Did find id %s in dir %s", p.to_str(), dir.to_str());
432-
return Some(dir.clone());
433-
}
424+
debug!("In find_dir_using_rust_path_hack: checking dir %s", dir.to_str());
425+
if dir_has_file(dir, "lib.rs") || dir_has_file(dir, "main.rs")
426+
|| dir_has_file(dir, "test.rs") || dir_has_file(dir, "bench.rs") {
427+
debug!("Did find id %s in dir %s", p.to_str(), dir.to_str());
428+
return Some(dir.clone());
434429
}
435430
debug!("Didn't find id %s in dir %s", p.to_str(), dir.to_str())
436431
}
@@ -445,11 +440,3 @@ pub fn user_set_rust_path() -> bool {
445440
Some(_) => true
446441
}
447442
}
448-
449-
/// Append the version string onto the end of the path's filename
450-
fn versionize(p: &Path, v: &Version) -> Path {
451-
let q = p.file_path().to_str();
452-
p.with_filename(fmt!("%s-%s", q, v.to_str()))
453-
}
454-
455-

branches/snap-stage3/src/librustpkg/tests.rs

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1267,9 +1267,7 @@ fn test_rust_path_can_contain_package_dirs_without_flag() {
12671267
#[test]
12681268
fn rust_path_hack_cwd() {
12691269
// Same as rust_path_hack_test, but the CWD is the dir to build out of
1270-
let cwd = mkdtemp(&os::tmpdir(), "foo").expect("rust_path_hack_cwd");
1271-
let cwd = cwd.push("foo");
1272-
assert!(os::mkdir_recursive(&cwd, U_RWX));
1270+
let cwd = mkdtemp(&os::tmpdir(), "pkg_files").expect("rust_path_hack_cwd");
12731271
writeFile(&cwd.push("lib.rs"), "pub fn f() { }");
12741272

12751273
let dest_workspace = mk_empty_workspace(&Path("bar"), &NoVersion, "dest_workspace");
@@ -1765,41 +1763,6 @@ fn reinstall() {
17651763
assert_built_executable_exists(&workspace, b.short_name);
17661764
}
17671765
1768-
#[test]
1769-
fn correct_package_name_with_rust_path_hack() {
1770-
/*
1771-
Set rust_path_hack flag
1772-
1773-
Try to install bar
1774-
Check that:
1775-
- no output gets produced in any workspace
1776-
- there's an error
1777-
*/
1778-
1779-
// Set RUST_PATH to something containing only the sources for foo
1780-
let foo_id = PkgId::new("foo");
1781-
let bar_id = PkgId::new("bar");
1782-
let foo_workspace = create_local_package(&foo_id);
1783-
let dest_workspace = mk_empty_workspace(&Path("bar"), &NoVersion, "dest_workspace");
1784-
1785-
writeFile(&dest_workspace.push_many(["src", "bar-0.1", "main.rs"]),
1786-
"extern mod blat; fn main() { let _x = (); }");
1787-
1788-
let rust_path = Some(~[(~"RUST_PATH", fmt!("%s:%s", dest_workspace.to_str(),
1789-
foo_workspace.push_many(["src", "foo-0.1"]).to_str()))]);
1790-
// bar doesn't exist, but we want to make sure rustpkg doesn't think foo is bar
1791-
command_line_test_with_env([~"install", ~"--rust-path-hack", ~"bar"],
1792-
&dest_workspace, rust_path);
1793-
assert!(!executable_exists(&dest_workspace, "bar"));
1794-
assert!(!lib_exists(&dest_workspace, &bar_id.path.clone(), bar_id.version.clone()));
1795-
assert!(!executable_exists(&dest_workspace, "foo"));
1796-
assert!(!lib_exists(&dest_workspace, &foo_id.path.clone(), foo_id.version.clone()));
1797-
assert!(!executable_exists(&foo_workspace, "bar"));
1798-
assert!(!lib_exists(&foo_workspace, &bar_id.path.clone(), bar_id.version.clone()));
1799-
assert!(!executable_exists(&foo_workspace, "foo"));
1800-
assert!(!lib_exists(&foo_workspace, &foo_id.path.clone(), foo_id.version.clone()));
1801-
}
1802-
18031766
/// Returns true if p exists and is executable
18041767
fn is_executable(p: &Path) -> bool {
18051768
use std::libc::consts::os::posix88::{S_IXUSR};

branches/snap-stage3/src/librustpkg/util.rs

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -439,30 +439,26 @@ impl<'self> Visitor<()> for ViewItemVisitor<'self> {
439439
let pkg_id = PkgId::new(lib_name);
440440
let workspaces = pkg_parent_workspaces(&self.context.context,
441441
&pkg_id);
442-
let source_workspace = if workspaces.is_empty() {
443-
error(fmt!("Couldn't find package %s \
444-
in any of the workspaces in the RUST_PATH (%s)",
445-
lib_name,
446-
rust_path().map(|s| s.to_str()).connect(":")));
442+
let dep_workspace = if workspaces.is_empty() {
443+
error(fmt!("Couldn't find package %s, which is needed by %s, \
444+
in any of the workspaces in the RUST_PATH (%?)",
445+
lib_name,
446+
self.parent.to_str(),
447+
rust_path()));
447448
cond.raise((pkg_id.clone(), ~"Dependency not found"))
448449
}
449-
else {
450+
else {
450451
workspaces[0]
451452
};
452453
let (outputs_disc, inputs_disc) =
453-
self.context.install(PkgSrc::new(source_workspace.clone(),
454-
// Use the rust_path_hack to search for dependencies iff
455-
// we were already using it
456-
self.context.context.use_rust_path_hack,
454+
self.context.install(PkgSrc::new(dep_workspace.clone(),
455+
false,
457456
pkg_id),
458457
&JustOne(Path(
459-
lib_crate_filename)));
458+
lib_crate_filename)));
460459
debug!("Installed %s, returned %? dependencies and \
461460
%? transitive dependencies",
462461
lib_name, outputs_disc.len(), inputs_disc.len());
463-
// It must have installed *something*...
464-
assert!(!outputs_disc.is_empty());
465-
let target_workspace = outputs_disc[0].pop();
466462
for dep in outputs_disc.iter() {
467463
debug!("Discovering a binary input: %s", dep.to_str());
468464
self.exec.discover_input("binary",
@@ -475,24 +471,31 @@ impl<'self> Visitor<()> for ViewItemVisitor<'self> {
475471
*dep,
476472
digest_file_with_date(&Path(*dep)));
477473
}
478-
else if *what == ~"binary" {
474+
else if *what == ~"binary" {
479475
self.exec.discover_input(*what,
480476
*dep,
481477
digest_only_date(&Path(*dep)));
482478
}
483-
else {
479+
else {
484480
fail!("Bad kind: %s", *what);
485481
}
486482
}
487483
// Also, add an additional search path
488-
debug!("Installed %s into %s", lib_name, target_workspace.to_str());
489-
(self.save)(target_workspace);
484+
debug!("Adding additional search path: %s", lib_name);
485+
let installed_library =
486+
installed_library_in_workspace(&Path(lib_name), &dep_workspace)
487+
.expect(fmt!("rustpkg failed to install dependency %s",
488+
lib_name));
489+
let install_dir = installed_library.pop();
490+
debug!("Installed %s into %s [%?]", lib_name, install_dir.to_str(),
491+
datestamp(&installed_library));
492+
(self.save)(install_dir);
490493
}
491-
}
492-
}
494+
}}
493495
// Ignore `use`s
494496
_ => ()
495497
}
498+
496499
visit::walk_view_item(self, vi, env)
497500
}
498501
}

branches/snap-stage3/src/libstd/path.rs

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -233,21 +233,6 @@ pub trait GenericPath : Clone + Eq + ToStr {
233233
result
234234
}
235235

236-
237-
/// Returns `true` iff `child` is a suffix of `parent`. See the test
238-
/// case for examples.
239-
fn is_parent_of(&self, child: &Self) -> bool {
240-
if !self.is_absolute() || child.is_absolute()
241-
|| self.components().len() < child.components().len()
242-
|| self.components().is_empty() {
243-
return false;
244-
}
245-
let child_components = child.components().len();
246-
let parent_components = self.components().len();
247-
let to_drop = self.components().len() - child_components;
248-
self.components().slice(to_drop, parent_components) == child.components()
249-
}
250-
251236
fn components<'a>(&'a self) -> &'a [~str];
252237
}
253238

@@ -1465,43 +1450,4 @@ mod tests {
14651450

14661451
}
14671452

1468-
1469-
#[test]
1470-
fn test_is_parent_of() {
1471-
fn is_parent_of_pp(p: &PosixPath, q: &PosixPath) -> bool {
1472-
p.is_parent_of(q)
1473-
}
1474-
1475-
assert!(is_parent_of_pp(&PosixPath("/a/b/c/d/e"), &PosixPath("c/d/e")));
1476-
assert!(!is_parent_of_pp(&PosixPath("a/b/c/d/e"), &PosixPath("c/d/e")));
1477-
assert!(!is_parent_of_pp(&PosixPath("/a/b/c/d/e"), &PosixPath("/c/d/e")));
1478-
assert!(!is_parent_of_pp(&PosixPath(""), &PosixPath("")));
1479-
assert!(!is_parent_of_pp(&PosixPath(""), &PosixPath("a/b/c")));
1480-
assert!(is_parent_of_pp(&PosixPath("/a/b/c"), &PosixPath("")));
1481-
assert!(is_parent_of_pp(&PosixPath("/a/b/c"), &PosixPath("a/b/c")));
1482-
assert!(!is_parent_of_pp(&PosixPath("/a/b/c"), &PosixPath("d/e/f")));
1483-
1484-
fn is_parent_of_wp(p: &WindowsPath, q: &WindowsPath) -> bool {
1485-
p.is_parent_of(q)
1486-
}
1487-
1488-
let abcde = WindowsPath("C:\\a\\b\\c\\d\\e");
1489-
let rel_abcde = WindowsPath("a\\b\\c\\d\\e");
1490-
let cde = WindowsPath("c\\d\\e");
1491-
let slashcde = WindowsPath("C:\\c\\d\\e");
1492-
let empty = WindowsPath("");
1493-
let abc = WindowsPath("C:\\a\\b\\c");
1494-
let rel_abc = WindowsPath("a\\b\\c");
1495-
let def = WindowsPath("d\\e\\f");
1496-
1497-
assert!(is_parent_of_wp(&abcde, &cde));
1498-
assert!(!is_parent_of_wp(&rel_abcde, &cde));
1499-
assert!(!is_parent_of_wp(&abcde, &slashcde));
1500-
assert!(!is_parent_of_wp(&empty, &empty));
1501-
assert!(!is_parent_of_wp(&empty, &rel_abc));
1502-
assert!(is_parent_of_wp(&abc, &empty));
1503-
assert!(is_parent_of_wp(&abc, &rel_abc));
1504-
assert!(!is_parent_of_wp(&abc, &def));
1505-
}
1506-
15071453
}

0 commit comments

Comments
 (0)