Skip to content

Commit 758366f

Browse files
committed
---
yaml --- r: 144591 b: refs/heads/try2 c: 91d6c60 h: refs/heads/master i: 144589: 2e9f552 144587: d3d9629 144583: f932257 144575: 2d1f308 v: v3
1 parent fa42c3d commit 758366f

26 files changed

+116
-537
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: 8002a09bf915bd186e4e455b25265b4160bfd125
8+
refs/heads/try2: 91d6c60bed2c5d574ca524ab4812f731118cd22d
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ fn check_impl_of_trait(cx: Context, it: @item, trait_ref: &trait_ref, self_type:
129129

130130
// If this trait has builtin-kind supertraits, meet them.
131131
let self_ty: ty::t = ty::node_id_to_type(cx.tcx, it.id);
132-
debug!("checking impl with self type %?", ty::get(self_ty).sty);
132+
error!("checking impl with self type %?", ty::get(self_ty).sty);
133133
do check_builtin_bounds(cx, self_ty, trait_def.bounds) |missing| {
134134
cx.tcx.sess.span_err(self_type.span,
135135
fmt!("the type `%s', which does not fulfill `%s`, cannot implement this \

branches/try2/src/librustpkg/api.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,7 @@ use std::hashmap::*;
2020
/// Convenience functions intended for calling from pkg.rs
2121
2222
fn default_ctxt(p: @Path) -> Ctx {
23-
Ctx {
24-
use_rust_path_hack: false,
25-
sysroot_opt: Some(p),
26-
json: false,
27-
dep_cache: @mut HashMap::new()
28-
}
23+
Ctx { sysroot_opt: Some(p), json: false, dep_cache: @mut HashMap::new() }
2924
}
3025

3126
pub fn build_lib(sysroot: @Path, root: Path, name: ~str, version: Version,

branches/try2/src/librustpkg/conditions.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,3 @@ condition! {
3636
condition! {
3737
no_rust_path: (~str) -> super::Path;
3838
}
39-
40-
condition! {
41-
not_a_workspace: (~str) -> super::Path;
42-
}
43-
44-
condition! {
45-
failed_to_create_temp_dir: (~str) -> super::Path;
46-
}

branches/try2/src/librustpkg/context.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,6 @@ use std::hashmap::HashMap;
1515
use std::os;
1616

1717
pub struct Ctx {
18-
// If use_rust_path_hack is true, rustpkg searches for sources
19-
// in *package* directories that are in the RUST_PATH (for example,
20-
// FOO/src/bar-0.1 instead of FOO). The flag doesn't affect where
21-
// rustpkg stores build artifacts.
22-
use_rust_path_hack: bool,
2318
// Sysroot -- if this is None, uses rustc filesearch's
2419
// idea of the default
2520
sysroot_opt: Option<@Path>,

branches/try2/src/librustpkg/package_source.rs

Lines changed: 22 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
extern mod extra;
12-
1311
use target::*;
1412
use package_id::PkgId;
1513
use std::path::Path;
@@ -18,9 +16,8 @@ use context::*;
1816
use crate::Crate;
1917
use messages::*;
2018
use source_control::{git_clone, git_clone_general};
21-
use path_util::{pkgid_src_in_workspace, find_dir_using_rust_path_hack, default_workspace};
19+
use path_util::pkgid_src_in_workspace;
2220
use util::compile_crate;
23-
use workspace::is_workspace;
2421

2522
// An enumeration of the unpacked source of a package workspace.
2623
// This contains a list of files found in the source workspace.
@@ -51,7 +48,7 @@ impl PkgSrc {
5148
}
5249

5350

54-
fn check_dir(&self, cx: &Ctx) -> Path {
51+
fn check_dir(&self) -> Path {
5552
use conditions::nonexistent_package::cond;
5653

5754
debug!("Pushing onto root: %s | %s", self.id.path.to_str(), self.root.to_str());
@@ -62,21 +59,12 @@ impl PkgSrc {
6259

6360
let dir = match path {
6461
Some(d) => (*d).clone(),
65-
None => {
66-
match self.fetch_git() {
67-
Some(d) => d,
68-
None => {
69-
match find_dir_using_rust_path_hack(cx, &self.id) {
70-
Some(d) => d,
71-
None => cond.raise((self.id.clone(),
72-
~"supplied path for package dir does not \
73-
exist, and couldn't interpret it as a URL fragment"))
74-
}
75-
}
76-
}
62+
None => match self.fetch_git() {
63+
Some(d) => d,
64+
None => cond.raise((self.id.clone(), ~"supplied path for package dir does not \
65+
exist, and couldn't interpret it as a URL fragment"))
7766
}
7867
};
79-
debug!("For package id %s, returning %s", self.id.to_str(), dir.to_str());
8068
if !os::path_is_dir(&dir) {
8169
cond.raise((self.id.clone(), ~"supplied path for package dir is a \
8270
non-directory"));
@@ -91,19 +79,11 @@ impl PkgSrc {
9179
/// refers to a git repo on the local version, also check it out.
9280
/// (right now we only support git)
9381
pub fn fetch_git(&self) -> Option<Path> {
94-
use conditions::failed_to_create_temp_dir::cond;
95-
96-
// We use a temporary directory because if the git clone fails,
97-
// it creates the target directory anyway and doesn't delete it
98-
99-
let scratch_dir = extra::tempfile::mkdtemp(&os::tmpdir(), "rustpkg");
100-
let clone_target = match scratch_dir {
101-
Some(d) => d.push("rustpkg_temp"),
102-
None => cond.raise(~"Failed to create temporary directory for fetching git sources")
103-
};
10482

10583
let mut local = self.root.push("src");
10684
local = local.push(self.id.to_str());
85+
// Git can't clone into a non-empty directory
86+
os::remove_dir_recursive(&local);
10787

10888
debug!("Checking whether %s exists locally. Cwd = %s, does it? %?",
10989
self.id.path.to_str(),
@@ -113,28 +93,15 @@ impl PkgSrc {
11393
if os::path_exists(&self.id.path) {
11494
debug!("%s exists locally! Cloning it into %s",
11595
self.id.path.to_str(), local.to_str());
116-
// Ok to use local here; we know it will succeed
11796
git_clone(&self.id.path, &local, &self.id.version);
11897
return Some(local);
11998
}
12099

121-
if (self.id.path.clone()).components().len() < 2 {
122-
// If a non-URL, don't bother trying to fetch
123-
return None;
124-
}
125-
126100
let url = fmt!("https://%s", self.id.path.to_str());
127101
note(fmt!("Fetching package: git clone %s %s [version=%s]",
128-
url, clone_target.to_str(), self.id.version.to_str()));
129-
130-
if git_clone_general(url, &clone_target, &self.id.version) {
131-
// since the operation succeeded, move clone_target to local
132-
if !os::rename_file(&clone_target, &local) {
133-
None
134-
}
135-
else {
136-
Some(local)
137-
}
102+
url, local.to_str(), self.id.version.to_str()));
103+
if git_clone_general(url, &local, &self.id.version) {
104+
Some(local)
138105
}
139106
else {
140107
None
@@ -171,10 +138,10 @@ impl PkgSrc {
171138

172139
/// Infers crates to build. Called only in the case where there
173140
/// is no custom build logic
174-
pub fn find_crates(&mut self, cx: &Ctx) {
141+
pub fn find_crates(&mut self) {
175142
use conditions::missing_pkg_files::cond;
176143

177-
let dir = self.check_dir(cx);
144+
let dir = self.check_dir();
178145
debug!("Called check_dir, I'm in %s", dir.to_str());
179146
let prefix = dir.components.len();
180147
debug!("Matching against %?", self.id.short_name);
@@ -216,7 +183,6 @@ impl PkgSrc {
216183
fn build_crates(&self,
217184
ctx: &Ctx,
218185
src_dir: &Path,
219-
destination_dir: &Path,
220186
crates: &[Crate],
221187
cfgs: &[~str],
222188
what: OutputType) {
@@ -228,8 +194,8 @@ impl PkgSrc {
228194
let result = compile_crate(ctx,
229195
&self.id,
230196
path,
231-
// compile_crate wants the destination workspace
232-
destination_dir,
197+
// compile_crate wants the workspace
198+
&self.root,
233199
crate.flags,
234200
crate.cfgs + cfgs,
235201
false,
@@ -243,39 +209,15 @@ impl PkgSrc {
243209
}
244210
}
245211

246-
pub fn build(&self, ctx: &Ctx, cfgs: ~[~str]) -> Path {
247-
use conditions::not_a_workspace::cond;
248-
249-
// Determine the destination workspace (which depends on whether
250-
// we're using the rust_path_hack)
251-
let destination_workspace = if is_workspace(&self.root) {
252-
debug!("%s is indeed a workspace", self.root.to_str());
253-
self.root.clone()
254-
}
255-
else {
256-
// It would be nice to have only one place in the code that checks
257-
// for the use_rust_path_hack flag...
258-
if ctx.use_rust_path_hack {
259-
let rs = default_workspace();
260-
debug!("Using hack: %s", rs.to_str());
261-
rs
262-
}
263-
else {
264-
cond.raise(fmt!("Package root %s is not a workspace; pass in --rust_path_hack \
265-
if you want to treat it as a package source", self.root.to_str()))
266-
}
267-
};
268-
269-
let dir = self.check_dir(ctx);
270-
debug!("Building libs in %s, destination = %s", dir.to_str(),
271-
destination_workspace.to_str());
272-
self.build_crates(ctx, &dir, &destination_workspace, self.libs, cfgs, Lib);
212+
pub fn build(&self, ctx: &Ctx, cfgs: ~[~str]) {
213+
let dir = self.check_dir();
214+
debug!("Building libs in %s", dir.to_str());
215+
self.build_crates(ctx, &dir, self.libs, cfgs, Lib);
273216
debug!("Building mains");
274-
self.build_crates(ctx, &dir, &destination_workspace, self.mains, cfgs, Main);
217+
self.build_crates(ctx, &dir, self.mains, cfgs, Main);
275218
debug!("Building tests");
276-
self.build_crates(ctx, &dir, &destination_workspace, self.tests, cfgs, Test);
219+
self.build_crates(ctx, &dir, self.tests, cfgs, Test);
277220
debug!("Building benches");
278-
self.build_crates(ctx, &dir, &destination_workspace, self.benchs, cfgs, Bench);
279-
destination_workspace
221+
self.build_crates(ctx, &dir, self.benchs, cfgs, Bench);
280222
}
281223
}

branches/try2/src/librustpkg/path_util.rs

Lines changed: 14 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ pub use package_id::PkgId;
1414
pub use target::{OutputType, Main, Lib, Test, Bench, Target, Build, Install};
1515
pub use version::{Version, NoVersion, split_version_general, try_parsing_version};
1616
pub use rustc::metadata::filesearch::rust_path;
17-
use context::Ctx;
1817

1918
use std::libc::consts::os::posix88::{S_IRUSR, S_IWUSR, S_IXUSR};
2019
use std::os::mkdir_recursive;
@@ -52,23 +51,18 @@ pub fn make_dir_rwx(p: &Path) -> bool { os::make_dir(p, U_RWX) }
5251
pub fn workspace_contains_package_id(pkgid: &PkgId, workspace: &Path) -> bool {
5352
debug!("Checking in src dir of %s for %s",
5453
workspace.to_str(), pkgid.to_str());
55-
workspace_contains_package_id_(pkgid, workspace, |p| { p.push("src") }).is_some()
56-
}
5754

58-
pub fn workspace_contains_package_id_(pkgid: &PkgId, workspace: &Path,
59-
// Returns the directory it was actually found in
60-
workspace_to_src_dir: &fn(&Path) -> Path) -> Option<Path> {
61-
let src_dir = workspace_to_src_dir(workspace);
55+
let src_dir = workspace.push("src");
6256

63-
let mut found = None;
57+
let mut found = false;
6458
do os::walk_dir(&src_dir) |p| {
6559
debug!("=> p = %s", p.to_str());
6660

67-
if os::path_is_dir(p) {
61+
let was_found = os::path_is_dir(p) && {
6862
debug!("p = %s, path = %s [%s]", p.to_str(), pkgid.path.to_str(),
6963
src_dir.push_rel(&pkgid.path).to_str());
7064

71-
if *p == src_dir.push_rel(&pkgid.path) || {
65+
*p == src_dir.push_rel(&pkgid.path) || {
7266
let pf = p.filename();
7367
do pf.iter().any |pf| {
7468
let g = pf.to_str();
@@ -82,15 +76,16 @@ pub fn workspace_contains_package_id_(pkgid: &PkgId, workspace: &Path,
8276
}
8377
}
8478
}
85-
} {
86-
found = Some(p.clone());
8779
}
88-
8980
};
81+
82+
if was_found {
83+
found = true
84+
}
9085
true
9186
};
9287

93-
debug!(if found.is_some() { fmt!("Found %s in %s", pkgid.to_str(), workspace.to_str()) }
88+
debug!(if found { fmt!("Found %s in %s", pkgid.to_str(), workspace.to_str()) }
9489
else { fmt!("Didn't find %s in %s", pkgid.to_str(), workspace.to_str()) });
9590
found
9691
}
@@ -128,7 +123,8 @@ pub fn built_executable_in_workspace(pkgid: &PkgId, workspace: &Path) -> Option<
128123
Some(result)
129124
}
130125
else {
131-
debug!("built_executable_in_workspace: %s does not exist", result.to_str());
126+
// This is not an error, but it's worth logging it
127+
error!(fmt!("built_executable_in_workspace: %s does not exist", result.to_str()));
132128
None
133129
}
134130
}
@@ -168,7 +164,7 @@ pub fn built_library_in_workspace(pkgid: &PkgId, workspace: &Path) -> Option<Pat
168164

169165
/// Does the actual searching stuff
170166
pub fn installed_library_in_workspace(short_name: &str, workspace: &Path) -> Option<Path> {
171-
// This could break once we're handling multiple versions better -- I should add a test for it
167+
// NOTE: this could break once we're handling multiple versions better... want a test for it
172168
library_in_workspace(&Path(short_name), short_name, Install, workspace, "lib", &NoVersion)
173169
}
174170

@@ -250,8 +246,8 @@ pub fn library_in_workspace(path: &Path, short_name: &str, where: Target,
250246
} // for
251247

252248
if result_filename.is_none() {
253-
debug!("warning: library_in_workspace didn't find a library in %s for %s",
254-
dir_to_search.to_str(), short_name);
249+
warn(fmt!("library_in_workspace didn't find a library in %s for %s",
250+
dir_to_search.to_str(), short_name));
255251
}
256252

257253
// Return the filename that matches, which we now know exists
@@ -396,25 +392,3 @@ pub fn uninstall_package_from(workspace: &Path, pkgid: &PkgId) {
396392
}
397393

398394
}
399-
400-
fn dir_has_file(dir: &Path, file: &str) -> bool {
401-
assert!(dir.is_absolute());
402-
os::path_exists(&dir.push(file))
403-
}
404-
405-
pub fn find_dir_using_rust_path_hack(cx: &Ctx, p: &PkgId) -> Option<Path> {
406-
if !cx.use_rust_path_hack {
407-
return None;
408-
}
409-
let rp = rust_path();
410-
for dir in rp.iter() {
411-
debug!("In find_dir_using_rust_path_hack: checking dir %s", dir.to_str());
412-
if dir_has_file(dir, "lib.rs") || dir_has_file(dir, "main.rs")
413-
|| dir_has_file(dir, "test.rs") || dir_has_file(dir, "bench.rs") {
414-
debug!("Did find id %s in dir %s", p.to_str(), dir.to_str());
415-
return Some(dir.clone());
416-
}
417-
debug!("Didn't find id %s in dir %s", p.to_str(), dir.to_str())
418-
}
419-
None
420-
}

0 commit comments

Comments
 (0)