Skip to content

Commit bab2853

Browse files
committed
---
yaml --- r: 61316 b: refs/heads/try c: 7e4a176 h: refs/heads/master v: v3
1 parent 42e90de commit bab2853

File tree

15 files changed

+424
-405
lines changed

15 files changed

+424
-405
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 2d28d645422c1617be58c8ca7ad9a457264ca850
5-
refs/heads/try: c3875e8c7066b5879437b3a5b578a6665fe767f2
5+
refs/heads/try: 7e4a176dd3a1789d5d10cb995a62daa185cb9cdd
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/libcore/vec.rs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2071,8 +2071,6 @@ pub trait ImmutableVector<'self, T> {
20712071
fn initn(&self, n: uint) -> &'self [T];
20722072
fn last(&self) -> &'self T;
20732073
fn last_opt(&self) -> Option<&'self T>;
2074-
fn position(&self, f: &fn(t: &T) -> bool) -> Option<uint>;
2075-
fn rposition(&self, f: &fn(t: &T) -> bool) -> Option<uint>;
20762074
#[cfg(stage0)]
20772075
fn each_reverse(&self, blk: &fn(&T) -> bool);
20782076
#[cfg(not(stage0))]
@@ -2140,30 +2138,6 @@ impl<'self,T> ImmutableVector<'self, T> for &'self [T] {
21402138
#[inline]
21412139
fn last_opt(&self) -> Option<&'self T> { last_opt(*self) }
21422140

2143-
/**
2144-
* Find the first index matching some predicate
2145-
*
2146-
* Apply function `f` to each element of `v`. When function `f` returns
2147-
* true then an option containing the index is returned. If `f` matches no
2148-
* elements then none is returned.
2149-
*/
2150-
#[inline]
2151-
fn position(&self, f: &fn(t: &T) -> bool) -> Option<uint> {
2152-
position(*self, f)
2153-
}
2154-
2155-
/**
2156-
* Find the last index matching some predicate
2157-
*
2158-
* Apply function `f` to each element of `v` in reverse order. When
2159-
* function `f` returns true then an option containing the index is
2160-
* returned. If `f` matches no elements then none is returned.
2161-
*/
2162-
#[inline]
2163-
fn rposition(&self, f: &fn(t: &T) -> bool) -> Option<uint> {
2164-
rposition(*self, f)
2165-
}
2166-
21672141
/// Iterates over a vector's elements in reverse.
21682142
#[inline]
21692143
#[cfg(stage0)]
@@ -2256,17 +2230,43 @@ impl<'self,T> ImmutableVector<'self, T> for &'self [T] {
22562230
}
22572231

22582232
pub trait ImmutableEqVector<T:Eq> {
2233+
fn position(&self, f: &fn(t: &T) -> bool) -> Option<uint>;
22592234
fn position_elem(&self, t: &T) -> Option<uint>;
2235+
fn rposition(&self, f: &fn(t: &T) -> bool) -> Option<uint>;
22602236
fn rposition_elem(&self, t: &T) -> Option<uint>;
22612237
}
22622238

