Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Pinoxchio
apollo
提交
678cc1cd
A
apollo
项目概览
Pinoxchio
/
apollo
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
apollo
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
678cc1cd
编写于
9月 04, 2020
作者:
S
storypku
提交者:
Liu Jiaming
9月 04, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Scripts: improved apollo_format.sh
上级
fe977119
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
79 addition
and
46 deletion
+79
-46
scripts/apollo_format.sh
scripts/apollo_format.sh
+74
-40
scripts/autopep8.sh
scripts/autopep8.sh
+1
-1
scripts/clang_format.sh
scripts/clang_format.sh
+1
-2
scripts/shfmt.sh
scripts/shfmt.sh
+3
-3
未找到文件。
scripts/apollo_format.sh
浏览文件 @
678cc1cd
...
...
@@ -25,6 +25,13 @@ set -e
TOP_DIR
=
"
$(
cd
"
$(
dirname
"
${
BASH_SOURCE
[0]
}
"
)
/.."
&&
pwd
-P
)
"
source
"
${
TOP_DIR
}
/scripts/apollo.bashrc"
FORMAT_BAZEL
=
0
FORMAT_CPP
=
0
FORMAT_MARKDOWN
=
0
FORMAT_PYTHON
=
0
FORMAT_SHELL
=
0
FORMAT_ALL
=
0
function
print_usage
()
{
echo
-e
"
\n
${
RED
}
Usage
${
NO_COLOR
}
:
.
${
BOLD
}
$0
${
NO_COLOR
}
[OPTION] <path/to/src/dir/or/files>"
...
...
@@ -35,7 +42,7 @@ function print_usage() {
${
BLUE
}
-s|--shell
${
NO_COLOR
}
Format Shell code
${
BLUE
}
-m|--markdown
${
NO_COLOR
}
Format Markdown file
${
BLUE
}
-a|--all
${
NO_COLOR
}
Format all
${
BLUE
}
-h|--help
${
NO_COLOR
}
Show this message"
${
BLUE
}
-h|--help
${
NO_COLOR
}
Show this message
and exit
"
}
function
run_clang_format
()
{
...
...
@@ -58,51 +65,78 @@ function run_prettier() {
bash
"
${
TOP_DIR
}
/scripts/mdfmt.sh"
"
$@
"
}
function
run_format_all
()
{
run_clang_format
"
$@
"
run_buildifier
"
$@
"
run_autopep8
"
$@
"
run_shfmt
"
$@
"
run_prettier
"
$@
"
}
function
main
()
{
if
[
"$#"
-eq
0
]
;
then
print_usage
exit
1
fi
local
option
=
"
$1
"
shift
case
"
${
option
}
"
in
while
[
$#
-gt
0
]
;
do
local
opt
=
"
$1
"
case
"
${
opt
}
"
in
-p
|
--python
)
run_autopep8
"
$@
"
FORMAT_PYTHON
=
1
shift
;;
-c
|
--cpp
)
run_clang_format
"
$@
"
FORMAT_CPP
=
1
shift
;;
-b
|
--bazel
)
run_buildifier
"
$@
"
FORMAT_BAZEL
=
1
shift
;;
-s
|
--shell
)
run_shfmt
"
$@
"
FORMAT_SHELL
=
1
shift
;;
-m
|
--markdown
)
run_prettier
"
$@
"
FORMAT_MARKDOWN
=
1
shift
;;
-a
|
--all
)
run_format_all
"
$@
"
FORMAT_ALL
=
1
shift
;;
-h
|
--help
)
print_usage
exit
1
;;
*
)
echo
"Unknown option:
${
option
}
"
if
[[
"
${
opt
}
"
=
-
*
]]
;
then
print_usage
exit
1
else
FORMAT_ALL
=
1
break
fi
;;
esac
done
if
[
"
${
FORMAT_ALL
}
"
-eq
1
]
;
then
FORMAT_BAZEL
=
1
FORMAT_CPP
=
1
FORMAT_MARKDOWN
=
1
FORMAT_SHELL
=
1
FORMAT_PYTHON
=
1
fi
if
[
"
${
FORMAT_BAZEL
}
"
-eq
1
]
;
then
run_buildifier
"
$@
"
fi
if
[
"
${
FORMAT_CPP
}
"
-eq
1
]
;
then
run_clang_format
"
$@
"
fi
if
[
"
${
FORMAT_PYTHON
}
"
-eq
1
]
;
then
run_autopep8
"
$@
"
fi
if
[
"
${
FORMAT_SHELL
}
"
-eq
1
]
;
then
run_shfmt
"
$@
"
fi
if
[
"
${
FORMAT_MARKDOWN
}
"
-eq
1
]
;
then
run_prettier
"
$@
"
fi
}
main
"
$@
"
scripts/autopep8.sh
浏览文件 @
678cc1cd
...
...
@@ -71,7 +71,7 @@ function run_autopep8() {
continue
fi
autopep8_run
${
srcs
}
ok
"Done formatting Python
source
files under
${
target
}
"
ok
"Done formatting Python files under
${
target
}
"
fi
done
}
...
...
scripts/clang_format.sh
浏览文件 @
678cc1cd
...
...
@@ -57,8 +57,7 @@ function run_clang_format() {
local
srcs
srcs
=
"
$(
find_c_cpp_srcs
${
target
}
)
"
if
[
-z
"
${
srcs
}
"
]
;
then
warning
"Do nothing. No c/c++/cuda header/source"
\
"files found under
${
target
}
."
ok
"No need to format C/C++/CUDA files under
${
target
}
as none found"
continue
fi
clang_format_run
${
srcs
}
...
...
scripts/shfmt.sh
浏览文件 @
678cc1cd
...
...
@@ -65,17 +65,17 @@ function run_shfmt() {
shell_format_run
"
${
target
}
"
info
"Done formatting
${
target
}
"
else
warning
"Do nothing.
${
target
}
is not a
Shell file
."
warning
"Do nothing.
${
target
}
is not a
bash scripts
."
fi
else
local
srcs
srcs
=
"
$(
_find_shell_srcs
${
target
}
)
"
if
[
-z
"
${
srcs
}
"
]
;
then
warning
"Do nothing. No Shell files found under
${
target
}
.
"
ok
"No need to format shell scripts under
${
target
}
as none found
"
continue
fi
shell_format_run
${
srcs
}
ok
"Done formatting
Shell source file
s under
${
target
}
"
ok
"Done formatting
shell script
s under
${
target
}
"
fi
done
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录