Skip to content

Commit 2bada59

Browse files
authored
Create bzl_library entries using gazelle-skylark (bazel-contrib#2621)
There are a few minor manual modifications that needed to be performed. For example, some .bzl files depend on .bzl files that are generated outside of this repo and do not presently exist. @bazel_tools is a great example of this. Additionally this effort has revealed that bazel gazelle has an explicit dependency on the private parts of rules_go in internal/gazelle_binary.bzl on line 21 where it imports from go/private:rules/transitions.bzl which is no longer the path to import from once I created the BUILD file in go/private/rules. As a temporary fix for this, I'm included a patch that changes that to point to the new path. I will provide a follow up patch once rules_go has been released to fix it properly in the gazelle repo and then remove the patch from rules_go. Fixed: bazel-contrib#2619 Bug: bazelbuild/bazel-skylib#250 Bug: bazel-contrib/bazel-gazelle#803
1 parent 99e0cf0 commit 2bada59

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+621
-104
lines changed

BUILD.bazel

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
load(
2-
"@io_bazel_rules_go//go/private:tools/lines_sorted_test.bzl",
2+
"@io_bazel_rules_go//go/private/tools:lines_sorted_test.bzl",
33
"lines_sorted_test",
44
)
55
load(
6-
"@io_bazel_rules_go//go/private:rules/nogo.bzl",
6+
"@io_bazel_rules_go//go/private/rules:nogo.bzl",
77
"nogo",
88
)
99
load(
10-
"@io_bazel_rules_go//go/private:rules/info.bzl",
10+
"@io_bazel_rules_go//go/private/rules:info.bzl",
1111
"go_info",
1212
)
1313
load(
@@ -22,7 +22,7 @@ load(
2222
"go_context_data",
2323
)
2424
load(
25-
"@io_bazel_rules_go//go/private:rules/stdlib.bzl",
25+
"@io_bazel_rules_go//go/private/rules:stdlib.bzl",
2626
"stdlib",
2727
)
2828

WORKSPACE

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,6 @@ load("@io_bazel_rules_go//extras:embed_data_deps.bzl", "go_embed_data_dependenci
2727

2828
go_embed_data_dependencies()
2929

30-
http_archive(
31-
name = "rules_proto",
32-
sha256 = "4d421d51f9ecfe9bf96ab23b55c6f2b809cbaf0eea24952683e397decfbd0dd0",
33-
strip_prefix = "rules_proto-f6b8d89b90a7956f6782a4a3609b2f0eee3ce965",
34-
# master, as of 2020-01-06
35-
urls = [
36-
"https://mirror.bazel.build/github.com/bazelbuild/rules_proto/archive/f6b8d89b90a7956f6782a4a3609b2f0eee3ce965.tar.gz",
37-
"https://github.com/bazelbuild/rules_proto/archive/f6b8d89b90a7956f6782a4a3609b2f0eee3ce965.tar.gz",
38-
],
39-
)
40-
4130
# Used by //tests:buildifier_test.
4231
# Latest release is not compatible with the incompatible bazel flags we use
4332
# in CI, in particular, --incompatible_load_proto_rules_from_bzl.

extras/BUILD.bazel

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
2+
13
filegroup(
24
name = "all_rules",
35
srcs = glob(["*.bzl"]) + ["//go/private:all_rules"],
@@ -10,3 +12,25 @@ filegroup(
1012
srcs = glob(["**"]),
1113
visibility = ["//visibility:public"],
1214
)
15+
16+
bzl_library(
17+
name = "bindata",
18+
srcs = ["bindata.bzl"],
19+
visibility = ["//visibility:public"],
20+
deps = ["@io_bazel_rules_go//go:def"],
21+
)
22+
23+
bzl_library(
24+
name = "embed_data",
25+
srcs = ["embed_data.bzl"],
26+
visibility = ["//visibility:public"],
27+
deps = ["@io_bazel_rules_go//go/private:context"],
28+
)
29+
30+
bzl_library(
31+
name = "embed_data_deps",
32+
srcs = ["embed_data_deps.bzl"],
33+
visibility = ["//visibility:public"],
34+
# Don't list dependency on @bazel_tools//tools/build_defs/repo.bzl
35+
deps = [], # keep
36+
)

go/BUILD.bazel

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
2+
13
filegroup(
24
name = "all_files",
35
testonly = True,
@@ -25,3 +27,31 @@ toolchain_type(
2527
name = "toolchain",
2628
visibility = ["//visibility:public"],
2729
)
30+
31+
bzl_library(
32+
name = "def",
33+
srcs = ["def.bzl"],
34+
visibility = ["//visibility:public"],
35+
deps = [
36+
"//extras:embed_data",
37+
"//go/private:context",
38+
"//go/private:go_toolchain",
39+
"//go/private:providers",
40+
"//go/private/rules:library",
41+
"//go/private/rules:nogo",
42+
"//go/private/rules:sdk",
43+
"//go/private/rules:source",
44+
"//go/private/rules:wrappers",
45+
"//go/private/tools:path",
46+
],
47+
)
48+
49+
bzl_library(
50+
name = "deps",
51+
srcs = ["deps.bzl"],
52+
visibility = ["//visibility:public"],
53+
deps = [
54+
"//go/private:repositories",
55+
"//go/private:sdk",
56+
],
57+
)

go/def.bzl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ may change without notice.
2323
"""
2424

2525
load(
26-
"@io_bazel_rules_go//go/private:context.bzl",
26+
"//go/private:context.bzl",
2727
_go_context = "go_context",
2828
)
2929
load(
30-
"@io_bazel_rules_go//go/private:providers.bzl",
30+
"//go/private:providers.bzl",
3131
_GoArchive = "GoArchive",
3232
_GoArchiveData = "GoArchiveData",
3333
_GoLibrary = "GoLibrary",
@@ -36,38 +36,38 @@ load(
3636
_GoSource = "GoSource",
3737
)
3838
load(
39-
"@io_bazel_rules_go//go/private:rules/sdk.bzl",
39+
"//go/private/rules:sdk.bzl",
4040
_go_sdk = "go_sdk",
4141
)
4242
load(
43-
"@io_bazel_rules_go//go/private:go_toolchain.bzl",
43+
"//go/private:go_toolchain.bzl",
4444
_declare_toolchains = "declare_toolchains",
4545
_go_toolchain = "go_toolchain",
4646
)
4747
load(
48-
"@io_bazel_rules_go//go/private:rules/wrappers.bzl",
48+
"//go/private/rules:wrappers.bzl",
4949
_go_binary_macro = "go_binary_macro",
5050
_go_library_macro = "go_library_macro",
5151
_go_test_macro = "go_test_macro",
5252
)
5353
load(
54-
"@io_bazel_rules_go//go/private:rules/source.bzl",
54+
"//go/private/rules:source.bzl",
5555
_go_source = "go_source",
5656
)
5757
load(
58-
"@io_bazel_rules_go//extras:embed_data.bzl",
58+
"//extras:embed_data.bzl",
5959
_go_embed_data = "go_embed_data",
6060
)
6161
load(
62-
"@io_bazel_rules_go//go/private:tools/path.bzl",
62+
"//go/private/tools:path.bzl",
6363
_go_path = "go_path",
6464
)
6565
load(
66-
"@io_bazel_rules_go//go/private:rules/library.bzl",
66+
"//go/private/rules:library.bzl",
6767
_go_tool_library = "go_tool_library",
6868
)
6969
load(
70-
"@io_bazel_rules_go//go/private:rules/nogo.bzl",
70+
"//go/private/rules:nogo.bzl",
7171
_nogo = "nogo_wrapper",
7272
)
7373

go/platform/BUILD.bazel

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
2+
13
# This file declares a config_setting for each platform supported by the
24
# Go SDK. These rules follow a goos_goarch naming convention, for example,
35
# //go/platform:linux_amd64
@@ -23,3 +25,14 @@ filegroup(
2325
srcs = glob(["**"]),
2426
visibility = ["//visibility:public"],
2527
)
28+
29+
bzl_library(
30+
name = "list",
31+
srcs = ["list.bzl"],
32+
deps = ["@io_bazel_rules_go//go/private:platforms"],
33+
)
34+
35+
bzl_library(
36+
name = "apple",
37+
srcs = ["apple.bzl"],
38+
)

go/private/BUILD.bazel

Lines changed: 116 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,25 @@
1+
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
2+
13
filegroup(
24
name = "all_rules",
3-
srcs = glob(["**/*.bzl"]),
5+
srcs = [
6+
"//go/private/actions:all_rules",
7+
"//go/private/rules:all_rules",
8+
"//go/private/skylib/lib:all_rules",
9+
"//go/private/tools:all_rules",
10+
] + glob(["**/*.bzl"]),
411
visibility = ["//visibility:public"],
512
)
613

714
filegroup(
815
name = "all_files",
916
testonly = True,
10-
srcs = glob(["**"]),
17+
srcs = [
18+
"//go/private/actions:all_files",
19+
"//go/private/rules:all_files",
20+
"//go/private/skylib/lib:all_files",
21+
"//go/private/tools:all_files",
22+
] + glob(["**"]),
1123
visibility = ["//visibility:public"],
1224
)
1325

@@ -30,3 +42,105 @@ config_setting(
3042
name = "stamp",
3143
values = {"stamp": "true"},
3244
)
45+
46+
bzl_library(
47+
name = "context",
48+
srcs = ["context.bzl"],
49+
visibility = [
50+
"//extras:__pkg__", # Manually added
51+
"//go:__subpackages__",
52+
],
53+
deps = [
54+
":common",
55+
":mode",
56+
":providers",
57+
"//go/platform:apple",
58+
"@bazel_skylib//lib:paths",
59+
"@bazel_skylib//rules:common_settings",
60+
"@bazel_tools//tools/build_defs/cc:action_names.bzl",
61+
"@bazel_tools//tools/cpp:toolchain_utils.bzl",
62+
],
63+
)
64+
65+
bzl_library(
66+
name = "go_toolchain",
67+
srcs = ["go_toolchain.bzl"],
68+
visibility = ["//go:__subpackages__"],
69+
deps = [
70+
"@io_bazel_rules_go//go/private:platforms",
71+
"@io_bazel_rules_go//go/private:providers",
72+
"@io_bazel_rules_go//go/private/actions:archive",
73+
"@io_bazel_rules_go//go/private/actions:asm",
74+
"@io_bazel_rules_go//go/private/actions:binary",
75+
"@io_bazel_rules_go//go/private/actions:compile",
76+
"@io_bazel_rules_go//go/private/actions:cover",
77+
"@io_bazel_rules_go//go/private/actions:link",
78+
"@io_bazel_rules_go//go/private/actions:pack",
79+
"@io_bazel_rules_go//go/private/actions:stdlib",
80+
],
81+
)
82+
83+
bzl_library(
84+
name = "repositories",
85+
srcs = ["repositories.bzl"],
86+
visibility = ["//go:__subpackages__"],
87+
# Don't list dependency on @bazel_tools//tools/build_defs/repo:http.bzl
88+
deps = [
89+
":common",
90+
":nogo",
91+
"//go/private/skylib/lib:versions",
92+
"//proto:gogo",
93+
], # keep
94+
)
95+
96+
bzl_library(
97+
name = "sdk",
98+
srcs = ["sdk.bzl"],
99+
visibility = ["//go:__subpackages__"],
100+
deps = [
101+
"@io_bazel_rules_go//go/private:common",
102+
"@io_bazel_rules_go//go/private:nogo",
103+
"@io_bazel_rules_go//go/private:platforms",
104+
"@io_bazel_rules_go//go/private:sdk_list",
105+
"@io_bazel_rules_go//go/private/skylib/lib:versions",
106+
],
107+
)
108+
109+
bzl_library(
110+
name = "common",
111+
srcs = ["common.bzl"],
112+
visibility = ["//go:__subpackages__"],
113+
)
114+
115+
bzl_library(
116+
name = "mode",
117+
srcs = ["mode.bzl"],
118+
visibility = ["//go:__subpackages__"],
119+
)
120+
121+
bzl_library(
122+
name = "nogo",
123+
srcs = ["nogo.bzl"],
124+
visibility = ["//go:__subpackages__"],
125+
)
126+
127+
bzl_library(
128+
name = "platforms",
129+
srcs = ["platforms.bzl"],
130+
visibility = ["//go:__subpackages__"],
131+
)
132+
133+
bzl_library(
134+
name = "providers",
135+
srcs = ["providers.bzl"],
136+
visibility = [
137+
"//go:__subpackages__",
138+
"//proto:__pkg__", # keep
139+
],
140+
)
141+
142+
bzl_library(
143+
name = "sdk_list",
144+
srcs = ["sdk_list.bzl"],
145+
visibility = ["//go:__subpackages__"],
146+
)

go/private/BUILD.sdk.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
load("@io_bazel_rules_go//go/private:rules/binary.bzl", "go_tool_binary")
2-
load("@io_bazel_rules_go//go/private:rules/sdk.bzl", "package_list")
1+
load("@io_bazel_rules_go//go/private/rules:binary.bzl", "go_tool_binary")
2+
load("@io_bazel_rules_go//go/private/rules:sdk.bzl", "package_list")
33
load("@io_bazel_rules_go//go:def.bzl", "declare_toolchains", "go_sdk")
44

55
package(default_visibility = ["//visibility:public"])

0 commit comments

Comments
 (0)