22632239
impl<'self,T:Eq> ImmutableEqVector<T> for &'self [T] {
2240+
/**
2241+
* Find the first index matching some predicate
2242+
*
2243+
* Apply function `f` to each element of `v`. When function `f` returns
2244+
* true then an option containing the index is returned. If `f` matches no
2245+
* elements then none is returned.
2246+
*/
2247+
#[inline]
2248+
fn position(&self, f: &fn(t: &T) -> bool) -> Option<uint> {
2249+
position(*self, f)
2250+
}
2251+
22642252
/// Find the first index containing a matching value
22652253
#[inline]
22662254
fn position_elem(&self, x: &T) -> Option<uint> {
22672255
position_elem(*self, x)
22682256
}
22692257

2258+
/**
2259+
* Find the last index matching some predicate
2260+
*
2261+
* Apply function `f` to each element of `v` in reverse order. When
2262+
* function `f` returns true then an option containing the index is
2263+
* returned. If `f` matches no elements then none is returned.
2264+
*/
2265+
#[inline]
2266+
fn rposition(&self, f: &fn(t: &T) -> bool) -> Option<uint> {
2267+
rposition(*self, f)
2268+
}
2269+
22702270
/// Find the last index containing a matching value
22712271
#[inline]
22722272
fn rposition_elem(&self, t: &T) -> Option<uint> {

branches/try/src/librustpkg/path_util.rs

Lines changed: 48 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@
1010

1111
// rustpkg utilities having to do with paths and directories
1212

13-
pub use util::{PkgId, RemotePath, LocalPath};
13+
use util::PkgId;
1414
use core::libc::consts::os::posix88::{S_IRUSR, S_IWUSR, S_IXUSR};
1515
use core::os::mkdir_recursive;
16-
pub use util::{normalize, OutputType, Main, Lib, Bench, Test};
16+
17+
#[deriving(Eq)]
18+
pub enum OutputType { Main, Lib, Bench, Test }
1719

1820
/// Returns the value of RUST_PATH, as a list
1921
/// of Paths. In general this should be read from the
@@ -29,73 +31,67 @@ pub static u_rwx: i32 = (S_IRUSR | S_IWUSR | S_IXUSR) as i32;
2931
/// succeeded.
3032
pub fn make_dir_rwx(p: &Path) -> bool { os::make_dir(p, u_rwx) }
3133

34+
/// Replace all occurrences of '-' in the stem part of path with '_'
35+
/// This is because we treat rust-foo-bar-quux and rust_foo_bar_quux
36+
/// as the same name
37+
pub fn normalize(p: ~Path) -> ~Path {
38+
match p.filestem() {
39+
None => p,
40+
Some(st) => {
41+
let replaced = str::replace(st, "-", "_");
42+
if replaced != st {
43+
~p.with_filestem(replaced)
44+
}
45+
else {
46+
p
47+
}
48+
}
49+
}
50+
}
51+
3252
// n.b. So far this only handles local workspaces
3353
// n.b. The next three functions ignore the package version right
3454
// now. Should fix that.
3555

3656
/// True if there's a directory in <workspace> with
3757
/// pkgid's short name
38-
pub fn workspace_contains_package_id(pkgid: PkgId, workspace: &Path) -> bool {
39-
let pkgpath = workspace.push("src").push(pkgid.local_path.to_str());
58+
pub fn workspace_contains_package_id(pkgid: &PkgId, workspace: &Path) -> bool {
59+
let pkgpath = workspace.push("src").push(pkgid.path.to_str());
4060
os::path_is_dir(&pkgpath)
4161
}
4262

4363
/// Return the directory for <pkgid>'s source files in <workspace>.
4464
/// Doesn't check that it exists.
4565
pub fn pkgid_src_in_workspace(pkgid: &PkgId, workspace: &Path) -> Path {
4666
let result = workspace.push("src");
47-
result.push(pkgid.local_path.to_str())
67+
result.push(pkgid.path.to_str())
4868
}
4969

5070
/// Figure out what the executable name for <pkgid> in <workspace>'s build
5171
/// directory is, and if the file exists, return it.
5272
pub fn built_executable_in_workspace(pkgid: &PkgId, workspace: &Path) -> Option<Path> {
5373
let mut result = workspace.push("build");
74+
result = result.push_rel(&pkgid.path);
5475
// should use a target-specific subdirectory
55-
result = mk_output_path(Main, pkgid, &result);
76+
result = mk_output_path(Main, fmt!("%s-%s", pkgid.path.to_str(), pkgid.version.to_str()),
77+
result);
5678
debug!("built_executable_in_workspace: checking whether %s exists",
5779
result.to_str());
5880
if os::path_exists(&result) {
5981
Some(result)
6082
}
6183
else {
62-
// This is not an error, but it's worth logging it
63-
error!(fmt!("built_executable_in_workspace: %s does not exist", result.to_str()));
6484
None
6585
}
6686
}
6787

68-
/// Figure out what the test name for <pkgid> in <workspace>'s build
69-
/// directory is, and if the file exists, return it.
70-
pub fn built_test_in_workspace(pkgid: PkgId, workspace: &Path) -> Option<Path> {
71-
output_in_workspace(pkgid, workspace, Test)
72-
}
73-
74-
/// Figure out what the test name for <pkgid> in <workspace>'s build
88+
/// Figure out what the library name for <pkgid> in <workspace>'s build
7589
/// directory is, and if the file exists, return it.
76-
pub fn built_bench_in_workspace(pkgid: PkgId, workspace: &Path) -> Option<Path> {
77-
output_in_workspace(pkgid, workspace, Bench)
78-
}
79-
80-
fn output_in_workspace(pkgid: PkgId, workspace: &Path, what: OutputType) -> Option<Path> {
90+
pub fn built_library_in_workspace(pkgid: &PkgId, workspace: &Path) -> Option<Path> {
8191
let mut result = workspace.push("build");
92+
result = result.push_rel(&pkgid.path);
8293
// should use a target-specific subdirectory
83-
result = mk_output_path(what, pkgid, &result);
84-
debug!("output_in_workspace: checking whether %s exists",
85-
result.to_str());
86-
if os::path_exists(&result) {
87-
Some(result)
88-
}
89-
else {
90-
error!(fmt!("output_in_workspace: %s does not exist", result.to_str()));
91-
None
92-
}
93-
}
94-
95-
/// Figure out what the library name for <pkgid> in <workspace>'s build
96-
/// directory is, and if the file exists, return it.
97-
pub fn built_library_in_workspace(pkgid: PkgId, workspace: &Path) -> Option<Path> {
98-
let result = mk_output_path(Lib, pkgid, &workspace.push("build"));
94+
result = mk_output_path(Lib, pkgid.path.to_str(), result);
9995
debug!("built_library_in_workspace: checking whether %s exists",
10096
result.to_str());
10197

@@ -104,7 +100,8 @@ pub fn built_library_in_workspace(pkgid: PkgId, workspace: &Path) -> Option<Path
104100
let dir_contents = os::list_dir(&result.pop());
105101
debug!("dir has %? entries", dir_contents.len());
106102

107-
let lib_prefix = fmt!("%s%s", os::consts::DLL_PREFIX, pkgid.short_name);
103+
// n.b. This code assumes the pkgid's path only has one element
104+
let lib_prefix = fmt!("%s%s", os::consts::DLL_PREFIX, pkgid.path.to_str());
108105
let lib_filetype = fmt!("%s%s", pkgid.version.to_str(), os::consts::DLL_SUFFIX);
109106

110107
debug!("lib_prefix = %s and lib_filetype = %s", lib_prefix, lib_filetype);
@@ -176,15 +173,13 @@ pub fn target_library_in_workspace(pkgid: &PkgId, workspace: &Path) -> Path {
176173

177174
/// Returns the test executable that would be installed for <pkgid>
178175
/// in <workspace>
179-
/// note that we *don't* install test executables, so this is just for unit testing
180-
pub fn target_test_in_workspace(pkgid: PkgId, workspace: &Path) -> Path {
176+
pub fn target_test_in_workspace(pkgid: &PkgId, workspace: &Path) -> Path {
181177
target_file_in_workspace(pkgid, workspace, Test)
182178
}
183179

184180
/// Returns the bench executable that would be installed for <pkgid>
185181
/// in <workspace>
186-
/// note that we *don't* install bench executables, so this is just for unit testing
187-
pub fn target_bench_in_workspace(pkgid: PkgId, workspace: &Path) -> Path {
182+
pub fn target_bench_in_workspace(pkgid: &PkgId, workspace: &Path) -> Path {
188183
target_file_in_workspace(pkgid, workspace, Bench)
189184
}
190185

@@ -193,14 +188,17 @@ fn target_file_in_workspace(pkgid: &PkgId, workspace: &Path,
193188
use conditions::bad_path::cond;
194189

195190
let (subdir, create_dir) = match what {
196-
Lib => "lib", Main | Test | Bench => "bin"
191+
Main => ("bin", true), Lib => ("lib", true), Test | Bench => ("build", false)
197192
};
198193
let result = workspace.push(subdir);
199-
debug!("target_file_in_workspace: %s %?", result.to_str(), create_dir);
200-
if !os::path_exists(&result) && !mkdir_recursive(&result, u_rwx) {
201-
cond.raise((result, fmt!("I couldn't create the %s dir", subdir)));
194+
if create_dir {
195+
if !os::path_exists(&result) && !mkdir_recursive(&result, u_rwx) {
196+
cond.raise((copy result,
197+
fmt!("I couldn't create the %s dir", subdir)));
198+
}
202199
}
203-
mk_output_path(what, pkgid, &result)
200+
mk_output_path(what, pkgid.path.to_str(), result)
201+
204202
}
205203

206204
/// Return the directory for <pkgid>'s build artifacts in <workspace>.
@@ -211,7 +209,7 @@ pub fn build_pkg_id_in_workspace(pkgid: &PkgId, workspace: &Path) -> Path {
211209
let mut result = workspace.push("build");
212210
// n.b. Should actually use a target-specific
213211
// subdirectory of build/
214-
result = result.push_rel(&*pkgid.local_path);
212+
result = result.push(normalize(~copy pkgid.path).to_str());
215213
if os::path_exists(&result) || os::mkdir_recursive(&result, u_rwx) {
216214
result
217215
}
@@ -222,15 +220,8 @@ pub fn build_pkg_id_in_workspace(pkgid: &PkgId, workspace: &Path) -> Path {
222220

223221
/// Return the output file for a given directory name,
224222
/// given whether we're building a library and whether we're building tests
225-
pub fn mk_output_path(what: OutputType, pkg_id: PkgId, workspace: &Path) -> Path {
226-
let short_name = pkg_id.short_name_with_version();
227-
// Not local_path.dir_path()! For package foo/bar/blat/, we want
228-
// the executable blat-0.5 to live under blat/
229-
let dir = workspace.push_rel(&*pkg_id.local_path);
230-
debug!("mk_output_path: short_name = %s, path = %s",
231-
short_name, dir.to_str());
232-
let output_path = match what {
233-
// this code is duplicated from elsewhere; fix this
223+
pub fn mk_output_path(what: OutputType, short_name: ~str, dir: Path) -> Path {
224+
match what {
234225
Lib => dir.push(os::dll_filename(short_name)),
235226
_ => dir.push(fmt!("%s%s%s", short_name,
236227
match what {
@@ -239,7 +230,5 @@ pub fn mk_output_path(what: OutputType, pkg_id: PkgId, workspace: &Path) -> Path
239230
_ => ""
240231
}
241232
os::EXE_SUFFIX))
242-
};
243-
debug!("mk_output_path: returning %s", output_path.to_str());
244-
output_path
233+
}
245234
}

0 commit comments

Comments
 (0)