Skip to content

Commit b4a0a8b

Browse files
committed
---
yaml --- r: 145015 b: refs/heads/try2 c: fd39bd1 h: refs/heads/master i: 145013: bfce291 145011: 49d06f7 145007: 33d4e3d v: v3
1 parent f634fae commit b4a0a8b

File tree

24 files changed

+594
-290
lines changed

24 files changed

+594
-290
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: 3d14e82be752959fb010a786ef4c9ef417bd64db
8+
refs/heads/try2: fd39bd169c594c02494527dfa09c3a7f7237180c
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/mk/rt.mk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ RUNTIME_CXXS_$(1)_$(2) := \
7575
rt/rust_rng.cpp \
7676
rt/rust_upcall.cpp \
7777
rt/rust_uv.cpp \
78-
rt/rust_crate_map.cpp \
7978
rt/isaac/randport.cpp \
8079
rt/miniz.cpp \
8180
rt/memory_region.cpp \

branches/try2/src/librustc/middle/stack_check.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,18 @@ fn stack_check_item(v: StackCheckVisitor,
8080
visit::walk_method_helper(&mut v, method, new_cx);
8181
}
8282
}
83+
ast::item_trait(_, _, ref methods) => {
84+
for method in methods.iter() {
85+
match *method {
86+
ast::provided(@ref method) => {
87+
let safe_stack = fixed_stack_segment(method.attrs);
88+
let new_cx = Context {safe_stack: safe_stack, ..in_cx};
89+
visit::walk_method_helper(&mut v, method, new_cx);
90+
}
91+
ast::required(*) => ()
92+
}
93+
}
94+
}
8395
_ => {
8496
visit::walk_item(&mut v, item, in_cx);
8597
}

branches/try2/src/librustc/middle/ty.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4267,6 +4267,7 @@ pub fn is_binopable(cx: ctxt, ty: t, op: ast::BinOp) -> bool {
42674267
static tycat_int: int = 3;
42684268
static tycat_float: int = 4;
42694269
static tycat_bot: int = 5;
4270+
static tycat_raw_ptr: int = 6;
42704271

42714272
static opcat_add: int = 0;
42724273
static opcat_sub: int = 1;
@@ -4310,6 +4311,7 @@ pub fn is_binopable(cx: ctxt, ty: t, op: ast::BinOp) -> bool {
43104311
ty_int(_) | ty_uint(_) | ty_infer(IntVar(_)) => tycat_int,
43114312
ty_float(_) | ty_infer(FloatVar(_)) => tycat_float,
43124313
ty_bot => tycat_bot,
4314+
ty_ptr(_) => tycat_raw_ptr,
43134315
_ => tycat_other
43144316
}
43154317
}
@@ -4324,7 +4326,8 @@ pub fn is_binopable(cx: ctxt, ty: t, op: ast::BinOp) -> bool {
43244326
/*char*/ [f, f, f, f, t, t, f, f],
43254327
/*int*/ [t, t, t, t, t, t, t, f],
43264328
/*float*/ [t, t, t, f, t, t, f, f],
4327-
/*bot*/ [t, t, t, t, f, f, t, t]];
4329+
/*bot*/ [t, t, t, t, f, f, t, t],
4330+
/*raw ptr*/ [f, f, f, f, t, t, f, f]];
43284331

43294332
return tbl[tycat(cx, ty)][opcat(op)];
43304333
}

branches/try2/src/librustpkg/package_id.rs

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,35 @@ impl PkgId {
9999
/// True if the ID has multiple components
100100
pub fn is_complex(&self) -> bool {
101101
self.short_name != self.path.to_str()
102-
}
102+
}
103+
104+
pub fn prefixes_iter(&self) -> Prefixes {
105+
Prefixes {
106+
components: self.path.components().to_owned(),
107+
remaining: ~[]
108+
}
109+
}
110+
111+
}
112+
113+
struct Prefixes {
114+
priv components: ~[~str],
115+
priv remaining: ~[~str]
116+
}
117+
118+
impl Iterator<(Path, Path)> for Prefixes {
119+
#[inline]
120+
fn next(&mut self) -> Option<(Path, Path)> {
121+
if self.components.len() <= 1 {
122+
None
123+
}
124+
else {
125+
let last = self.components.pop();
126+
self.remaining.push(last);
127+
// converting to str and then back is a little unfortunate
128+
Some((Path(self.components.to_str()), Path(self.remaining.to_str())))
129+
}
130+
}
103131
}
104132

