Skip to content

Commit 42e90de

Browse files
committed
---
yaml --- r: 61315 b: refs/heads/try c: c3875e8 h: refs/heads/master i: 61313: 0cde71b 61311: 9f2e87b v: v3
1 parent ed07fcf commit 42e90de

File tree

17 files changed

+363
-329
lines changed

17 files changed

+363
-329
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: 68863153bba3ab994978b49216cb58641e7a9fbb
5+
refs/heads/try: c3875e8c7066b5879437b3a5b578a6665fe767f2
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/librustc/middle/resolve.rs

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2058,8 +2058,7 @@ pub impl Resolver {
20582058
self.resolve_single_import(module_,
20592059
containing_module,
20602060
target,
2061-
source,
2062-
import_directive.span);
2061+
source);
20632062
}
20642063
GlobImport => {
20652064
let span = import_directive.span;
@@ -2122,8 +2121,7 @@ pub impl Resolver {
21222121
module_: @mut Module,
21232122
containing_module: @mut Module,
21242123
target: ident,
2125-
source: ident,
2126-
span: span)
2124+
source: ident)
21272125
-> ResolveResult<()> {
21282126
debug!("(resolving single import) resolving `%s` = `%s::%s` from \
21292127
`%s`",
@@ -2327,14 +2325,14 @@ pub impl Resolver {
23272325
}
23282326

23292327
if resolve_fail {
2330-
self.session.span_err(span, fmt!("unresolved import: there is no `%s` in `%s`",
2331-
*self.session.str_of(source),
2332-
self.module_to_str(containing_module)));
2328+
self.session.err(fmt!("unresolved import: there is no `%s` in `%s`",
2329+
*self.session.str_of(source),
2330+
self.module_to_str(containing_module)));
23332331
return Failed;
23342332
} else if priv_fail {
2335-
self.session.span_err(span, fmt!("unresolved import: found `%s` in `%s` but it is \
2336-
private", *self.session.str_of(source),
2337-
self.module_to_str(containing_module)));
2333+
self.session.err(fmt!("unresolved import: found `%s` in `%s` but it is private",
2334+
*self.session.str_of(source),
2335+
self.module_to_str(containing_module)));
23382336
return Failed;
23392337
}
23402338

@@ -2595,18 +2593,7 @@ pub impl Resolver {
25952593
let start_index;
25962594
match module_prefix_result {
25972595
Failed => {
2598-
let mpath = self.idents_to_str(module_path);
2599-
match str::rfind(self.idents_to_str(module_path), |c| { c == ':' }) {
2600-
Some(idx) => {
2601-
self.session.span_err(span, fmt!("unresolved import: could not find `%s` \
2602-
in `%s`", str::substr(mpath, idx,
2603-
mpath.len() - idx),
2604-
// idx - 1 to account for the extra
2605-
// colon
2606-
str::substr(mpath, 0, idx - 1)));
2607-
},
2608-
None => (),
2609-
};
2596+
self.session.span_err(span, ~"unresolved name");
26102597
return Failed;
26112598
}
26122599
Indeterminate => {

branches/try/src/librustpkg/path_util.rs

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

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

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

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

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-
5232
// n.b. So far this only handles local workspaces
5333
// n.b. The next three functions ignore the package version right
5434
// now. Should fix that.
5535

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

6343
/// Return the directory for <pkgid>'s source files in <workspace>.
6444
/// Doesn't check that it exists.
6545
pub fn pkgid_src_in_workspace(pkgid: &PkgId, workspace: &Path) -> Path {
6646
let result = workspace.push("src");
67-
result.push(pkgid.path.to_str())
47+
result.push(pkgid.local_path.to_str())
6848
}
6949

7050
/// Figure out what the executable name for <pkgid> in <workspace>'s build
7151
/// directory is, and if the file exists, return it.
7252
pub fn built_executable_in_workspace(pkgid: &PkgId, workspace: &Path) -> Option<Path> {
7353
let mut result = workspace.push("build");
74-
result = result.push_rel(&pkgid.path);
7554
// should use a target-specific subdirectory
76-
result = mk_output_path(Main, fmt!("%s-%s", pkgid.path.to_str(), pkgid.version.to_str()),
77-
result);
55+
result = mk_output_path(Main, pkgid, &result);
7856
debug!("built_executable_in_workspace: checking whether %s exists",
7957
result.to_str());
8058
if os::path_exists(&result) {
8159
Some(result)
8260
}
8361
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()));
8464
None
8565
}
8666
}
8767

88-
/// Figure out what the library name for <pkgid> in <workspace>'s build
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
8975
/// directory is, and if the file exists, return it.
90-
pub fn built_library_in_workspace(pkgid: &PkgId, workspace: &Path) -> Option<Path> {
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> {
9181
let mut result = workspace.push("build");
92-
result = result.push_rel(&pkgid.path);
9382
// should use a target-specific subdirectory
94-
result = mk_output_path(Lib, pkgid.path.to_str(), result);
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"));
9599
debug!("built_library_in_workspace: checking whether %s exists",
96100
result.to_str());
97101

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

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());
107+
let lib_prefix = fmt!("%s%s", os::consts::DLL_PREFIX, pkgid.short_name);
105108
let lib_filetype = fmt!("%s%s", pkgid.version.to_str(), os::consts::DLL_SUFFIX);
106109

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

174177
/// Returns the test executable that would be installed for <pkgid>
175178
/// in <workspace>
176-
pub fn target_test_in_workspace(pkgid: &PkgId, workspace: &Path) -> Path {
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 {
177181
target_file_in_workspace(pkgid, workspace, Test)
178182
}
179183

180184
/// Returns the bench executable that would be installed for <pkgid>
181185
/// in <workspace>
182-
pub fn target_bench_in_workspace(pkgid: &PkgId, workspace: &Path) -> Path {
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 {
183188
target_file_in_workspace(pkgid, workspace, Bench)
184189
}
185190

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

190195
let (subdir, create_dir) = match what {
191-
Main => ("bin", true), Lib => ("lib", true), Test | Bench => ("build", false)
196+
Lib => "lib", Main | Test | Bench => "bin"
192197
};
193198
let result = workspace.push(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-
}
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)));
199202
}
200-
mk_output_path(what, pkgid.path.to_str(), result)
201-
203+
mk_output_path(what, pkgid, &result)
202204
}
203205

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

221223
/// Return the output file for a given directory name,
222224
/// given whether we're building a library and whether we're building tests
223-
pub fn mk_output_path(what: OutputType, short_name: ~str, dir: Path) -> Path {
224-
match what {
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
225234
Lib => dir.push(os::dll_filename(short_name)),
226235
_ => dir.push(fmt!("%s%s%s", short_name,
227236
match what {
@@ -230,5 +239,7 @@ pub fn mk_output_path(what: OutputType, short_name: ~str, dir: Path) -> Path {
230239
_ => ""
231240
}
232241
os::EXE_SUFFIX))
233-
}
242+
};
243+
debug!("mk_output_path: returning %s", output_path.to_str());
244+
output_path
234245
}

0 commit comments

Comments
 (0)