Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
77df8b80
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,发现更多精彩内容 >>
提交
77df8b80
编写于
8月 22, 2013
作者:
D
Do Nhat Minh
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
removed os::set_args, closing #8325
removed pub on real_args, changed test to use args
上级
f8584523
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
35 addition
and
40 deletion
+35
-40
src/librust/rust.rs
src/librust/rust.rs
+9
-10
src/librustc/rustc.rs
src/librustc/rustc.rs
+8
-3
src/librustdoc/rustdoc.rs
src/librustdoc/rustdoc.rs
+3
-0
src/librusti/rusti.rs
src/librusti/rusti.rs
+5
-1
src/librustpkg/rustpkg.rs
src/librustpkg/rustpkg.rs
+4
-1
src/libstd/os.rs
src/libstd/os.rs
+6
-25
未找到文件。
src/librust/rust.rs
浏览文件 @
77df8b80
...
...
@@ -45,7 +45,7 @@ fn is_valid(&self) -> bool {
enum
Action
{
Call
(
extern
"Rust"
fn
(
args
:
&
[
~
str
])
->
ValidUsage
),
CallMain
(
&
'static
str
,
extern
"Rust"
fn
()),
CallMain
(
&
'static
str
,
extern
"Rust"
fn
(
&
[
~
str
]
)),
}
enum
UsageSource
<
'self
>
{
...
...
@@ -69,7 +69,7 @@ struct Command<'self> {
static
COMMANDS
:
[
Command
<
'static
>
,
..
NUM_OF_COMMANDS
]
=
[
Command
{
cmd
:
"build"
,
action
:
CallMain
(
"rustc"
,
rustc
::
main
),
action
:
CallMain
(
"rustc"
,
rustc
::
main
_args
),
usage_line
:
"compile rust source files"
,
usage_full
:
UsgCall
(
rustc_help
),
},
...
...
@@ -95,19 +95,19 @@ struct Command<'self> {
},
Command
{
cmd
:
"doc"
,
action
:
CallMain
(
"rustdoc"
,
rustdoc
::
main
),
action
:
CallMain
(
"rustdoc"
,
rustdoc
::
main
_args
),
usage_line
:
"generate documentation from doc comments"
,
usage_full
:
UsgCall
(
rustdoc
::
config
::
usage
),
},
Command
{
cmd
:
"pkg"
,
action
:
CallMain
(
"rustpkg"
,
rustpkg
::
main
),
action
:
CallMain
(
"rustpkg"
,
rustpkg
::
main
_args
),
usage_line
:
"download, build, install rust packages"
,
usage_full
:
UsgCall
(
rustpkg
::
usage
::
general
),
},
Command
{
cmd
:
"sketch"
,
action
:
CallMain
(
"rusti"
,
rusti
::
main
),
action
:
CallMain
(
"rusti"
,
rusti
::
main
_args
),
usage_line
:
"run a rust interpreter"
,
usage_full
:
UsgStr
(
"
\n
Usage:
\t
rusti"
),
},
...
...
@@ -164,7 +164,7 @@ fn cmd_test(args: &[~str]) -> ValidUsage {
[
ref
filename
]
=>
{
let
test_exec
=
Path
(
*
filename
)
.filestem
()
.unwrap
()
+
"test~"
;
invoke
(
"rustc"
,
&
[
~
"--test"
,
filename
.to_owned
(),
~
"-o"
,
test_exec
.to_owned
()],
rustc
::
main
);
~
"-o"
,
test_exec
.to_owned
()],
rustc
::
main
_args
);
let
exit_code
=
run
::
process_status
(
~
"./"
+
test_exec
,
[]);
Valid
(
exit_code
)
}
...
...
@@ -177,7 +177,7 @@ fn cmd_run(args: &[~str]) -> ValidUsage {
[
ref
filename
,
..
prog_args
]
=>
{
let
exec
=
Path
(
*
filename
)
.filestem
()
.unwrap
()
+
"~"
;
invoke
(
"rustc"
,
&
[
filename
.to_owned
(),
~
"-o"
,
exec
.to_owned
()],
rustc
::
main
);
rustc
::
main
_args
);
let
exit_code
=
run
::
process_status
(
~
"./"
+
exec
,
prog_args
);
Valid
(
exit_code
)
}
...
...
@@ -185,11 +185,10 @@ fn cmd_run(args: &[~str]) -> ValidUsage {
}
}
fn
invoke
(
prog
:
&
str
,
args
:
&
[
~
str
],
f
:
&
fn
())
{
fn
invoke
(
prog
:
&
str
,
args
:
&
[
~
str
],
f
:
&
fn
(
&
[
~
str
]
))
{
let
mut
osargs
=
~
[
prog
.to_owned
()];
osargs
.push_all_move
(
args
.to_owned
());
os
::
set_args
(
osargs
);
f
();
f
(
osargs
);
}
fn
do_command
(
command
:
&
Command
,
args
:
&
[
~
str
])
->
ValidUsage
{
...
...
src/librustc/rustc.rs
浏览文件 @
77df8b80
...
...
@@ -191,11 +191,11 @@ pub fn describe_debug_flags() {
}
}
pub
fn
run_compiler
(
args
:
&
~
[
~
str
],
demitter
:
diagnostic
::
Emitter
)
{
pub
fn
run_compiler
(
args
:
&
[
~
str
],
demitter
:
diagnostic
::
Emitter
)
{
// Don't display log spew by default. Can override with RUST_LOG.
::
std
::
logging
::
console_off
();
let
mut
args
=
(
*
args
)
.clone
();
let
mut
args
=
args
.to_owned
();
let
binary
=
args
.shift
()
.to_managed
();
if
args
.is_empty
()
{
usage
(
binary
);
return
;
}
...
...
@@ -381,7 +381,12 @@ impl Drop for finally {
pub
fn
main
()
{
let
args
=
os
::
args
();
main_args
(
args
);
}
pub
fn
main_args
(
args
:
&
[
~
str
])
{
let
owned_args
=
args
.to_owned
();
do
monitor
|
demitter
|
{
run_compiler
(
&
args
,
demitter
);
run_compiler
(
owned_
args
,
demitter
);
}
}
src/librustdoc/rustdoc.rs
浏览文件 @
77df8b80
...
...
@@ -59,7 +59,10 @@
pub
fn
main
()
{
let
args
=
os
::
args
();
main_args
(
args
);
}
pub
fn
main_args
(
args
:
&
[
~
str
])
{
if
args
.iter
()
.any
(|
x
|
"-h"
==
*
x
)
||
args
.iter
()
.any
(|
x
|
"--help"
==
*
x
)
{
config
::
usage
();
return
;
...
...
src/librusti/rusti.rs
浏览文件 @
77df8b80
...
...
@@ -498,9 +498,13 @@ pub fn run_line(repl: &mut Repl, input: @io::Reader, out: @io::Writer, line: ~st
}
pub
fn
main
()
{
let
args
=
os
::
args
();
main_args
(
args
);
}
pub
fn
main_args
(
args
:
&
[
~
str
])
{
#[fixed_stack_segment]
;
#[inline(never)]
;
let
args
=
os
::
args
();
let
input
=
io
::
stdin
();
let
out
=
io
::
stdout
();
let
mut
repl
=
Repl
{
...
...
src/librustpkg/rustpkg.rs
浏览文件 @
77df8b80
...
...
@@ -466,8 +466,11 @@ fn unprefer(&self, _id: &str, _vers: Option<~str>) {
pub
fn
main
()
{
io
::
println
(
"WARNING: The Rust package manager is experimental and may be unstable"
);
let
args
=
os
::
args
();
main_args
(
args
);
}
pub
fn
main_args
(
args
:
&
[
~
str
])
{
let
opts
=
~
[
getopts
::
optflag
(
"h"
),
getopts
::
optflag
(
"help"
),
getopts
::
optflag
(
"j"
),
getopts
::
optflag
(
"json"
),
getopts
::
optmulti
(
"c"
),
getopts
::
optmulti
(
"cfg"
)];
...
...
src/libstd/os.rs
浏览文件 @
77df8b80
...
...
@@ -36,7 +36,6 @@
use
libc
;
use
libc
::{
c_char
,
c_void
,
c_int
,
size_t
};
use
libc
::
FILE
;
use
local_data
;
use
option
::{
Some
,
None
};
use
os
;
use
prelude
::
*
;
...
...
@@ -1188,7 +1187,7 @@ unsafe fn load_argc_and_argv(argc: c_int, argv: **c_char) -> ~[~str] {
* Returns a list of the command line arguments.
*/
#[cfg(target_os
=
"macos"
)]
pub
fn
real_args
()
->
~
[
~
str
]
{
fn
real_args
()
->
~
[
~
str
]
{
#[fixed_stack_segment]
;
#[inline(never)]
;
unsafe
{
...
...
@@ -1201,7 +1200,7 @@ pub fn real_args() -> ~[~str] {
#[cfg(target_os
=
"linux"
)]
#[cfg(target_os
=
"android"
)]
#[cfg(target_os
=
"freebsd"
)]
pub
fn
real_args
()
->
~
[
~
str
]
{
fn
real_args
()
->
~
[
~
str
]
{
use
rt
;
match
rt
::
args
::
clone
()
{
...
...
@@ -1211,7 +1210,7 @@ pub fn real_args() -> ~[~str] {
}
#[cfg(windows)]
pub
fn
real_args
()
->
~
[
~
str
]
{
fn
real_args
()
->
~
[
~
str
]
{
#[fixed_stack_segment]
;
#[inline(never)]
;
let
mut
nArgs
:
c_int
=
0
;
...
...
@@ -1261,28 +1260,10 @@ struct OverriddenArgs {
val
:
~
[
~
str
]
}
static
overridden_arg_key
:
local_data
::
Key
<@
OverriddenArgs
>
=
&
local_data
::
Key
;
/// Returns the arguments which this program was started with (normally passed
/// via the command line).
///
/// The return value of the function can be changed by invoking the
/// `os::set_args` function.
pub
fn
args
()
->
~
[
~
str
]
{
match
local_data
::
get
(
overridden_arg_key
,
|
k
|
k
.map
(|
&
k
|
*
k
))
{
None
=>
real_args
(),
Some
(
args
)
=>
args
.val
.clone
()
}
}
/// For the current task, overrides the task-local cache of the arguments this
/// program had when it started. These new arguments are only available to the
/// current task via the `os::args` method.
pub
fn
set_args
(
new_args
:
~
[
~
str
])
{
let
overridden_args
=
@
OverriddenArgs
{
val
:
new_args
.clone
()
};
local_data
::
set
(
overridden_arg_key
,
overridden_args
);
real_args
()
}
// FIXME #6100 we should really use an internal implementation of this - using
...
...
@@ -1770,7 +1751,7 @@ mod tests {
use
libc
;
use
option
::
Some
;
use
option
;
use
os
::{
env
,
getcwd
,
getenv
,
make_absolute
,
real_
args
};
use
os
::{
env
,
getcwd
,
getenv
,
make_absolute
,
args
};
use
os
::{
remove_file
,
setenv
,
unsetenv
};
use
os
;
use
path
::
Path
;
...
...
@@ -1788,7 +1769,7 @@ pub fn last_os_error() {
#[test]
pub
fn
test_args
()
{
let
a
=
real_
args
();
let
a
=
args
();
assert
!
(
a
.len
()
>=
1
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录