Skip to content

Commit 51df92f

Browse files
committed
Load py_library, py_binary from rules_python
This adds an explicit dependency on rules_python and loads py_library and py_binary rules from there, instead of relying on built-in versions in Bazel. This prepares us for the rollout of bazelbuild/bazel#15897 (which is happening internally already, and across the Bazel ecosystem soon). Except for the change to the WORKSPACE file, this change was auto-generated by running, buildozer 'new_load @rules_python//python:py_library.bzl py_library' //...:__pkg__ buildozer 'new_load @rules_python//python:py_binary.bzl py_binary' //...:__pkg__ buildozer 'new_load @rules_python//python:py_test.bzl py_test' //...:__pkg__ buildozer 'fix unusedLoads' //...:__pkg__ Upstreams cl/551628592.
1 parent 96ad72e commit 51df92f

File tree

9 files changed

+53
-29
lines changed

9 files changed

+53
-29
lines changed

WORKSPACE

+11
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,14 @@ http_archive(
2323
urls = ["https://github.com/bazelbuild/bazel-skylib/releases/download/1.2.1/bazel-skylib-1.2.1.tar.gz"],
2424
sha256 = "f7be3474d42aae265405a592bb7da8e171919d74c16f082a5457840f06054728",
2525
)
26+
27+
http_archive(
28+
name = "rules_python",
29+
sha256 = "c68bdc4fbec25de5b5493b8819cfc877c4ea299c0dcb15c244c5a00208cde311",
30+
strip_prefix = "rules_python-0.31.0",
31+
url = "https://github.com/bazelbuild/rules_python/releases/download/0.31.0/rules_python-0.31.0.tar.gz",
32+
)
33+
34+
load("@rules_python//python:repositories.bzl", "py_repositories")
35+
36+
py_repositories()

compiler/back_end/cpp/BUILD

+4-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414

1515
# Emboss C++ code generator.
1616

17+
load("@rules_python//python:py_binary.bzl", "py_binary")
18+
load("@rules_python//python:py_library.bzl", "py_library")
19+
load("@rules_python//python:py_test.bzl", "py_test")
1720
load(":build_defs.bzl", "emboss_cc_test")
1821