105133
impl ToStr for PkgId {
@@ -119,3 +147,4 @@ pub fn hash(data: ~str) -> ~str {
119147
write(hasher, data);
120148
hasher.result_str()
121149
}
150+

branches/try2/src/librustpkg/package_source.rs

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,33 @@ impl PkgSrc {
7777
let dir: Path = match path {
7878
Some(d) => (*d).clone(),
7979
None => {
80+
// See if any of the prefixes of this package ID form a valid package ID
81+
// That is, is this a package ID that points into the middle of a workspace?
82+
for (prefix, suffix) in id.prefixes_iter() {
83+
let package_id = PkgId::new(prefix.to_str());
84+
let path = workspace.push("src").push_rel(&package_id.path);
85+
debug!("in loop: checking if %s is a directory", path.to_str());
86+
if os::path_is_dir(&path) {
87+
let ps = PkgSrc::new(workspace.clone(),
88+
use_rust_path_hack,
89+
PkgId::new(prefix.to_str()));
90+
debug!("pkgsrc: Returning [%s|%s|%s]", workspace.to_str(),
91+
ps.start_dir.push_rel(&suffix).to_str(), ps.id.to_str());
92+
93+
return PkgSrc {
94+
workspace: workspace,
95+
start_dir: ps.start_dir.push_rel(&suffix),
96+
id: ps.id,
97+
libs: ~[],
98+
mains: ~[],
99+
tests: ~[],
100+
benchs: ~[]
101+
}
102+
103+
};
104+
}
105+
106+
// Ok, no prefixes work, so try fetching from git
80107
let mut ok_d = None;
81108
for w in to_try.iter() {
82109
debug!("Calling fetch_git on %s", w.to_str());
@@ -93,16 +120,17 @@ impl PkgSrc {
93120
if use_rust_path_hack {
94121
match find_dir_using_rust_path_hack(&id) {
95122
Some(d) => d,
96-
None => cond.raise((id.clone(),
97-
~"supplied path for package dir does not \
98-
exist, and couldn't interpret it as a URL fragment"))
123+
None => {
124+
cond.raise((id.clone(),
125+
~"supplied path for package dir does not \
126+
exist, and couldn't interpret it as a URL fragment"))
127+
}
99128
}
100129
}
101130
else {
102131
cond.raise((id.clone(),
103-
~"supplied path for package dir does not \
104-
exist, and couldn't interpret it as a URL fragment"))
105-
132+
~"supplied path for package dir does not \
133+
exist, and couldn't interpret it as a URL fragment"))
106134
}
107135
}
108136
}
@@ -115,6 +143,9 @@ impl PkgSrc {
115143
non-directory"));
116144
}
117145

146+
debug!("pkgsrc: Returning {%s|%s|%s}", workspace.to_str(),
147+
dir.to_str(), id.to_str());
148+
118149
PkgSrc {
119150
workspace: workspace,
120151
start_dir: dir,

branches/try2/src/librustpkg/path_util.rs

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,16 @@ pub fn make_dir_rwx_recursive(p: &Path) -> bool { os::mkdir_recursive(p, U_RWX)
5151
/// True if there's a directory in <workspace> with
5252
/// pkgid's short name
5353
pub fn workspace_contains_package_id(pkgid: &PkgId, workspace: &Path) -> bool {
54-
debug!("Checking in src dir of %s for %s",
55-
workspace.to_str(), pkgid.to_str());
5654
workspace_contains_package_id_(pkgid, workspace, |p| { p.push("src") }).is_some()
5755
}
5856

5957
pub fn workspace_contains_package_id_(pkgid: &PkgId, workspace: &Path,
6058
// Returns the directory it was actually found in
6159
workspace_to_src_dir: &fn(&Path) -> Path) -> Option<Path> {
60+
if !os::path_is_dir(workspace) {
61+
return None;
62+
}
63+
6264
let src_dir = workspace_to_src_dir(workspace);
6365

6466
let mut found = None;
@@ -143,9 +145,17 @@ pub fn built_library_in_workspace(pkgid: &PkgId, workspace: &Path) -> Option<Pat
143145
}
144146

145147
/// Does the actual searching stuff
146-
pub fn installed_library_in_workspace(short_name: &str, workspace: &Path) -> Option<Path> {
148+
pub fn installed_library_in_workspace(pkg_path: &Path, workspace: &Path) -> Option<Path> {
147149
// This could break once we're handling multiple versions better -- I should add a test for it
148-
library_in_workspace(&Path(short_name), short_name, Install, workspace, "lib", &NoVersion)
150+
match pkg_path.filename() {
151+
None => None,
152+
Some(short_name) => library_in_workspace(pkg_path,
153+
short_name,
154+
Install,
155+
workspace,
156+
"lib",
157+
&NoVersion)
158+
}
149159
}
150160

151161
/// `workspace` is used to figure out the directory to search.
@@ -391,3 +401,12 @@ pub fn find_dir_using_rust_path_hack(p: &PkgId) -> Option<Path> {
391401
}
392402
None
393403
}
404+
405+
/// True if the user set RUST_PATH to something non-empty --
406+
/// as opposed to the default paths that rustpkg adds automatically
407+
pub fn user_set_rust_path() -> bool {
408+
match os::getenv("RUST_PATH") {
409+
None | Some(~"") => false,
410+
Some(_) => true
411+
}
412+
}

branches/try2/src/librustpkg/rustpkg.rs

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ use rustc::metadata::filesearch::rust_path;
3333
use extra::{getopts};
3434
use syntax::{ast, diagnostic};
3535
use util::*;
36-
use messages::*;
36+
use messages::{error, warn, note};
3737
use path_util::build_pkg_id_in_workspace;
3838
use path_util::{U_RWX, in_rust_path};
3939
use path_util::{built_executable_in_workspace, built_library_in_workspace, default_workspace};
@@ -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/search.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ use version::Version;
1515
/// return Some(p) (returns the first one of there are multiple matches.) Return
1616
/// None if there's no such path.
1717
/// FIXME #8711: This ignores the desired version.
18-
pub fn find_installed_library_in_rust_path(short_name: &str, _version: &Version) -> Option<Path> {
18+
pub fn find_installed_library_in_rust_path(pkg_path: &Path, _version: &Version) -> Option<Path> {
1919
let rp = rust_path();
20+
debug!("find_installed_library_in_rust_path: looking for path %s", pkg_path.to_str());
2021
for p in rp.iter() {
21-
match installed_library_in_workspace(short_name, p) {
22+
match installed_library_in_workspace(pkg_path, p) {
2223
Some(path) => return Some(path),
2324
None => ()
2425
}

0 commit comments

Comments
 (0)