Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenXiangShan
rust-xs-test
提交
958baf90
R
rust-xs-test
项目概览
OpenXiangShan
/
rust-xs-test
10 个月 前同步成功
通知
0
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rust-xs-test
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
958baf90
编写于
1月 14, 2021
作者:
H
hustccc
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add some unfinished code
上级
94506583
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
25 addition
and
4 deletion
+25
-4
xscommand/src/git.rs
xscommand/src/git.rs
+12
-3
xscommand/src/lib.rs
xscommand/src/lib.rs
+13
-1
未找到文件。
xscommand/src/git.rs
浏览文件 @
958baf90
...
...
@@ -14,6 +14,7 @@ use simple_logger::SimpleLogger;
pub
struct
Git
<
'a
>
{
exe
:
Command
,
args
:
Vec
<&
'a
str
>
,
work_dir
:
Option
<&
'a
str
>
,
}
...
...
@@ -24,10 +25,12 @@ impl<'a> XSCommand<'a, GitErr> for Git<'a> {
Self
{
exe
:
git
,
args
,
work_dir
:
None
,
}
}
fn
set_args
(
&
mut
self
,
args
:
Vec
<&
'a
str
>
)
->
Result
<
(),
GitErr
>
{
// TODO: check the rationality of args
self
.args
=
args
;
Ok
(())
}
...
...
@@ -42,10 +45,13 @@ impl<'a> XSCommand<'a, GitErr> for Git<'a> {
args
}
fn
set_workdir
(
&
mut
self
,
work_dir
:
&
'a
str
)
->
Result
<
(),
GitErr
>
{
// TODO: check the rationality of workdir
self
.work_dir
=
Some
(
work_dir
);
Ok
(())
}
fn
excute
(
&
mut
self
,
stdout
:
Option
<&
str
>
,
stderr
:
Option
<&
str
>
)
->
Result
<
i32
,
GitErr
>
{
// Init the logger
// let logger = SimpleLogger::new();
// logger.init().unwrap();
for
arg
in
&
self
.args
{
self
.exe
.arg
(
arg
);
}
...
...
@@ -60,6 +66,9 @@ impl<'a> XSCommand<'a, GitErr> for Git<'a> {
let
err_out
=
unsafe
{
Stdio
::
from_raw_fd
(
stderr_fd
)
};
self
.exe
.stderr
(
err_out
);
}
if
let
Some
(
dir
)
=
self
.work_dir
{
self
.exe
.current_dir
(
dir
);
}
let
res
=
self
.exe
.status
();
match
res
{
Ok
(
exit_status
)
=>
{
...
...
xscommand/src/lib.rs
浏览文件 @
958baf90
//! `xscommand` crate is for abstraction of command used in XiangShan development
//! like `sh`, `git` and `emu` which is a simulator in the development of XiangShan
//!
//! The project use this crate should init the [logger](https://github.com/rust-lang/log) in the main.rs, like this:
//! ```no_run
//! extern crate simple_logger;
//! use simple_logger::SimpleLogger;
//!
//! fn main() {
//! let logger = SimpleLogger::new();
//! logger.init().unwrap();
//! ...
//! }
//! ```
pub
mod
git
;
use
std
::
fmt
::
Debug
;
...
...
@@ -15,6 +25,8 @@ pub trait XSCommand<'a, T: XSCommandErr + Debug> {
fn
set_args
(
&
mut
self
,
args
:
Vec
<&
'a
str
>
)
->
Result
<
(),
T
>
;
/// Get arguments
fn
get_args
(
&
self
)
->
Vec
<&
str
>
;
/// Set the working dir for the XSCommand
fn
set_workdir
(
&
mut
self
,
work_dir
:
&
'a
str
)
->
Result
<
(),
T
>
;
/// Excute the command
/// Return exit code
fn
excute
(
&
mut
self
,
stdout
:
Option
<&
str
>
,
stderr
:
Option
<&
str
>
)
->
Result
<
i32
,
T
>
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录