Skip to content

Commit

Permalink
Apply buildifier fixes (#3142)
Browse files Browse the repository at this point in the history
* Apply buildifier format/lint fixes
  • Loading branch information
fmeum authored May 5, 2022
1 parent a20046b commit a2677c2
Show file tree
Hide file tree
Showing 37 changed files with 64 additions and 66 deletions.
8 changes: 4 additions & 4 deletions extras/gomock.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@ def _gomock_reflect(name, library, out, mockgen_tool, **kwargs):

def _gomock_prog_gen_impl(ctx):
args = ["-prog_only"]
args += [ctx.attr.library[GoLibrary].importpath]
args += [",".join(ctx.attr.interfaces)]
args.append(ctx.attr.library[GoLibrary].importpath)
args.append(",".join(ctx.attr.interfaces))

cmd = ctx.file.mockgen_tool
out = ctx.outputs.out
Expand Down Expand Up @@ -286,8 +286,8 @@ def _gomock_prog_exec_impl(ctx):

# annoyingly, the interfaces join has to go after the importpath so we can't
# share those.
args += [ctx.attr.library[GoLibrary].importpath]
args += [",".join(ctx.attr.interfaces)]
args.append(ctx.attr.library[GoLibrary].importpath)
args.append(",".join(ctx.attr.interfaces))

ctx.actions.run_shell(
outputs = [ctx.outputs.out],
Expand Down
2 changes: 1 addition & 1 deletion go/private/BUILD.nogo.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package(default_visibility = [ "//visibility:public" ])
package(default_visibility = ["//visibility:public"])

alias(
name = "nogo",
Expand Down
21 changes: 12 additions & 9 deletions go/private/BUILD.sdk.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,23 @@ filegroup(

filegroup(
name = "tools",
srcs = glob(["pkg/tool/**", "bin/gofmt*"])
srcs = glob([
"pkg/tool/**",
"bin/gofmt*",
]),
)

go_sdk(
name = "go_sdk",
goos = "{goos}",
srcs = [":srcs"],
go = "bin/go{exe}",
goarch = "{goarch}",
root_file = "ROOT",
package_list = ":package_list",
libs = [":libs"],
goos = "{goos}",
headers = [":headers"],
srcs = [":srcs"],
libs = [":libs"],
package_list = ":package_list",
root_file = "ROOT",
tools = [":tools"],
go = "bin/go{exe}",
)

go_tool_binary(
Expand All @@ -51,14 +54,14 @@ go_tool_binary(
package_list(
name = "package_list",
srcs = [":srcs"],
root_file = "ROOT",
out = "packages.txt",
root_file = "ROOT",
)

declare_toolchains(
builder = ":builder",
host = "{goos}_{goarch}",
sdk = ":go_sdk",
builder = ":builder",
)

filegroup(
Expand Down
2 changes: 1 addition & 1 deletion go/private/actions/archive.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def emit_archive(go, source = None, _recompile_suffix = ""):
runfiles = source.runfiles
data_files = runfiles.files

# After bazel version 5.0.0, skylark introduced a new API called merge_all().
# After bazel version 5.0.0, starlark introduced a new API called merge_all().
# There is a recommendation in the release notes to use merge_all() if we hit
# the depth limit because of using merge() in a loop; we saw some repositories
# hitting this issue after upgrading to 5.0.0. To keep it backward compatible,
Expand Down
6 changes: 3 additions & 3 deletions go/tools/bazel_testing/def.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def go_bazel_test(rule_files = None, **kwargs):

bazel_testing_library = "@io_bazel_rules_go//go/tools/bazel_testing"
if bazel_testing_library not in kwargs["deps"]:
kwargs["deps"] += [bazel_testing_library]
kwargs["deps"].append(bazel_testing_library)

# Add data dependency on rules_go files. bazel_testing will copy or link
# these files in an external repo.
Expand All @@ -55,8 +55,8 @@ def go_bazel_test(rule_files = None, **kwargs):
# much slower.
kwargs.setdefault("tags", [])
if "local" not in kwargs["tags"]:
kwargs["tags"] += ["local"]
kwargs["tags"].append("local")
if "exclusive" not in kwargs["tags"]:
kwargs["tags"] += ["exclusive"]
kwargs["tags"].append("exclusive")

go_test(**kwargs)
2 changes: 1 addition & 1 deletion tests/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ load(":buildifier_test.bzl", "buildifier_test")

buildifier_test(
name = "buildifier_test",
size = "small",
data = [
":buildifier_test.bzl",
"//:all_files",
],
size = "small",
)
1 change: 0 additions & 1 deletion tests/core/coverage/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library", "go_test")
load("@io_bazel_rules_go//go/tools/bazel_testing:def.bzl", "go_bazel_test")

go_bazel_test(
Expand Down
2 changes: 1 addition & 1 deletion tests/core/cross/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library", "go_source", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library", "go_test")
load("@io_bazel_rules_go//go/tools/bazel_testing:def.bzl", "go_bazel_test")
load(":def.bzl", "no_context_info")

Expand Down
2 changes: 1 addition & 1 deletion tests/core/go_binary/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ go_binary(
go_test(
name = "pie_test",
srcs = [
"pie_darwin_test.go",
"pie_darwin_amd64_test.go",
"pie_darwin_test.go",
"pie_linux_test.go",
],
data = select({
Expand Down
2 changes: 1 addition & 1 deletion tests/core/go_path/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ go_test(
":nodata_path",
":notransitive_path",
],
deps = ["//go/tools/bazel:go_default_library"],
rundir = ".",
deps = ["//go/tools/bazel:go_default_library"],
)
4 changes: 2 additions & 2 deletions tests/core/go_path/pkg/lib/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ go_library(
"data.txt",
"testdata/testdata.txt",
],
deps = [":transitive_lib"],
importpath = "example.com/repo/pkg/lib",
visibility = ["//visibility:public"],
deps = [":transitive_lib"],
)

go_test(
Expand Down Expand Up @@ -39,8 +39,8 @@ go_library(
go_library(
name = "vendored",
srcs = ["vendored.go"],
importpath = "example.com/repo2",
importmap = "example.com/repo/vendor/example.com/repo2",
importpath = "example.com/repo2",
visibility = ["//visibility:public"],
)

Expand Down
6 changes: 3 additions & 3 deletions tests/core/go_plugin_with_proto_library/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_test", "go_library")
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_test")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")

test_suite(name = "go_plugin_with_proto_library")
Expand All @@ -14,8 +14,8 @@ go_binary(
name = "plugin",
srcs = ["plugin.go"],
out = "plugin.so",
deps = [":validate"],
linkmode = "plugin",
deps = [":validate"],
)

proto_library(
Expand All @@ -25,7 +25,7 @@ proto_library(

go_proto_library(
name = "validate",
gc_goopts = ["-trimpath=$(BINDIR)=>."],
importpath = "go_plugin_with_proto_library/validate",
proto = ":validate_proto",
gc_goopts = ["-trimpath=$(BINDIR)=>."],
)
1 change: 0 additions & 1 deletion tests/core/race/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary")
load("@io_bazel_rules_go//go/tools/bazel_testing:def.bzl", "go_bazel_test")

go_bazel_test(
Expand Down
2 changes: 1 addition & 1 deletion tests/core/starlark/packagedriver/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load(":go_pkg_info_aspect_test.bzl", "package_driver_suite")

package_driver_suite(
name = "package_driver_test"
name = "package_driver_test",
)
1 change: 0 additions & 1 deletion tests/core/starlark/packagedriver/fixtures/a/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ go_library(
importpath = "example.com/a",
visibility = ["//tests/core/starlark/packagedriver:__subpackages__"],
)

Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
load("@bazel_skylib//lib:unittest.bzl", "asserts", "analysistest")
load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts")
load("//go/tools/gopackagesdriver:aspect.bzl", "go_pkg_info_aspect")


def _package_driver_pkg_json_test_impl(ctx):
env = analysistest.begin(ctx)

Expand Down
2 changes: 1 addition & 1 deletion tests/core/stdlib/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ load(":stdlib_files.bzl", "stdlib_files")
go_test(
name = "buildid_test",
srcs = ["buildid_test.go"],
rundir = ".",
data = [":stdlib_files"],
rundir = ".",
)

stdlib_files(name = "stdlib_files")
1 change: 0 additions & 1 deletion tests/core/stdlib/stdlib_files.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

load("//go:def.bzl", "go_context")
load("//go/private:providers.bzl", "GoStdLib")

def _pure_transition_impl(settings, attr):
Expand Down
4 changes: 2 additions & 2 deletions tests/examples/executable_name/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_test", "go_source")
load("@io_bazel_rules_go//go:def.bzl", "go_binary")

go_binary(
name = "some_binary",
Expand All @@ -16,5 +16,5 @@ sh_test(
name = "executable_name",
size = "small",
srcs = ["name_test.sh"],
data = [ ":normalised_binary" ],
data = [":normalised_binary"],
)
4 changes: 2 additions & 2 deletions tests/legacy/examples/bin/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary")

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

load("@io_bazel_rules_go//go:def.bzl", "go_binary")

go_binary(
name = "bin",
srcs = ["bin.go"],
Expand Down
4 changes: 2 additions & 2 deletions tests/legacy/examples/cgo/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

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

load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
name = "go_default_library",
srcs = [
Expand Down
5 changes: 4 additions & 1 deletion tests/legacy/examples/cgo/cc_dependency/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ cc_library(

cc_binary(
name = "c_version_so",
srcs = ["c_version.c", "c_version.h"],
srcs = [
"c_version.c",
"c_version.h",
],
linkshared = True,
)

Expand Down
6 changes: 3 additions & 3 deletions tests/legacy/examples/cgo/example_command/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary")
load(":generate_test.bzl", "generate_script")

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

load("@io_bazel_rules_go//go:def.bzl", "go_binary")
load(":generate_test.bzl", "generate_script")

go_binary(
name = "example_command",
srcs = ["main.go"],
Expand Down
4 changes: 2 additions & 2 deletions tests/legacy/examples/cgo/skip_go_library/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package(default_visibility = ["//visibility:public"])

load("@io_bazel_rules_go//go:def.bzl", "go_library")

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

go_library(
name = "go_default_library",
srcs = [
Expand Down
4 changes: 2 additions & 2 deletions tests/legacy/examples/lib/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

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

load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
name = "go_default_library",
srcs = [
Expand Down
4 changes: 2 additions & 2 deletions tests/legacy/examples/lib/deep/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package(default_visibility = ["//tests/legacy/examples/lib:__pkg__"])

load("@io_bazel_rules_go//go:def.bzl", "go_library")

package(default_visibility = ["//tests/legacy/examples/lib:__pkg__"])

go_library(
name = "go_default_library",
srcs = [
Expand Down
4 changes: 2 additions & 2 deletions tests/legacy/examples/monobuild/cmd/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary")

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

load("@io_bazel_rules_go//go:def.bzl", "go_binary")

go_binary(
name = "mycmd",
srcs = ["mycmd.go"],
Expand Down
4 changes: 2 additions & 2 deletions tests/legacy/examples/monobuild/lib1/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package(default_visibility = ["//tests/legacy/examples/monobuild/cmd:__pkg__"])

load("@io_bazel_rules_go//go:def.bzl", "go_library")

package(default_visibility = ["//tests/legacy/examples/monobuild/cmd:__pkg__"])

go_library(
name = "go_default_library",
srcs = [
Expand Down
4 changes: 2 additions & 2 deletions tests/legacy/examples/monobuild/lib2/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package(default_visibility = ["//tests/legacy/examples/monobuild/cmd:__pkg__"])

load("@io_bazel_rules_go//go:def.bzl", "go_library")

package(default_visibility = ["//tests/legacy/examples/monobuild/cmd:__pkg__"])

go_library(
name = "go_default_library",
srcs = [
Expand Down
1 change: 0 additions & 1 deletion tests/legacy/examples/proto/dep/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")

Expand Down
2 changes: 1 addition & 1 deletion tests/legacy/examples/proto/gogo/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_test")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")

Expand Down
1 change: 0 additions & 1 deletion tests/legacy/examples/proto/gostyle/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")

Expand Down
2 changes: 1 addition & 1 deletion tests/legacy/examples/proto/grpc/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
load("@io_bazel_rules_go//go:def.bzl", "go_binary")
load("@io_bazel_rules_go//proto:def.bzl", "go_grpc_library", "go_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")

Expand Down
1 change: 0 additions & 1 deletion tests/legacy/examples/proto/lib/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")

Expand Down
Loading

0 comments on commit a2677c2

Please sign in to comment.