Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
a6c04eab
R
Rust
项目概览
int
/
Rust
大约 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a6c04eab
编写于
1月 18, 2012
作者:
G
Graydon Hoare
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1562 from elly/cargo
[cargo] add --test flag to install
上级
6a6aec04
ad0065fe
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
48 addition
and
15 deletion
+48
-15
src/cargo/cargo.rs
src/cargo/cargo.rs
+48
-15
未找到文件。
src/cargo/cargo.rs
浏览文件 @
a6c04eab
...
...
@@ -54,7 +54,8 @@
libdir
:
str
,
workdir
:
str
,
sourcedir
:
str
,
sources
:
map
::
hashmap
<
str
,
source
>
sources
:
map
::
hashmap
<
str
,
source
>
,
mutable
test
:
bool
};
type
pkg
=
{
...
...
@@ -67,7 +68,7 @@
};
fn
info
(
msg
:
str
)
{
io
::
stdout
()
.write_line
(
msg
);
io
::
stdout
()
.write_line
(
"info: "
+
msg
);
}
fn
warn
(
msg
:
str
)
{
...
...
@@ -323,7 +324,8 @@ fn configure() -> cargo {
libdir
:
fs
::
connect
(
p
,
"lib"
),
workdir
:
fs
::
connect
(
p
,
"work"
),
sourcedir
:
fs
::
connect
(
p
,
"sources"
),
sources
:
sources
sources
:
sources
,
mutable
test
:
false
};
need_dir
(
c
.root
);
...
...
@@ -353,7 +355,8 @@ fn for_each_package(c: cargo, b: block(source, package)) {
})
}
fn
install_one_crate
(
c
:
cargo
,
_
path
:
str
,
cf
:
str
,
_
p
:
pkg
)
{
// FIXME: deduplicate code with install_one_crate
fn
test_one_crate
(
c
:
cargo
,
_
path
:
str
,
cf
:
str
,
_
p
:
pkg
)
{
let
name
=
fs
::
basename
(
cf
);
let
ri
=
str
::
index
(
name
,
'.'
as
u8
);
if
ri
!=
-
1
{
...
...
@@ -361,7 +364,7 @@ fn install_one_crate(c: cargo, _path: str, cf: str, _p: pkg) {
}
#
debug
(
"Installing: %s"
,
name
);
let
old
=
fs
::
list_dir
(
"."
);
let
p
=
run
::
program_output
(
"rustc"
,
[
name
+
".rc"
]);
let
p
=
run
::
program_output
(
"rustc"
,
[
"--test"
,
name
+
".rc"
]);
if
p
.status
!=
0
{
error
(
#
fmt
[
"rustc failed: %d
\n
%s
\n
%s"
,
p
.status
,
p
.err
,
p
.out
]);
ret
;
...
...
@@ -371,6 +374,26 @@ fn install_one_crate(c: cargo, _path: str, cf: str, _p: pkg) {
vec
::
filter
::
<
str
>
(
new
,
{
|
n
|
!
vec
::
member
::
<
str
>
(
n
,
old
)
});
let
exec_suffix
=
os
::
exec_suffix
();
for
ct
:
str
in
created
{
if
(
exec_suffix
!=
""
&&
str
::
ends_with
(
ct
,
exec_suffix
))
||
(
exec_suffix
==
""
&&
!
str
::
starts_with
(
ct
,
"./lib"
))
{
// FIXME: need libstd fs::copy or something
run
::
run_program
(
ct
,
[]);
}
}
}
fn
install_one_crate
(
c
:
cargo
,
_
path
:
str
,
cf
:
str
,
_
p
:
pkg
)
{
let
buildpath
=
fs
::
connect
(
_
path
,
"/build"
);
need_dir
(
buildpath
);
#
debug
(
"Installing: %s -> %s"
,
cf
,
buildpath
);
let
p
=
run
::
program_output
(
"rustc"
,
[
"--out-dir"
,
buildpath
,
cf
]);
if
p
.status
!=
0
{
error
(
#
fmt
[
"rustc failed: %d
\n
%s
\n
%s"
,
p
.status
,
p
.err
,
p
.out
]);
ret
;
}
let
new
=
fs
::
list_dir
(
buildpath
);
let
exec_suffix
=
os
::
exec_suffix
();
for
ct
:
str
in
new
{
if
(
exec_suffix
!=
""
&&
str
::
ends_with
(
ct
,
exec_suffix
))
||
(
exec_suffix
==
""
&&
!
str
::
starts_with
(
ct
,
"./lib"
))
{
#
debug
(
" bin: %s"
,
ct
);
...
...
@@ -402,6 +425,9 @@ fn install_source(c: cargo, path: str) {
alt
p
{
none
.
{
cont
;
}
some
(
_
p
)
{
if
c
.test
{
test_one_crate
(
c
,
path
,
cf
,
_
p
);
}
install_one_crate
(
c
,
path
,
cf
,
_
p
);
}
}
...
...
@@ -530,13 +556,20 @@ fn cmd_install(c: cargo, argv: [str]) {
ret
;
}
let
target
=
argv
[
2
];
// TODO: getopts
if
vec
::
len
(
argv
)
>
3u
&&
argv
[
2
]
==
"--test"
{
c
.test
=
true
;
target
=
argv
[
3
];
}
let
wd
=
alt
tempfile
::
mkdtemp
(
c
.workdir
+
fs
::
path_sep
(),
""
)
{
some
(
_
wd
)
{
_
wd
}
none
.
{
fail
"needed temp dir"
;
}
};
if
str
::
starts_with
(
argv
[
2
]
,
"uuid:"
)
{
let
uuid
=
rest
(
argv
[
2
]
,
5u
);
if
str
::
starts_with
(
target
,
"uuid:"
)
{
let
uuid
=
rest
(
target
,
5u
);
let
idx
=
str
::
index
(
uuid
,
'/'
as
u8
);
if
idx
!=
-
1
{
let
source
=
str
::
slice
(
uuid
,
0u
,
idx
as
uint
);
...
...
@@ -546,7 +579,7 @@ fn cmd_install(c: cargo, argv: [str]) {
install_uuid
(
c
,
wd
,
uuid
);
}
}
else
{
let
name
=
argv
[
2
]
;
let
name
=
target
;
let
idx
=
str
::
index
(
name
,
'/'
as
u8
);
if
idx
!=
-
1
{
let
source
=
str
::
slice
(
name
,
0u
,
idx
as
uint
);
...
...
@@ -686,13 +719,13 @@ fn cmd_search(c: cargo, argv: [str]) {
fn
cmd_usage
()
{
print
(
"Usage: cargo <verb> [args...]"
);
print
(
" init Fetch default sources"
);
print
(
" install [source/]package-name Install by name"
);
print
(
" install uuid:[source/]package-uuid Install by uuid"
);
print
(
" list [source] List packages"
);
print
(
" search <name | '*'> [tags...] Search packages"
);
print
(
" sync Sync all sources"
);
print
(
" usage This"
);
print
(
" init
Fetch default sources"
);
print
(
" install [
--test] [
source/]package-name Install by name"
);
print
(
" install
[--test]
uuid:[source/]package-uuid Install by uuid"
);
print
(
" list [source]
List packages"
);
print
(
" search <name | '*'> [tags...]
Search packages"
);
print
(
" sync
Sync all sources"
);
print
(
" usage
This"
);
}
fn
main
(
argv
:
[
str
])
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录