1922
package(
@@ -37,7 +40,7 @@ py_binary(
3740
py_library(
3841
name = "attributes",
3942
srcs = ["attributes.py"],
40-
deps = []
43+
deps = [],
4144
)
4245

4346
py_library(

compiler/back_end/util/BUILD

+3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414

1515
# Shared utilities for Emboss back ends.
1616

17+
load("@rules_python//python:py_library.bzl", "py_library")
18+
load("@rules_python//python:py_test.bzl", "py_test")
19+
1720
package(
1821
default_visibility = ["//compiler:__subpackages__"],
1922
)

compiler/front_end/BUILD

+12-8
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
# intermediate representation (IR). The IR is passed to back end code
1919
# generators to generate code in various languages.
2020

21+
load("@rules_python//python:py_binary.bzl", "py_binary")
22+
load("@rules_python//python:py_library.bzl", "py_library")
23+
load("@rules_python//python:py_test.bzl", "py_test")
24+
2125
package(
2226
default_visibility = [
2327
"//:__subpackages__",
@@ -135,8 +139,8 @@ py_library(
135139
":tokenizer",
136140
":type_check",
137141
":write_inference",
138-
"//compiler/util:ir_pb2",
139142
"//compiler/util:error",
143+
"//compiler/util:ir_pb2",
140144
"//compiler/util:parser_types",
141145
"//compiler/util:resources",
142146
],
@@ -151,8 +155,8 @@ py_test(
151155
python_version = "PY3",
152156
deps = [
153157
":glue",
154-
"//compiler/util:ir_pb2",
155158
"//compiler/util:error",
159+
"//compiler/util:ir_pb2",
156160
"//compiler/util:parser_types",
157161
"//compiler/util:test_util",
158162
],
@@ -163,8 +167,8 @@ py_library(
163167
srcs = ["synthetics.py"],
164168
visibility = ["//visibility:private"],
165169
deps = [
166-
"//compiler/util:ir_pb2",
167170
"//compiler/util:expression_parser",
171+
"//compiler/util:ir_pb2",
168172
"//compiler/util:traverse_ir",
169173
],
170174
)
@@ -185,8 +189,8 @@ py_library(
185189
srcs = ["symbol_resolver.py"],
186190
visibility = ["//visibility:private"],
187191
deps = [
188-
"//compiler/util:ir_pb2",
189192
"//compiler/util:error",
193+
"//compiler/util:ir_pb2",
190194
"//compiler/util:ir_util",
191195
"//compiler/util:traverse_ir",
192196
],
@@ -257,8 +261,8 @@ py_test(
257261
deps = [
258262
":attribute_checker",
259263
":glue",
260-
"//compiler/util:ir_pb2",
261264
"//compiler/util:error",
265+
"//compiler/util:ir_pb2",
262266
"//compiler/util:ir_util",
263267
"//compiler/util:test_util",
264268
],
@@ -269,8 +273,8 @@ py_library(
269273
srcs = ["type_check.py"],
270274
deps = [
271275
":attributes",
272-
"//compiler/util:ir_pb2",
273276
"//compiler/util:error",
277+
"//compiler/util:ir_pb2",
274278
"//compiler/util:ir_util",
275279
"//compiler/util:traverse_ir",
276280
],
@@ -321,8 +325,8 @@ py_library(
321325
],
322326
deps = [
323327
":attributes",
324-
"//compiler/util:ir_pb2",
325328
"//compiler/util:error",
329+
"//compiler/util:ir_pb2",
326330
"//compiler/util:ir_util",
327331
"//compiler/util:resources",
328332
"//compiler/util:traverse_ir",
@@ -345,8 +349,8 @@ py_library(
345349
name = "dependency_checker",
346350
srcs = ["dependency_checker.py"],
347351
deps = [
348-
"//compiler/util:ir_pb2",
349352
"//compiler/util:error",
353+
"//compiler/util:ir_pb2",
350354
"//compiler/util:ir_util",
351355
"//compiler/util:traverse_ir",
352356
],

compiler/util/BUILD

+6-3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414

1515
# Shared utilities for Emboss back ends.
1616

17+
load("@rules_python//python:py_library.bzl", "py_library")
18+
load("@rules_python//python:py_test.bzl", "py_test")
19+
1720
package(
1821
default_visibility = ["//compiler:__subpackages__"],
1922
)
@@ -100,8 +103,8 @@ py_library(
100103
name = "traverse_ir",
101104
srcs = ["traverse_ir.py"],
102105
deps = [
103-
":simple_memoizer",
104106
":ir_pb2",
107+
":simple_memoizer",
105108
],
106109
)
107110

@@ -110,8 +113,8 @@ py_test(
110113
srcs = ["traverse_ir_test.py"],
111114
python_version = "PY3",
112115
deps = [
113-
":traverse_ir",
114116
":ir_pb2",
117+
":traverse_ir",
115118
],
116119
)
117120

@@ -128,8 +131,8 @@ py_test(
128131
srcs = ["parser_types_test.py"],
129132
python_version = "PY3",
130133
deps = [
131-
":parser_types",
132134
":ir_pb2",
135+
":parser_types",
133136
],
134137
)
135138

doc/BUILD

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
filegroup(
2121
name = "grammar_md",
2222
srcs = [
23-
"grammar.md",
2423
"__init__.py",
24+
"grammar.md",
2525
],
2626
# This should only be needed by docs_are_up_to_date_test.
2727
visibility = ["//:__subpackages__"],

integration/googletest/BUILD

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ cc_library(
1919
visibility = ["//visibility:public"],
2020
deps = [
2121
"//runtime/cpp:cpp_utils",
22-
"@com_google_googletest//:gtest",
2322
"@com_google_absl//absl/memory",
23+
"@com_google_googletest//:gtest",
2424
],
2525
)
2626

@@ -32,7 +32,7 @@ cc_test(
3232
copts = ["-Wsign-compare"],
3333
deps = [
3434
":emboss_test_util",
35-
"@com_google_googletest//:gtest_main",
3635
"//testdata:complex_structure_emboss",
36+
"@com_google_googletest//:gtest_main",
3737
],
3838
)

runtime/cpp/test/BUILD

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ emboss_cc_util_test(
5151
copts = ["-DEMBOSS_FORCE_ALL_CHECKS"],
5252
deps = [
5353
"//runtime/cpp:cpp_utils",
54-
"@com_google_googletest//:gtest_main",
5554
"@com_google_absl//absl/strings:str_format",
55+
"@com_google_googletest//:gtest_main",
5656
],
5757
)
5858

testdata/BUILD

+13-13
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@
1414

1515
# Shared test data for Emboss.
1616

17-
load("//:build_defs.bzl",
18-
"emboss_cc_library",
19-
"emboss_library",
20-
"cc_emboss_library"
17+
load(
18+
"//:build_defs.bzl",
19+
"cc_emboss_library",
20+
"emboss_cc_library",
21+
"emboss_library",
2122
)
2223

2324
package(
@@ -27,17 +28,18 @@ package(
2728
filegroup(
2829
name = "golden_files",
2930
srcs = [
31+
"golden/__init__.py",
3032
"golden/span_se_log_file_status.emb",
3133
"golden/span_se_log_file_status.ir.txt",
3234
"golden/span_se_log_file_status.parse_tree.txt",
3335
"golden/span_se_log_file_status.tokens.txt",
34-
"golden/__init__.py",
3536
],
3637
)
3738

3839
filegroup(
3940
name = "test_embs",
4041
srcs = [
42+
"__init__.py",
4143
"absolute_cpp_namespace.emb",
4244
"anonymous_bits.emb",
4345
"bcd.emb",
@@ -50,22 +52,21 @@ filegroup(
5052
"enum_case.emb",
5153
"explicit_sizes.emb",
5254
"float.emb",
55+
"import_dir/project/imported.emb",
56+
"import_dir/project/importer.emb",
5357
"imported.emb",
5458
"imported_genfiles.emb",
5559
"importer.emb",
56-
"import_dir/project/imported.emb",
57-
"import_dir/project/importer.emb",
5860
"int_sizes.emb",
5961
"nested_structure.emb",
60-
"no_cpp_namespace.emb",
6162
"next_keyword.emb",
63+
"no_cpp_namespace.emb",
6264
"parameters.emb",
6365
"requires.emb",
6466
"subtypes.emb",
6567
"text_format.emb",
6668
"uint_sizes.emb",
6769
"virtual_field.emb",
68-
"__init__.py",
6970
],
7071
)
7172

@@ -180,15 +181,14 @@ emboss_cc_library(
180181
srcs = [
181182
"import_dir/project/importer.emb",
182183
],
184+
import_dirs = [
185+
"import_dir",
186+
],
183187
deps = [
184188
":import_dir_imported_emboss",
185189
],
186-
import_dirs = [
187-
"import_dir",
188-
]
189190
)
190191

191-
192192
emboss_cc_library(
193193
name = "importer2_emboss",
194194
srcs = [

0 commit comments

Comments
 (0)