Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Pinoxchio
apollo
提交
ec697b9a
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,发现更多精彩内容 >>
提交
ec697b9a
编写于
8月 10, 2020
作者:
C
changsh726
提交者:
Chang Songhong
8月 11, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Scripts: aggregate format tools in apollo_format.sh
上级
1628d75b
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
103 addition
and
17 deletion
+103
-17
apollo.sh
apollo.sh
+3
-0
scripts/apollo.bashrc
scripts/apollo.bashrc
+0
-13
scripts/apollo_format.sh
scripts/apollo_format.sh
+83
-0
scripts/autopep8.sh
scripts/autopep8.sh
+16
-3
scripts/clang_format.sh
scripts/clang_format.sh
+1
-1
未找到文件。
apollo.sh
浏览文件 @
ec697b9a
...
...
@@ -198,6 +198,9 @@ function main() {
doc
)
env
${
APOLLO_ENV
}
bash
"
${
APOLLO_ROOT_DIR
}
/scripts/apollo_docs.sh"
"
$@
"
;;
format
)
env
${
APOLLO_ENV
}
bash
"
${
APOLLO_ROOT_DIR
}
/scripts/apollo_format.sh"
"
$@
"
;;
usage
)
_usage
;;
...
...
scripts/apollo.bashrc
浏览文件 @
ec697b9a
...
...
@@ -132,15 +132,6 @@ function c_family_ext() {
return
1
}
function
py_ext
()
{
local
__ext
__ext
=
"
$(
file_ext
$1
)
"
if
[
"
${
__ext
}
"
==
"py"
]
;
then
return
0
fi
return
1
}
function
find_c_cpp_srcs
()
{
find
"
$@
"
-type
f
-name
"*.h"
\
-o
-name
"*.c"
\
...
...
@@ -153,10 +144,6 @@ function find_c_cpp_srcs() {
-o
-name
"*.cu"
}
function
find_py_srcs
()
{
find
"
$@
"
-type
f
-name
"*.py"
}
## Prevent multiple entries of my_bin_path in PATH
function
add_to_path
()
{
if
[
-z
"
$1
"
]
;
then
...
...
scripts/apollo_format.sh
0 → 100644
浏览文件 @
ec697b9a
#!/usr/bin/env bash
###############################################################################
# Copyright 2020 The Apollo Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
###############################################################################
# Usage:
# apollo_format.sh <path/to/src/dir/or/files> [Options]
# Fail on error
set
-e
TOP_DIR
=
"
$(
cd
"
$(
dirname
"
${
BASH_SOURCE
[0]
}
"
)
/.."
&&
pwd
-P
)
"
source
"
${
TOP_DIR
}
/scripts/apollo.bashrc"
function
print_usage
()
{
info
"Usage:
$0
<path/to/src/dir/or/files> [Options]"
info
"Options:"
info
"
${
TAB
}
py|python Format Python code"
info
"
${
TAB
}
bazel Lint Bazel code"
info
"
${
TAB
}
cpp Format cpp code"
info
"
${
TAB
}
all Lint all (C++/Python/Bazel)"
}
function
run_clang_format
()
{
bash
"
${
TOP_DIR
}
/scripts/clang_format.sh"
"
$@
"
}
function
run_buildifier
()
{
bash
"
${
TOP_DIR
}
/scripts/buildifier.sh"
"
$@
"
}
function
run_autopep8
()
{
bash
"
${
TOP_DIR
}
/scripts/autopep8.sh"
"
$@
"
}
function
run_format_all
()
{
run_clang_format
"
$@
"
run_buildifier
"
$@
"
run_autopep8
"
$@
"
}
function
main
()
{
if
[
"$#"
-eq
0
]
;
then
print_usage
exit
1
fi
local
path
=
"
$1
"
shift
local
option
=
"
$1
"
case
"
${
option
}
"
in
py
|
python
)
run_autopep8
"
${
path
}
"
;;
cpp
)
run_clang_format
"
${
path
}
"
;;
bazel
)
run_buildifier
"
${
path
}
"
;;
all
)
run_format_all
"
${
path
}
"
;;
*
)
run_format_all
"
${
path
}
"
;;
esac
}
main
"
$@
"
scripts/autopep8.sh
浏览文件 @
ec697b9a
#!/usr/bin/env bash
###############################################################################
# Copyright 20
19
The Apollo Authors. All Rights Reserved.
# Copyright 20
20
The Apollo Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
...
...
@@ -27,6 +27,19 @@ source "${TOP_DIR}/scripts/apollo.bashrc"
AUTOPEP8_CMD
=
"autopep8"
function
_find_py_srcs
()
{
find
"
$@
"
-type
f
-name
"*.py"
}
function
_py_ext
()
{
local
__ext
__ext
=
"
$(
file_ext
$1
)
"
if
[
"
${
__ext
}
"
==
"py"
]
;
then
return
0
fi
return
1
}
function
check_autopep8
()
{
AUTOPEP8_CMD
=
"
$(
command
-v
autopep8
)
"
if
[
-z
"
${
AUTOPEP8_CMD
}
"
]
;
then
...
...
@@ -45,7 +58,7 @@ function autopep8_run() {
function
run_autopep8
()
{
for
target
in
"
$@
"
;
do
if
[
-f
"
${
target
}
"
]
;
then
if
py_ext
"
${
target
}
"
;
then
if
_
py_ext
"
${
target
}
"
;
then
autopep8_run
"
${
target
}
"
info
"Done formatting
${
target
}
"
else
...
...
@@ -53,7 +66,7 @@ function run_autopep8() {
fi
else
local
srcs
srcs
=
"
$(
find_py_srcs
${
target
}
)
"
srcs
=
"
$(
_
find_py_srcs
${
target
}
)
"
if
[
-z
"
${
srcs
}
"
]
;
then
warning
"Do nothing. No Python files found under
${
target
}
."
continue
...
...
scripts/clang_format.sh
浏览文件 @
ec697b9a
...
...
@@ -39,7 +39,7 @@ function check_clang_format() {
}
function
clang_format_run
()
{
${
CLANG_FORMAT_CMD
}
-i
-style
=
Google
"
$@
"
${
CLANG_FORMAT_CMD
}
-i
"
$@
"
}
function
run_clang_format
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录