Skip to content

Commit a88c6d8

Browse files
authored
Merge pull request #8425 from The-OpenROAD-Project-staging/bazel-linting
Added bazel format and linting workflows using buildifier
2 parents 3d0ea11 + f589aa2 commit a88c6d8

File tree

24 files changed

+226
-91
lines changed

24 files changed

+226
-91
lines changed

.buildifier.json

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
{
2+
"type": "auto",
3+
"mode": "fix",
4+
"lint": "fix",
5+
"warningsList": [
6+
"attr-applicable_licenses",
7+
"attr-cfg",
8+
"attr-license",
9+
"attr-licenses",
10+
"attr-non-empty",
11+
"attr-output-default",
12+
"attr-single-file",
13+
"build-args-kwargs",
14+
"bzl-visibility",
15+
"confusing-name",
16+
"constant-glob",
17+
"ctx-actions",
18+
"ctx-args",
19+
"deprecated-function",
20+
"depset-items",
21+
"depset-iteration",
22+
"depset-union",
23+
"dict-concatenation",
24+
"dict-method-named-arg",
25+
"duplicated-name",
26+
"filetype",
27+
"function-docstring",
28+
"function-docstring-args",
29+
"function-docstring-header",
30+
"function-docstring-return",
31+
"git-repository",
32+
"http-archive",
33+
"integer-division",
34+
"keyword-positional-params",
35+
"list-append",
36+
"load",
37+
"module-docstring",
38+
"name-conventions",
39+
"native-android",
40+
"native-build",
41+
"native-cc-binary",
42+
"native-cc-common",
43+
"native-cc-debug-package-info",
44+
"native-cc-fdo-prefetch-hints",
45+
"native-cc-fdo-profile",
46+
"native-cc-import",
47+
"native-cc-info",
48+
"native-cc-library",
49+
"native-cc-memprof-profile",
50+
"native-cc-objc-import",
51+
"native-cc-objc-library",
52+
"native-cc-propeller-optimize",
53+
"native-cc-proto",
54+
"native-cc-shared-library",
55+
"native-cc-shared-library-hint-info",
56+
"native-cc-shared-library-info",
57+
"native-cc-test",
58+
"native-cc-toolchain",
59+
"native-cc-toolchain-suite",
60+
"native-java-binary",
61+
"native-java-common",
62+
"native-java-import",
63+
"native-java-info",
64+
"native-java-library",
65+
"native-java-lite-proto",
66+
"native-java-package-config",
67+
"native-java-plugin",
68+
"native-java-plugin-info",
69+
"native-java-proto",
70+
"native-java-runtime",
71+
"native-java-test",
72+
"native-java-toolchain",
73+
"native-package",
74+
"native-proto",
75+
"native-proto-common",
76+
"native-proto-info",
77+
"native-proto-lang-toolchain",
78+
"native-proto-lang-toolchain-info",
79+
"native-py",
80+
"native-sh-binary",
81+
"native-sh-library",
82+
"native-sh-test",
83+
"no-effect",
84+
"output-group",
85+
"overly-nested-depset",
86+
"package-name",
87+
"package-on-top",
88+
"positional-args",
89+
"print",
90+
"provider-params",
91+
"redefined-variable",
92+
"repository-name",
93+
"return-value",
94+
"rule-impl-return",
95+
"skylark-comment",
96+
"skylark-docstring",
97+
"string-iteration",
98+
"uninitialized",
99+
"unnamed-macro",
100+
"unreachable",
101+
"unsorted-dict-items",
102+
"unused-variable"
103+
]
104+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Lint Bazel (Buildifier)
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
8+
jobs:
9+
check:
10+
runs-on: ${{ vars.USE_SELF_HOSTED == 'true' && 'self-hosted' || 'ubuntu-latest' }}
11+
env:
12+
BUILDIFIER_VERSION: v8.2.1
13+
14+
steps:
15+
- name: Checkout Code
16+
uses: actions/checkout@v5
17+
18+
- name: Download buildifier
19+
run: |
20+
wget https://github.com/bazelbuild/buildtools/releases/download/${BUILDIFIER_VERSION}/buildifier-linux-amd64 -O buildifier
21+
chmod +x buildifier
22+
23+
- name: Run buildifier (format check)
24+
run: ./buildifier -r -mode=check -lint=off .
25+
26+
- name: Run buildifier (lint)
27+
if: always()
28+
run: ./buildifier -r -lint=warn .

bazel/tcl_encode_or.bzl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ def _tcl_encode_or_impl(ctx):
2222
# Only keep .tcl and .py files.
2323
allowed_extensions = (".tcl", ".py")
2424
filtered_sources = [
25-
f for f in ctx.files.srcs if f.basename.endswith(allowed_extensions)
25+
f
26+
for f in ctx.files.srcs
27+
if f.basename.endswith(allowed_extensions)
2628
]
2729

2830
ctx.actions.run(

openroad/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ py_wheel(
3030
abi = "abi3",
3131
distribution = "openroad",
3232
homepage = "https://github.com/The-OpenROAD-Project/OpenROAD",
33+
platform = "linux_x86_64",
3334
python_requires = ">=3.10",
3435
python_tag = "cp310",
3536
version = "0.0.1",
3637
deps = [
3738
":openroad_pkg",
3839
],
39-
platform = "linux_x86_64"
4040
)

src/ant/BUILD

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# SPDX-License-Identifier: BSD-3-Clause
22
# Copyright (c) 2025, The OpenROAD Authors
33

4+
load("//bazel:python_wrap_cc.bzl", "python_wrap_cc")
45
load("//bazel:tcl_encode_or.bzl", "tcl_encode")
56
load("//bazel:tcl_wrap_cc.bzl", "tcl_wrap_cc")
6-
load("//bazel:python_wrap_cc.bzl", "python_wrap_cc")
77

88
package(
99
default_visibility = ["//:__subpackages__"],
@@ -90,13 +90,13 @@ python_wrap_cc(
9090
"src/AntennaChecker.i",
9191
"//:error_swig-py",
9292
],
93-
deps = [
94-
"//src/odb:swig-py",
95-
],
9693
module = "ant_py",
9794
root_swig_src = "src/AntennaChecker-py.i",
9895
swig_includes = [
9996
"include",
10097
"src",
10198
],
102-
)
99+
deps = [
100+
"//src/odb:swig-py",
101+
],
102+
)

src/dpl/BUILD

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# SPDX-License-Identifier: BSD-3-Clause
22
# Copyright (c) 2025, The OpenROAD Authors
33

4+
load("//bazel:python_wrap_cc.bzl", "python_wrap_cc")
45
load("//bazel:tcl_encode_or.bzl", "tcl_encode")
56
load("//bazel:tcl_wrap_cc.bzl", "tcl_wrap_cc")
6-
load("//bazel:python_wrap_cc.bzl", "python_wrap_cc")
77

88
package(
99
default_visibility = ["//:__subpackages__"],
@@ -176,4 +176,4 @@ python_wrap_cc(
176176
deps = [
177177
"//src/odb:swig-py",
178178
],
179-
)
179+
)

src/drt/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# SPDX-License-Identifier: BSD-3-Clause
22
# Copyright (c) 2025, The OpenROAD Authors
33

4+
load("//bazel:python_wrap_cc.bzl", "python_wrap_cc")
45
load("//bazel:tcl_encode_or.bzl", "tcl_encode")
56
load("//bazel:tcl_wrap_cc.bzl", "tcl_wrap_cc")
6-
load("//bazel:python_wrap_cc.bzl", "python_wrap_cc")
77

88
package(
99
default_visibility = ["//:__subpackages__"],

src/dst/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ cc_library(
4343
"@boost.system",
4444
] + select({
4545
"@platforms//os:macos": ["@boost.thread//:thread_mac"],
46-
"//conditions:default": ["@boost.thread//:thread_posix"],
46+
"//conditions:default": ["@boost.thread//:thread_posix"],
4747
}),
4848
)
4949

src/exa/BUILD

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# SPDX-License-Identifier: BSD-3-Clause
22
# Copyright (c) 2025, The OpenROAD Authors
33

4+
load("//bazel:python_wrap_cc.bzl", "python_wrap_cc")
45
load("//bazel:tcl_encode_or.bzl", "tcl_encode")
56
load("//bazel:tcl_wrap_cc.bzl", "tcl_wrap_cc")
6-
load("//bazel:python_wrap_cc.bzl", "python_wrap_cc")
77

88
package(
99
default_visibility = ["//:__subpackages__"],
@@ -97,5 +97,5 @@ python_wrap_cc(
9797
swig_includes = [
9898
"include",
9999
"src",
100-
]
101-
)
100+
],
101+
)

src/fin/BUILD

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# SPDX-License-Identifier: BSD-3-Clause
22
# Copyright (c) 2025, The OpenROAD Authors
33

4+
load("//bazel:python_wrap_cc.bzl", "python_wrap_cc")
45
load("//bazel:tcl_encode_or.bzl", "tcl_encode")
56
load("//bazel:tcl_wrap_cc.bzl", "tcl_wrap_cc")
6-
load("//bazel:python_wrap_cc.bzl", "python_wrap_cc")
77

88
package(
99
default_visibility = ["//:__subpackages__"],
@@ -84,4 +84,4 @@ python_wrap_cc(
8484
deps = [
8585
"//src/odb:swig-py",
8686
],
87-
)
87+
)

0 commit comments

Comments
 (0)