Skip to content

Commit f9e6d2e

Browse files
committed
---
yaml --- r: 144503 b: refs/heads/try2 c: ed20425 h: refs/heads/master i: 144501: 5f52701 144499: 8d12e9d 144495: b986e49 v: v3
1 parent 671eb0b commit f9e6d2e

File tree

13 files changed

+112
-140
lines changed

13 files changed

+112
-140
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: f22b4b169854c8a4ba86c16ee43327d6bcf94562
8+
refs/heads/try2: ed204257a0c6abc8386879bb631471ec17d8a96a
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
branch = master
55
[submodule "src/libuv"]
66
path = src/libuv
7-
url = https://github.com/brson/libuv.git
7+
url = https://github.com/alexcrichton/libuv.git
88
branch = master

branches/try2/mk/rt.mk

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -163,34 +163,44 @@ LIBUV_DEPS := $$(wildcard \
163163
$$(S)src/libuv/*/*/*/*)
164164
endif
165165

166+
LIBUV_GYP := $$(S)src/libuv/build/gyp
167+
LIBUV_MAKEFILE := $$(S)src/libuv/out/Makefile
168+
LIBUV_NO_LOAD = run-benchmarks.target.mk run-tests.target.mk \
169+
uv_dtrace_header.target.mk uv_dtrace_provider.target.mk
170+
166171
# XXX: Shouldn't need platform-specific conditions here
167172
ifdef CFG_WINDOWSY_$(1)
168-
$$(LIBUV_LIB_$(1)_$(2)): $$(LIBUV_DEPS)
173+
$$(LIBUV_LIB_$(1)_$(2)): $$(LIBUV_DEPS) $$(LIBUV_MAKEFILE)
169174
$$(Q)$$(MAKE) -C $$(S)src/libuv/ \
170-
builddir_name="$$(CFG_BUILD_DIR)/rt/$(1)/stage$(2)/libuv" \
175+
builddir="$$(CFG_BUILD_DIR)/rt/$(1)/stage$(2)/libuv" \
171176
OS=mingw \
177+
BUILDTYPE=Release \
178+
NO_LOAD="$$(LIBUV_NO_LOAD)" \
172179
V=$$(VERBOSE)
173180
else ifeq ($(OSTYPE_$(1)), linux-androideabi)
174-
$$(LIBUV_LIB_$(1)_$(2)): $$(LIBUV_DEPS)
181+
$$(LIBUV_LIB_$(1)_$(2)): $$(LIBUV_DEPS) $$(LIBUV_MAKEFILE)
175182
$$(Q)$$(MAKE) -C $$(S)src/libuv/ \
176183
CFLAGS="$$(CFG_GCCISH_CFLAGS) $$(LIBUV_FLAGS_$$(HOST_$(1))) $$(SNAP_DEFINES)" \
177184
LDFLAGS="$$(CFG_GCCISH_LINK_FLAGS) $$(LIBUV_FLAGS_$$(HOST_$(1)))" \
178185
CC="$$(CC_$(1))" \
179186
CXX="$$(CXX_$(1))" \
180187
AR="$$(AR_$(1))" \
181-
BUILDTYPE=Release \
182-
builddir_name="$$(CFG_BUILD_DIR)/rt/$(1)/stage$(2)/libuv" \
188+
builddir="$$(CFG_BUILD_DIR)/rt/$(1)/stage$(2)/libuv" \
183189
host=android OS=linux \
190+
BUILDTYPE=Release \
191+
NO_LOAD="$$(LIBUV_NO_LOAD)" \
184192
V=$$(VERBOSE)
185193
else
186-
$$(LIBUV_LIB_$(1)_$(2)): $$(LIBUV_DEPS)
187-
$$(Q)$$(MAKE) -C $$(S)src/libuv/ \
194+
$$(LIBUV_LIB_$(1)_$(2)): $$(LIBUV_DEPS) $$(LIBUV_MAKEFILE)
195+
$$(Q)$$(MAKE) -C $$(S)src/libuv/out \
188196
CFLAGS="$$(CFG_GCCISH_CFLAGS) $$(LIBUV_FLAGS_$$(HOST_$(1))) $$(SNAP_DEFINES)" \
189197
LDFLAGS="$$(CFG_GCCISH_LINK_FLAGS) $$(LIBUV_FLAGS_$$(HOST_$(1)))" \
190198
CC="$$(CC_$(1))" \
191199
CXX="$$(CXX_$(1))" \
192200
AR="$$(AR_$(1))" \
193-
builddir_name="$$(CFG_BUILD_DIR)/rt/$(1)/stage$(2)/libuv" \
201+
builddir="$$(CFG_BUILD_DIR)/rt/$(1)/stage$(2)/libuv" \
202+
BUILDTYPE=Release \
203+
NO_LOAD="$$(LIBUV_NO_LOAD)" \
194204
V=$$(VERBOSE)
195205
endif
196206

@@ -250,6 +260,13 @@ endif
250260

251261
endef
252262

263+
$(LIBUV_GYP):
264+
mkdir -p $(S)src/libuv/build
265+
git clone https://git.chromium.org/external/gyp.git $(S)src/libuv/build/gyp
266+
267+
$(LIBUV_MAKEFILE): $(LIBUV_GYP)
268+
(cd $(S)src/libuv/ && ./gyp_uv -f make)
269+
253270
# Instantiate template for all stages
254271
$(foreach stage,$(STAGES), \
255272
$(foreach target,$(CFG_TARGET_TRIPLES), \

branches/try2/src/librustpkg/rustpkg.rs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ use path_util::{U_RWX, in_rust_path};
4343
use path_util::{built_executable_in_workspace, built_library_in_workspace, default_workspace};
4444
use path_util::{target_executable_in_workspace, target_library_in_workspace};
4545
use source_control::is_git_dir;
46-
use workspace::{each_pkg_parent_workspace, pkg_parent_workspaces, cwd_to_workspace};
46+
use workspace::{each_pkg_parent_workspace, pkg_parent_workspaces, in_workspace, cwd_to_workspace};
4747
use context::Ctx;
4848
use package_id::PkgId;
4949
use package_source::PkgSrc;
@@ -190,10 +190,11 @@ impl CtxMethods for Ctx {
190190
match cmd {
191191
"build" => {
192192
if args.len() < 1 {
193-
match cwd_to_workspace() {
194-
None => { usage::build(); return }
195-
Some((ws, pkgid)) => self.build(&ws, &pkgid)
193+
if !in_workspace(|| { usage::build() } ) {
194+
return;
196195
}
196+
let (workspace, pkgid) = cwd_to_workspace();
197+
self.build(&workspace, &pkgid);
197198
}
198199
else {
199200
// The package id is presumed to be the first command-line
@@ -209,12 +210,13 @@ impl CtxMethods for Ctx {
209210
}
210211
"clean" => {
211212
if args.len() < 1 {
212-
match cwd_to_workspace() {
213-
None => { usage::clean(); return }
214-
// tjc: Maybe clean should clean all the packages in the
215-
// current workspace, though?
216-
Some((ws, pkgid)) => self.clean(&ws, &pkgid)
213+
if !in_workspace(|| { usage::clean() } ) {
214+
return;
217215
}
216+
// tjc: Maybe clean should clean all the packages in the
217+
// current workspace, though?
218+
let (workspace, pkgid) = cwd_to_workspace();
219+
self.clean(&workspace, &pkgid);
218220

219221
}
220222
else {
@@ -237,10 +239,11 @@ impl CtxMethods for Ctx {
237239
}
238240
"install" => {
239241
if args.len() < 1 {
240-
match cwd_to_workspace() {
241-
None => { usage::install(); return }
242-
Some((ws, pkgid)) => self.install(&ws, &pkgid)
242+
if !in_workspace(|| { usage::install() }) {
243+
return;
243244
}
245+
let (workspace, pkgid) = cwd_to_workspace();
246+
self.install(&workspace, &pkgid);
244247
}
245248
else {
246249
// The package id is presumed to be the first command-line

branches/try2/src/librustpkg/tests.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -695,8 +695,7 @@ fn package_script_with_default_build() {
695695
696696
#[test]
697697
fn rustpkg_build_no_arg() {
698-
let tmp = mkdtemp(&os::tmpdir(), "rustpkg_build_no_arg").expect("rustpkg_build_no_arg failed")
699-
.push(".rust");
698+
let tmp = mkdtemp(&os::tmpdir(), "rustpkg_build_no_arg").expect("rustpkg_build_no_arg failed");
700699
let package_dir = tmp.push("src").push("foo");
701700
assert!(os::mkdir_recursive(&package_dir, U_RWX));
702701
@@ -710,8 +709,7 @@ fn rustpkg_build_no_arg() {
710709
#[test]
711710
fn rustpkg_install_no_arg() {
712711
let tmp = mkdtemp(&os::tmpdir(),
713-
"rustpkg_install_no_arg").expect("rustpkg_install_no_arg failed")
714-
.push(".rust");
712+
"rustpkg_install_no_arg").expect("rustpkg_install_no_arg failed");
715713
let package_dir = tmp.push("src").push("foo");
716714
assert!(os::mkdir_recursive(&package_dir, U_RWX));
717715
writeFile(&package_dir.push("lib.rs"),
@@ -723,8 +721,7 @@ fn rustpkg_install_no_arg() {
723721
724722
#[test]
725723
fn rustpkg_clean_no_arg() {
726-
let tmp = mkdtemp(&os::tmpdir(), "rustpkg_clean_no_arg").expect("rustpkg_clean_no_arg failed")
727-
.push(".rust");
724+
let tmp = mkdtemp(&os::tmpdir(), "rustpkg_clean_no_arg").expect("rustpkg_clean_no_arg failed");
728725
let package_dir = tmp.push("src").push("foo");
729726
assert!(os::mkdir_recursive(&package_dir, U_RWX));
730727

branches/try2/src/librustpkg/workspace.rs

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

1111
// rustpkg utilities having to do with workspaces
1212

13-
use std::{os,util};
13+
use std::os;
1414
use std::path::Path;
1515
use path_util::workspace_contains_package_id;
1616
use package_id::PkgId;
1717

18-
use path_util::rust_path;
18+
use rustc::metadata::filesearch::rust_path;
1919

2020
pub fn each_pkg_parent_workspace(pkgid: &PkgId, action: &fn(&Path) -> bool) -> bool {
2121
// Using the RUST_PATH, find workspaces that contain
@@ -42,22 +42,23 @@ pub fn pkg_parent_workspaces(pkgid: &PkgId) -> ~[Path] {
4242
.collect()
4343
}
4444

45+
pub fn in_workspace(complain: &fn()) -> bool {
46+
let dir_part = os::getcwd().pop().components.clone();
47+
if *(dir_part.last()) != ~"src" {
48+
complain();
49+
false
50+
}
51+
else {
52+
true
53+
}
54+
}
55+
4556
/// Construct a workspace and package-ID name based on the current directory.
4657
/// This gets used when rustpkg gets invoked without a package-ID argument.
47-
pub fn cwd_to_workspace() -> Option<(Path, PkgId)> {
58+
pub fn cwd_to_workspace() -> (Path, PkgId) {
4859
let cwd = os::getcwd();
49-
for path in rust_path().move_iter() {
50-
let srcpath = path.push("src");
51-
if srcpath.is_ancestor_of(&cwd) {
52-
// I'd love to use srcpath.get_relative_to(cwd) but it behaves wrong
53-
// I'd say broken, but it has tests enforcing the wrong behavior.
54-
// instead, just hack up the components vec
55-
let mut pkgid = cwd;
56-
pkgid.is_absolute = false;
57-
let comps = util::replace(&mut pkgid.components, ~[]);
58-
pkgid.components = comps.move_iter().skip(srcpath.components.len()).collect();
59-
return Some((path, PkgId::new(pkgid.components.connect("/"))))
60-
}
61-
}
62-
None
60+
let ws = cwd.pop().pop();
61+
let cwd_ = cwd.clone();
62+
let pkgid = cwd_.components.last().to_str();
63+
(ws, PkgId::new(pkgid))
6364
}

branches/try2/src/libstd/rt/io/net/tcp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ mod test {
166166
do run_in_newsched_task {
167167
let mut called = false;
168168
do io_error::cond.trap(|e| {
169-
assert!(e.kind == ConnectionRefused);
169+
assert_eq!(e.kind, ConnectionRefused);
170170
called = true;
171171
}).inside {
172172
let addr = SocketAddr { ip: Ipv4Addr(0, 0, 0, 0), port: 1 };

branches/try2/src/libstd/rt/uv/mod.rs

Lines changed: 14 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,12 @@ impl<H, W: Watcher + NativeHandle<*H>> WatcherInterop for W {
202202
// XXX: Need to define the error constants like EOF so they can be
203203
// compared to the UvError type
204204

205-
pub struct UvError(uvll::uv_err_t);
205+
pub struct UvError(c_int);
206206

207207
impl UvError {
208208
pub fn name(&self) -> ~str {
209209
unsafe {
210-
let inner = match self { &UvError(ref a) => a };
210+
let inner = match self { &UvError(a) => a };
211211
let name_str = uvll::err_name(inner);
212212
assert!(name_str.is_not_null());
213213
from_c_str(name_str)
@@ -216,15 +216,15 @@ impl UvError {
216216

217217
pub fn desc(&self) -> ~str {
218218
unsafe {
219-
let inner = match self { &UvError(ref a) => a };
219+
let inner = match self { &UvError(a) => a };
220220
let desc_str = uvll::strerror(inner);
221221
assert!(desc_str.is_not_null());
222222
from_c_str(desc_str)
223223
}
224224
}
225225

226226
pub fn is_eof(&self) -> bool {
227-
self.code == uvll::EOF
227+
**self == uvll::EOF
228228
}
229229
}
230230

@@ -236,38 +236,30 @@ impl ToStr for UvError {
236236

237237
#[test]
238238
fn error_smoke_test() {
239-
let err = uvll::uv_err_t { code: 1, sys_errno_: 1 };
240-
let err: UvError = UvError(err);
239+
let err: UvError = UvError(uvll::EOF);
241240
assert_eq!(err.to_str(), ~"EOF: end of file");
242241
}
243242
244-
pub fn last_uv_error<H, W: Watcher + NativeHandle<*H>>(watcher: &W) -> UvError {
245-
unsafe {
246-
let loop_ = watcher.event_loop();
247-
UvError(uvll::last_error(loop_.native_handle()))
248-
}
249-
}
250-
251243
pub fn uv_error_to_io_error(uverr: UvError) -> IoError {
252244
unsafe {
253245
// Importing error constants
254246
use rt::uv::uvll::*;
255247
use rt::io::*;
256248
257249
// uv error descriptions are static
258-
let c_desc = uvll::strerror(&*uverr);
250+
let c_desc = uvll::strerror(*uverr);
259251
let desc = str::raw::c_str_to_static_slice(c_desc);
260252
261-
let kind = match uverr.code {
253+
let kind = match *uverr {
262254
UNKNOWN => OtherIoError,
263255
OK => OtherIoError,
264256
EOF => EndOfFile,
265257
EACCES => PermissionDenied,
266258
ECONNREFUSED => ConnectionRefused,
267259
ECONNRESET => ConnectionReset,
268260
EPIPE => BrokenPipe,
269-
_ => {
270-
rtdebug!("uverr.code %u", uverr.code as uint);
261+
err => {
262+
rtdebug!("uverr.code %d", err as int);
271263
// XXX: Need to map remaining uv error types
272264
OtherIoError
273265
}
@@ -282,30 +274,13 @@ pub fn uv_error_to_io_error(uverr: UvError) -> IoError {
282274
}
283275
284276
/// Given a uv handle, convert a callback status to a UvError
285-
pub fn status_to_maybe_uv_error_with_loop(
286-
loop_: *uvll::uv_loop_t,
287-
status: c_int) -> Option<UvError> {
288-
if status != -1 {
277+
pub fn status_to_maybe_uv_error<T, U: Watcher + NativeHandle<*T>>(
278+
handle: U, status: c_int) -> Option<UvError>
279+
{
280+
if status >= 0 {
289281
None
290282
} else {
291-
unsafe {
292-
rtdebug!("loop: %x", loop_ as uint);
293-
let err = uvll::last_error(loop_);
294-
Some(UvError(err))
295-
}
296-
}
297-
}
298-
/// Given a uv handle, convert a callback status to a UvError
299-
pub fn status_to_maybe_uv_error<T, U: Watcher + NativeHandle<*T>>(handle: U,
300-
status: c_int) -> Option<UvError> {
301-
if status != -1 {
302-
None
303-
} else {
304-
unsafe {
305-
rtdebug!("handle: %x", handle.native_handle() as uint);
306-
let loop_ = uvll::get_loop_for_uv_handle(handle.native_handle());
307-
status_to_maybe_uv_error_with_loop(loop_, status)
308-
}
283+
Some(UvError(status))
309284
}
310285
}
311286

branches/try2/src/libstd/rt/uv/net.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use rt::uv::{AllocCallback, ConnectionCallback, ReadCallback, UdpReceiveCallback
1616
use rt::uv::{Loop, Watcher, Request, UvError, Buf, NativeHandle, NullCallback,
1717
status_to_maybe_uv_error};
1818
use rt::io::net::ip::{SocketAddr, Ipv4Addr, Ipv6Addr};
19-
use rt::uv::last_uv_error;
2019
use vec;
2120
use str;
2221
use from_str::{FromStr};
@@ -232,7 +231,7 @@ impl TcpWatcher {
232231
};
233232
match result {
234233
0 => Ok(()),
235-
_ => Err(last_uv_error(self)),
234+
_ => Err(UvError(result)),
236235
}
237236
}
238237
}
@@ -327,7 +326,7 @@ impl UdpWatcher {
327326
};
328327
match result {
329328
0 => Ok(()),
330-
_ => Err(last_uv_error(self)),
329+
_ => Err(UvError(result)),
331330
}
332331
}
333332
}

0 commit comments

Comments
 (0)