Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Pinoxchio
apollo
提交
482a39f4
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,发现更多精彩内容 >>
提交
482a39f4
编写于
6月 17, 2020
作者:
S
storypku
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Format: buildify tools/cpplint.bzl and fix buildifier call
上级
52f3087b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
63 addition
and
56 deletion
+63
-56
apollo.sh
apollo.sh
+1
-1
tools/cpplint.bzl
tools/cpplint.bzl
+62
-55
未找到文件。
apollo.sh
浏览文件 @
482a39f4
...
...
@@ -456,7 +456,7 @@ function clean() {
}
function
buildify
()
{
find
.
-name
'*BUILD'
-or
-name
'*.bzl'
-type
f
-exec
buildifier
-
showlog
-
mode
=
fix
{}
+
find
.
-name
'*BUILD'
-or
-name
'*.bzl'
-type
f
-exec
buildifier
-mode
=
fix
{}
+
if
[
$?
-eq
0
]
;
then
success
'Buildify worked!'
else
...
...
tools/cpplint.bzl
浏览文件 @
482a39f4
...
...
@@ -20,65 +20,72 @@ _EXTENSIONS_ARGS = ["--extensions=" + ",".join(
)]
def
_extract_labels
(
srcs
):
"""Convert a srcs= or hdrs= value to its set of labels."""
# Tuples are already labels.
if
type
(
srcs
)
==
type
(()):
return
list
(
srcs
)
return
[]
"""Convert a srcs= or hdrs= value to its set of labels."""
def
_is_source_label
(
label
):
for
extension
in
_SOURCE_EXTENSIONS
:
if
label
.
endswith
(
extension
):
return
True
return
False
# Tuples are already labels.
if
type
(
srcs
)
==
type
(()):
return
list
(
srcs
)
return
[]
def
_
add_linter_rules
(
source_labels
,
source_filenames
,
name
,
data
=
None
):
# Common attributes for all of our py_test invocations.
data
=
(
data
or
[])
size
=
"small"
tags
=
[
"cpplint"
]
def
_
is_source_label
(
label
):
for
extension
in
_SOURCE_EXTENSIONS
:
if
label
.
endswith
(
extension
):
return
True
return
False
# Google cpplint.
cpplint_cfg
=
[
"//:CPPLINT.cfg"
]
+
native
.
glob
([
'CPPLINT.cfg'
])
native
.
py_test
(
name
=
name
+
"_cpplint"
,
srcs
=
[
"@cpplint//:cpplint"
],
data
=
data
+
cpplint_cfg
+
source_labels
,
args
=
_EXTENSIONS_ARGS
+
source_filenames
,
main
=
"cpplint.py"
,
size
=
size
,
tags
=
tags
,
)
def
_add_linter_rules
(
source_labels
,
source_filenames
,
name
,
data
=
None
):
# Common attributes for all of our py_test invocations.
data
=
(
data
or
[])
size
=
"small"
tags
=
[
"cpplint"
]
def
cpplint
(
data
=
None
,
extra_srcs
=
None
):
"""For every rule in the BUILD file so far, adds a test rule that runs
cpplint over the C++ sources listed in that rule. Thus, BUILD file authors
should call this function at the *end* of every C++-related BUILD file.
By default, only the CPPLINT.cfg from the project root and the current
directory are used. Additional configs can be passed in as data labels.
Sources that are not discoverable through the "sources so far" heuristic can
be passed in as extra_srcs=[].
"""
# Iterate over all rules.
for
rule
in
native
.
existing_rules
().
values
():
# Extract the list of C++ source code labels and convert to filenames.
candidate_labels
=
(
_extract_labels
(
rule
.
get
(
"srcs"
,
()))
+
_extract_labels
(
rule
.
get
(
"hdrs"
,
()))
# Google cpplint.
cpplint_cfg
=
[
"//:CPPLINT.cfg"
]
+
native
.
glob
([
"CPPLINT.cfg"
])
native
.
py_test
(
name
=
name
+
"_cpplint"
,
srcs
=
[
"@cpplint//:cpplint"
],
data
=
data
+
cpplint_cfg
+
source_labels
,
args
=
_EXTENSIONS_ARGS
+
source_filenames
,
main
=
"cpplint.py"
,
size
=
size
,
tags
=
tags
,
)
source_labels
=
[
label
for
label
in
candidate_labels
if
_is_source_label
(
label
)
]
source_filenames
=
[
"$(location %s)"
%
x
for
x
in
source_labels
]
# Run the cpplint checker as a unit test.
if
len
(
source_filenames
)
>
0
:
_add_linter_rules
(
source_labels
,
source_filenames
,
rule
[
"name"
],
data
)
def
cpplint
(
data
=
None
,
extra_srcs
=
None
):
"""For every rule in the BUILD file so far, adds a test rule that runs
cpplint over the C++ sources listed in that rule. Thus, BUILD file authors
should call this function at the *end* of every C++-related BUILD file.
By default, only the CPPLINT.cfg from the project root and the current
directory are used. Additional configs can be passed in as data labels.
Sources that are not discoverable through the "sources so far" heuristic can
be passed in as extra_srcs=[].
"""
# Iterate over all rules.
for
rule
in
native
.
existing_rules
().
values
():
# Extract the list of C++ source code labels and convert to filenames.
candidate_labels
=
(
_extract_labels
(
rule
.
get
(
"srcs"
,
()))
+
_extract_labels
(
rule
.
get
(
"hdrs"
,
()))
)
source_labels
=
[
label
for
label
in
candidate_labels
if
_is_source_label
(
label
)
]
source_filenames
=
[
"$(location %s)"
%
x
for
x
in
source_labels
]
# Run the cpplint checker as a unit test.
if
len
(
source_filenames
)
>
0
:
_add_linter_rules
(
source_labels
,
source_filenames
,
rule
[
"name"
],
data
)
# Lint all of the extra_srcs separately in a single rule.
if
extra_srcs
:
source_labels
=
extra_srcs
source_filenames
=
[
"$(location %s)"
%
x
for
x
in
source_labels
]
_add_linter_rules
(
source_labels
,
source_filenames
,
"extra_srcs_cpplint"
,
data
)
# Lint all of the extra_srcs separately in a single rule.
if
extra_srcs
:
source_labels
=
extra_srcs
source_filenames
=
[
"$(location %s)"
%
x
for
x
in
source_labels
]
_add_linter_rules
(
source_labels
,
source_filenames
,
"extra_srcs_cpplint"
,
data
,
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录