Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Also generate import-style targets with Gazelle #1173

Merged
merged 2 commits into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,22 @@ test_suite(
name = "tests",
tests = [
"//api_proto:api.gen.pb.go_checkshtest",
"//build:go_default_test",
"//build:build_test",
"//build_proto:build.gen.pb.go_checkshtest",
"//buildifier:buildifier_integration_test",
"//deps_proto:deps.gen.pb.go_checkshtest",
"//edit:go_default_test",
"//edit:edit_test",
"//extra_actions_base_proto:extra_actions_base.gen.pb.go_checkshtest",
"//labels:go_default_test",
"//labels:labels_test",
"//lang:tables.gen.go_checkshtest",
"//tables:go_default_test",
"//warn:go_default_test",
"//warn/docs:go_default_test",
"//wspace:go_default_test",
"//tables:tables_test",
"//warn:warn_test",
"//warn/docs:docs_test",
"//wspace:wspace_test",
],
)

#gazelle:go_naming_convention import_alias
gazelle(
name = "gazelle",
prefix = "github.com/bazelbuild/buildtools",
Expand Down
8 changes: 7 additions & 1 deletion api_proto/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,14 @@ go_proto_library(
)

go_library(
name = "go_default_library",
name = "api_proto",
embed = [":api_proto_go_proto"],
importpath = "github.com/bazelbuild/buildtools/api_proto",
visibility = ["//visibility:public"],
)

alias(
name = "go_default_library",
actual = ":api_proto",
visibility = ["//visibility:public"],
)
16 changes: 11 additions & 5 deletions build/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ go_yacc(
)

go_library(
name = "go_default_library",
name = "build",
srcs = [
"lex.go",
"parse.y.baz.go", # keep
Expand All @@ -23,12 +23,12 @@ go_library(
importpath = "github.com/bazelbuild/buildtools/build",
visibility = ["//visibility:public"],
deps = [
"//tables:go_default_library",
"//tables",
],
)

go_test(
name = "go_default_test",
name = "build_test",
size = "small",
srcs = [
"checkfile_test.go",
Expand All @@ -49,9 +49,15 @@ go_test(
"rewrite_test_files/original_formatted.star",
"rewrite_test_files/original.star",
],
embed = [":go_default_library"],
embed = [":build"],
deps = [
"//tables:go_default_library",
"//tables",
"//testutils",
],
)

alias(
name = "go_default_library",
actual = ":build",
visibility = ["//visibility:public"],
)
8 changes: 8 additions & 0 deletions build_proto/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
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")
load("//build:build_defs.bzl", "go_proto_checkedin_test")
Expand All @@ -23,3 +24,10 @@ go_proto_library(
proto = ":blaze_query_proto",
visibility = ["//visibility:public"],
)

go_library(
name = "build_proto",
embed = [":go_default_library"],
importpath = "github.com/bazelbuild/buildtools/build_proto",
visibility = ["//visibility:public"],
)
26 changes: 12 additions & 14 deletions buildifier/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")

go_binary(
name = "buildifier",
embed = [":go_default_library"],
embed = [":buildifier_lib"],
visibility = ["//visibility:public"],
)

go_binary(
name = "buildifier-darwin",
out = "buildifier-darwin_amd64",
embed = [":go_default_library"],
embed = [":buildifier_lib"],
goarch = "amd64",
goos = "darwin",
pure = "on",
Expand All @@ -19,7 +19,7 @@ go_binary(
go_binary(
name = "buildifier-linux",
out = "buildifier-linux_amd64",
embed = [":go_default_library"],
embed = [":buildifier_lib"],
goarch = "amd64",
goos = "linux",
pure = "on",
Expand All @@ -29,7 +29,7 @@ go_binary(
go_binary(
name = "buildifier-windows",
out = "buildifier-windows_amd64.exe",
embed = [":go_default_library"],
embed = [":buildifier_lib"],
goarch = "amd64",
goos = "windows",
pure = "on",
Expand All @@ -39,7 +39,7 @@ go_binary(
go_binary(
name = "buildifier-darwin-arm64",
out = "buildifier-darwin_arm64",
embed = [":go_default_library"],
embed = [":buildifier_lib"],
goarch = "arm64",
goos = "darwin",
pure = "on",
Expand All @@ -49,7 +49,7 @@ go_binary(
go_binary(
name = "buildifier-linux-arm64",
out = "buildifier-linux_arm64",
embed = [":go_default_library"],
embed = [":buildifier_lib"],
goarch = "arm64",
goos = "linux",
pure = "on",
Expand All @@ -73,7 +73,7 @@ sh_test(
)

go_library(
name = "go_default_library",
name = "buildifier_lib",
srcs = ["buildifier.go"],
importpath = "github.com/bazelbuild/buildtools/buildifier",
visibility = ["//visibility:private"],
Expand All @@ -82,13 +82,11 @@ go_library(
"main.buildScmRevision": "{STABLE_buildScmRevision}",
},
deps = [
"//build:go_default_library",
"//buildifier/config:go_default_library",
"//buildifier/utils:go_default_library",
"//differ:go_default_library",
"//tables:go_default_library",
"//warn:go_default_library",
"//wspace:go_default_library",
"//build",
"//buildifier/config",
"//buildifier/utils",
"//differ",
"//wspace",
],
)

Expand Down
18 changes: 12 additions & 6 deletions buildifier/config/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
name = "go_default_library",
name = "config",
srcs = [
"config.go",
"validation.go",
],
importpath = "github.com/bazelbuild/buildtools/buildifier/config",
visibility = ["//buildifier:__pkg__"],
deps = [
"//tables:go_default_library",
"//warn:go_default_library",
"//wspace:go_default_library",
"//tables",
"//warn",
"//wspace",
],
)

go_test(
name = "go_default_test",
name = "config_test",
srcs = ["config_test.go"],
embed = [":go_default_library"],
embed = [":config"],
)

alias(
name = "go_default_library",
actual = ":config",
visibility = ["//visibility:public"],
)
16 changes: 11 additions & 5 deletions buildifier/utils/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
name = "go_default_library",
name = "utils",
srcs = [
"diagnostics.go",
"tempfile.go",
Expand All @@ -10,13 +10,19 @@ go_library(
importpath = "github.com/bazelbuild/buildtools/buildifier/utils",
visibility = ["//buildifier:__subpackages__"],
deps = [
"//build:go_default_library",
"//warn:go_default_library",
"//build",
"//warn",
],
)

go_test(
name = "go_default_test",
name = "utils_test",
srcs = ["utils_test.go"],
embed = [":go_default_library"],
embed = [":utils"],
)

alias(
name = "go_default_library",
actual = ":utils",
visibility = ["//visibility:public"],
)
10 changes: 5 additions & 5 deletions buildifier2/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")

go_library(
name = "go_default_library",
name = "buildifier2_lib",
srcs = ["buildifier2.go"],
importpath = "github.com/bazelbuild/buildtools/buildifier2",
visibility = ["//visibility:private"],
deps = [
"//build:go_default_library",
"//convertast:go_default_library",
"@skylark_syntax//syntax:go_default_library",
"//build",
"//convertast",
"@skylark_syntax//syntax",
],
)

go_binary(
name = "buildifier2",
embed = [":go_default_library"],
embed = [":buildifier2_lib"],
visibility = ["//visibility:public"],
)
20 changes: 10 additions & 10 deletions buildozer/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")

go_library(
name = "go_default_library",
name = "buildozer_lib",
srcs = ["main.go"],
importpath = "github.com/bazelbuild/buildtools/buildozer",
visibility = ["//visibility:private"],
Expand All @@ -10,15 +10,15 @@ go_library(
"main.buildScmRevision": "{STABLE_buildScmRevision}",
},
deps = [
"//build:go_default_library",
"//edit:go_default_library",
"//tables:go_default_library",
"//build",
"//edit",
"//tables",
],
)

go_binary(
name = "buildozer",
embed = [":go_default_library"],
embed = [":buildozer_lib"],
visibility = ["//visibility:public"],
)

Expand All @@ -39,7 +39,7 @@ sh_test(
go_binary(
name = "buildozer-darwin",
out = "buildozer-darwin_amd64",
embed = [":go_default_library"],
embed = [":buildozer_lib"],
goarch = "amd64",
goos = "darwin",
pure = "on",
Expand All @@ -49,7 +49,7 @@ go_binary(
go_binary(
name = "buildozer-linux",
out = "buildozer-linux_amd64",
embed = [":go_default_library"],
embed = [":buildozer_lib"],
goarch = "amd64",
goos = "linux",
pure = "on",
Expand All @@ -59,7 +59,7 @@ go_binary(
go_binary(
name = "buildozer-windows",
out = "buildozer-windows_amd64.exe",
embed = [":go_default_library"],
embed = [":buildozer_lib"],
goarch = "amd64",
goos = "windows",
pure = "on",
Expand All @@ -69,7 +69,7 @@ go_binary(
go_binary(
name = "buildozer-darwin-arm64",
out = "buildozer-darwin_arm64",
embed = [":go_default_library"],
embed = [":buildozer_lib"],
goarch = "arm64",
goos = "darwin",
pure = "on",
Expand All @@ -79,7 +79,7 @@ go_binary(
go_binary(
name = "buildozer-linux-arm64",
out = "buildozer-linux_arm64",
embed = [":go_default_library"],
embed = [":buildozer_lib"],
goarch = "arm64",
goos = "linux",
pure = "on",
Expand Down
16 changes: 8 additions & 8 deletions bzlenv/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
name = "go_default_library",
name = "bzlenv",
srcs = ["bzlenv.go"],
importpath = "github.com/bazelbuild/buildtools/bzlenv",
visibility = ["//visibility:public"],
deps = ["//build:go_default_library"],
deps = ["//build"],
)

go_test(
name = "bzlenv_test",
size = "small",
srcs = ["bzlenv_test.go"],
embed = [":go_default_library"],
embed = [":bzlenv"],
deps = ["//build"],
)

go_test(
name = "go_default_test",
srcs = ["bzlenv_test.go"],
embed = [":go_default_library"],
deps = ["//build:go_default_library"],
alias(
name = "go_default_library",
actual = ":bzlenv",
visibility = ["//visibility:public"],
)
8 changes: 7 additions & 1 deletion config/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")

go_library(
name = "go_default_library",
name = "config",
srcs = ["config.go"],
importpath = "github.com/bazelbuild/buildtools/config",
visibility = ["//visibility:public"],
)

alias(
name = "go_default_library",
actual = ":config",
visibility = ["//visibility:public"],
)
Loading