Skip to content

Commit

Permalink
Use repo-relative labels everywhere
Browse files Browse the repository at this point in the history
This makes it possible to load gazelle under any repo name, not
necessarily bazel_gazelle. This opens up the possibility to call the
gazelle Bazel module "gazelle".
  • Loading branch information
fmeum committed Jul 1, 2022
1 parent 75b35c8 commit f1b4e7b
Show file tree
Hide file tree
Showing 11 changed files with 140 additions and 140 deletions.
8 changes: 4 additions & 4 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ bzl_library(
srcs = ["deps.bzl"],
visibility = ["//visibility:public"],
deps = [
"@bazel_gazelle//internal:go_repository",
"@bazel_gazelle//internal:go_repository_cache",
"@bazel_gazelle//internal:go_repository_config",
"@bazel_gazelle//internal:go_repository_tools",
"//internal:go_repository",
"//internal:go_repository_cache",
"//internal:go_repository_config",
"//internal:go_repository_tools",
"@bazel_tools//tools/build_defs/repo:git.bzl",
],
)
2 changes: 1 addition & 1 deletion cmd/gazelle/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
load("@bazel_gazelle//:def.bzl", "DEFAULT_LANGUAGES", "gazelle_binary")
load("//:def.bzl", "DEFAULT_LANGUAGES", "gazelle_binary")

gazelle_binary(
name = "gazelle",
Expand Down
8 changes: 4 additions & 4 deletions def.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ gazelle_binary = _gazelle_binary
gazelle_generation_test = _gazelle_generation_test

DEFAULT_LANGUAGES = [
"@bazel_gazelle//language/proto:go_default_library",
"@bazel_gazelle//language/go:go_default_library",
Label("//language/proto:go_default_library"),
Label("//language/go:go_default_library"),
]

def _gazelle_runner_impl(ctx):
Expand Down Expand Up @@ -94,7 +94,7 @@ _gazelle_runner = rule(
implementation = _gazelle_runner_impl,
attrs = {
"gazelle": attr.label(
default = "@bazel_gazelle//cmd/gazelle",
default = "//cmd/gazelle",
executable = True,
cfg = "host",
),
Expand All @@ -119,7 +119,7 @@ _gazelle_runner = rule(
"extra_args": attr.string_list(),
"data": attr.label_list(allow_files = True),
"_template": attr.label(
default = "@bazel_gazelle//internal:gazelle.bash.in",
default = "//internal:gazelle.bash.in",
allow_single_file = True,
),
},
Expand Down
8 changes: 4 additions & 4 deletions deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ load(
"git_repository",
)
load(
"@bazel_gazelle//internal:go_repository.bzl",
"//internal:go_repository.bzl",
_go_repository = "go_repository",
)
load(
"@bazel_gazelle//internal:go_repository_cache.bzl",
"//internal:go_repository_cache.bzl",
"go_repository_cache",
)
load(
"@bazel_gazelle//internal:go_repository_tools.bzl",
"//internal:go_repository_tools.bzl",
"go_repository_tools",
)
load(
"@bazel_gazelle//internal:go_repository_config.bzl",
"//internal:go_repository_config.bzl",
"go_repository_config",
)

Expand Down
10 changes: 5 additions & 5 deletions internal/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ go_bazel_test(
"runner_test.go",
],
rule_files = [
"@bazel_gazelle//:all_files",
"//:all_files",
"@io_bazel_rules_go//:all_files",
],
deps = ["//testtools"],
Expand Down Expand Up @@ -72,7 +72,7 @@ bzl_library(
visibility = ["//:__subpackages__"],
deps = [
":common",
"@bazel_gazelle//internal:go_repository_cache",
"//internal:go_repository_cache",
"@bazel_tools//tools/build_defs/repo:utils.bzl",
],
)
Expand All @@ -90,7 +90,7 @@ bzl_library(
visibility = ["//:__subpackages__"],
deps = [
":common",
"@bazel_gazelle//internal:go_repository_cache",
"//internal:go_repository_cache",
],
)

Expand All @@ -100,8 +100,8 @@ bzl_library(
visibility = ["//:__subpackages__"],
deps = [
":common",
"@bazel_gazelle//internal:go_repository_cache",
"@bazel_gazelle//internal:go_repository_tools_srcs",
"//internal:go_repository_cache",
"//internal:go_repository_tools_srcs",
],
)

Expand Down
2 changes: 1 addition & 1 deletion internal/go_repository.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

load("//internal:common.bzl", "env_execute", "executable_extension")
load("@bazel_gazelle//internal:go_repository_cache.bzl", "read_cache_env")
load("//internal:go_repository_cache.bzl", "read_cache_env")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "read_netrc", "use_netrc")

_DOC = """
Expand Down
10 changes: 5 additions & 5 deletions internal/go_repository_config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

load("//internal:common.bzl", "env_execute", "executable_extension")
load("@bazel_gazelle//internal:go_repository_cache.bzl", "read_cache_env")
load("//internal:go_repository_cache.bzl", "read_cache_env")

def _go_repository_config_impl(ctx):
# Locate and resolve configuration files. Gazelle reads directives and
Expand Down Expand Up @@ -47,10 +47,10 @@ def _go_repository_config_impl(ctx):

else:
ctx.file(
"WORKSPACE",
"",
False,
)
"WORKSPACE",
"",
False,
)

# add an empty build file so Bazel recognizes the config
ctx.file(
Expand Down
8 changes: 4 additions & 4 deletions internal/go_repository_tools.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
# limitations under the License.

load("//internal:common.bzl", "env_execute", "executable_extension")
load("@bazel_gazelle//internal:go_repository_cache.bzl", "read_cache_env")
load("@bazel_gazelle//internal:go_repository_tools_srcs.bzl", "GO_REPOSITORY_TOOLS_SRCS")
load("//internal:go_repository_cache.bzl", "read_cache_env")
load("//internal:go_repository_tools_srcs.bzl", "GO_REPOSITORY_TOOLS_SRCS")

_GO_REPOSITORY_TOOLS_BUILD_FILE = """
package(default_visibility = ["//visibility:public"])
Expand Down Expand Up @@ -44,7 +44,7 @@ def _go_repository_tools_impl(ctx):
go_tool = env["GOROOT"] + "/bin/go" + extension

ctx.symlink(
ctx.path(Label("@bazel_gazelle//:WORKSPACE")).dirname,
ctx.path(Label("//:WORKSPACE")).dirname,
"src/github.com/bazelbuild/bazel-gazelle",
)

Expand Down Expand Up @@ -125,7 +125,7 @@ go_repository_tools = repository_rule(
default = GO_REPOSITORY_TOOLS_SRCS,
),
"_list_repository_tools_srcs": attr.label(
default = "@bazel_gazelle//internal:list_repository_tools_srcs.go",
default = "//internal:list_repository_tools_srcs.go",
),
},
environ = [
Expand Down
216 changes: 108 additions & 108 deletions internal/go_repository_tools_srcs.bzl
Original file line number Diff line number Diff line change
@@ -1,112 +1,112 @@
# Code generated by list_repository_tools_srcs.go; DO NOT EDIT.
# regenerate with `go run internal/list_repository_tools_srcs.go -dir $PWD -generate internal/go_repository_tools_srcs.bzl`
GO_REPOSITORY_TOOLS_SRCS = [
"@bazel_gazelle//:BUILD.bazel",
"@bazel_gazelle//cmd:BUILD.bazel",
"@bazel_gazelle//cmd/autogazelle:BUILD.bazel",
"@bazel_gazelle//cmd/autogazelle:autogazelle.go",
"@bazel_gazelle//cmd/autogazelle:client_unix.go",
"@bazel_gazelle//cmd/autogazelle:server_unix.go",
"@bazel_gazelle//cmd/fetch_repo:BUILD.bazel",
"@bazel_gazelle//cmd/fetch_repo:fetch_repo.go",
"@bazel_gazelle//cmd/fetch_repo:module.go",
"@bazel_gazelle//cmd/fetch_repo:vcs.go",
"@bazel_gazelle//cmd/gazelle:BUILD.bazel",
"@bazel_gazelle//cmd/gazelle:diff.go",
"@bazel_gazelle//cmd/gazelle:fix-update.go",
"@bazel_gazelle//cmd/gazelle:fix.go",
"@bazel_gazelle//cmd/gazelle:gazelle.go",
"@bazel_gazelle//cmd/gazelle:langs.go",
"@bazel_gazelle//cmd/gazelle:metaresolver.go",
"@bazel_gazelle//cmd/gazelle:print.go",
"@bazel_gazelle//cmd/gazelle:update-repos.go",
"@bazel_gazelle//cmd/generate_repo_config:BUILD.bazel",
"@bazel_gazelle//cmd/generate_repo_config:generate_repo_config.go",
"@bazel_gazelle//cmd/move_labels:BUILD.bazel",
"@bazel_gazelle//cmd/move_labels:move_labels.go",
"@bazel_gazelle//config:BUILD.bazel",
"@bazel_gazelle//config:config.go",
"@bazel_gazelle//config:constants.go",
"@bazel_gazelle//flag:BUILD.bazel",
"@bazel_gazelle//flag:flag.go",
"@bazel_gazelle//internal:BUILD.bazel",
"@bazel_gazelle//internal/gazellebinarytest:BUILD.bazel",
"@bazel_gazelle//internal/gazellebinarytest:xlang.go",
"@bazel_gazelle//internal/generationtest:BUILD.bazel",
"@bazel_gazelle//internal/language:BUILD.bazel",
"@bazel_gazelle//internal/language/test_filegroup:BUILD.bazel",
"@bazel_gazelle//internal/language/test_filegroup:lang.go",
"@bazel_gazelle//internal:list_repository_tools_srcs.go",
"@bazel_gazelle//internal/version:BUILD.bazel",
"@bazel_gazelle//internal/version:version.go",
"@bazel_gazelle//internal/wspace:BUILD.bazel",
"@bazel_gazelle//internal/wspace:finder.go",
"@bazel_gazelle//label:BUILD.bazel",
"@bazel_gazelle//label:label.go",
"@bazel_gazelle//language:BUILD.bazel",
"@bazel_gazelle//language/go:BUILD.bazel",
"@bazel_gazelle//language/go:config.go",
"@bazel_gazelle//language/go:constants.go",
"@bazel_gazelle//language/go:dep.go",
"@bazel_gazelle//language/go:embed.go",
"@bazel_gazelle//language/go:fileinfo.go",
"@bazel_gazelle//language/go:fix.go",
"@bazel_gazelle//language/go/gen_std_package_list:BUILD.bazel",
"@bazel_gazelle//language/go/gen_std_package_list:gen_std_package_list.go",
"@bazel_gazelle//language/go:generate.go",
"@bazel_gazelle//language/go:godep.go",
"@bazel_gazelle//language/go:kinds.go",
"@bazel_gazelle//language/go:lang.go",
"@bazel_gazelle//language/go:modules.go",
"@bazel_gazelle//language/go:package.go",
"@bazel_gazelle//language/go:resolve.go",
"@bazel_gazelle//language/go:std_package_list.go",
"@bazel_gazelle//language/go:update.go",
"@bazel_gazelle//language/go:utils.go",
"@bazel_gazelle//language/go:work.go",
"@bazel_gazelle//language:lang.go",
"@bazel_gazelle//language/proto:BUILD.bazel",
"@bazel_gazelle//language/proto:config.go",
"@bazel_gazelle//language/proto:constants.go",
"@bazel_gazelle//language/proto:fileinfo.go",
"@bazel_gazelle//language/proto:fix.go",
"@bazel_gazelle//language/proto/gen:BUILD.bazel",
"@bazel_gazelle//language/proto/gen:gen_known_imports.go",
"@bazel_gazelle//language/proto/gen:update_proto_csv.go",
"@bazel_gazelle//language/proto:generate.go",
"@bazel_gazelle//language/proto:kinds.go",
"@bazel_gazelle//language/proto:known_go_imports.go",
"@bazel_gazelle//language/proto:known_imports.go",
"@bazel_gazelle//language/proto:known_proto_imports.go",
"@bazel_gazelle//language/proto:lang.go",
"@bazel_gazelle//language/proto:package.go",
"@bazel_gazelle//language/proto:resolve.go",
"@bazel_gazelle//language:update.go",
"@bazel_gazelle//merger:BUILD.bazel",
"@bazel_gazelle//merger:fix.go",
"@bazel_gazelle//merger:merger.go",
"@bazel_gazelle//pathtools:BUILD.bazel",
"@bazel_gazelle//pathtools:path.go",
"@bazel_gazelle//repo:BUILD.bazel",
"@bazel_gazelle//repo:remote.go",
"@bazel_gazelle//repo:repo.go",
"@bazel_gazelle//resolve:BUILD.bazel",
"@bazel_gazelle//resolve:config.go",
"@bazel_gazelle//resolve:index.go",
"@bazel_gazelle//rule:BUILD.bazel",
"@bazel_gazelle//rule:directives.go",
"@bazel_gazelle//rule:expr.go",
"@bazel_gazelle//rule:merge.go",
"@bazel_gazelle//rule:platform.go",
"@bazel_gazelle//rule:platform_strings.go",
"@bazel_gazelle//rule:rule.go",
"@bazel_gazelle//rule:sort_labels.go",
"@bazel_gazelle//rule:types.go",
"@bazel_gazelle//rule:value.go",
"@bazel_gazelle//testtools:BUILD.bazel",
"@bazel_gazelle//testtools:config.go",
"@bazel_gazelle//testtools:files.go",
"@bazel_gazelle//walk:BUILD.bazel",
"@bazel_gazelle//walk:config.go",
"@bazel_gazelle//walk:walk.go",
Label("//BUILD.bazel"),
Label("//cmd:BUILD.bazel"),
Label("//cmd/autogazelle:BUILD.bazel"),
Label("//cmd/autogazelle:autogazelle.go"),
Label("//cmd/autogazelle:client_unix.go"),
Label("//cmd/autogazelle:server_unix.go"),
Label("//cmd/fetch_repo:BUILD.bazel"),
Label("//cmd/fetch_repo:fetch_repo.go"),
Label("//cmd/fetch_repo:module.go"),
Label("//cmd/fetch_repo:vcs.go"),
Label("//cmd/gazelle:BUILD.bazel"),
Label("//cmd/gazelle:diff.go"),
Label("//cmd/gazelle:fix-update.go"),
Label("//cmd/gazelle:fix.go"),
Label("//cmd/gazelle:gazelle.go"),
Label("//cmd/gazelle:langs.go"),
Label("//cmd/gazelle:metaresolver.go"),
Label("//cmd/gazelle:print.go"),
Label("//cmd/gazelle:update-repos.go"),
Label("//cmd/generate_repo_config:BUILD.bazel"),
Label("//cmd/generate_repo_config:generate_repo_config.go"),
Label("//cmd/move_labels:BUILD.bazel"),
Label("//cmd/move_labels:move_labels.go"),
Label("//config:BUILD.bazel"),
Label("//config:config.go"),
Label("//config:constants.go"),
Label("//flag:BUILD.bazel"),
Label("//flag:flag.go"),
Label("//internal:BUILD.bazel"),
Label("//internal/gazellebinarytest:BUILD.bazel"),
Label("//internal/gazellebinarytest:xlang.go"),
Label("//internal/generationtest:BUILD.bazel"),
Label("//internal/language:BUILD.bazel"),
Label("//internal/language/test_filegroup:BUILD.bazel"),
Label("//internal/language/test_filegroup:lang.go"),
Label("//internal:list_repository_tools_srcs.go"),
Label("//internal/version:BUILD.bazel"),
Label("//internal/version:version.go"),
Label("//internal/wspace:BUILD.bazel"),
Label("//internal/wspace:finder.go"),
Label("//label:BUILD.bazel"),
Label("//label:label.go"),
Label("//language:BUILD.bazel"),
Label("//language/go:BUILD.bazel"),
Label("//language/go:config.go"),
Label("//language/go:constants.go"),
Label("//language/go:dep.go"),
Label("//language/go:embed.go"),
Label("//language/go:fileinfo.go"),
Label("//language/go:fix.go"),
Label("//language/go/gen_std_package_list:BUILD.bazel"),
Label("//language/go/gen_std_package_list:gen_std_package_list.go"),
Label("//language/go:generate.go"),
Label("//language/go:godep.go"),
Label("//language/go:kinds.go"),
Label("//language/go:lang.go"),
Label("//language/go:modules.go"),
Label("//language/go:package.go"),
Label("//language/go:resolve.go"),
Label("//language/go:std_package_list.go"),
Label("//language/go:update.go"),
Label("//language/go:utils.go"),
Label("//language/go:work.go"),
Label("//language:lang.go"),
Label("//language/proto:BUILD.bazel"),
Label("//language/proto:config.go"),
Label("//language/proto:constants.go"),
Label("//language/proto:fileinfo.go"),
Label("//language/proto:fix.go"),
Label("//language/proto/gen:BUILD.bazel"),
Label("//language/proto/gen:gen_known_imports.go"),
Label("//language/proto/gen:update_proto_csv.go"),
Label("//language/proto:generate.go"),
Label("//language/proto:kinds.go"),
Label("//language/proto:known_go_imports.go"),
Label("//language/proto:known_imports.go"),
Label("//language/proto:known_proto_imports.go"),
Label("//language/proto:lang.go"),
Label("//language/proto:package.go"),
Label("//language/proto:resolve.go"),
Label("//language:update.go"),
Label("//merger:BUILD.bazel"),
Label("//merger:fix.go"),
Label("//merger:merger.go"),
Label("//pathtools:BUILD.bazel"),
Label("//pathtools:path.go"),
Label("//repo:BUILD.bazel"),
Label("//repo:remote.go"),
Label("//repo:repo.go"),
Label("//resolve:BUILD.bazel"),
Label("//resolve:config.go"),
Label("//resolve:index.go"),
Label("//rule:BUILD.bazel"),
Label("//rule:directives.go"),
Label("//rule:expr.go"),
Label("//rule:merge.go"),
Label("//rule:platform.go"),
Label("//rule:platform_strings.go"),
Label("//rule:rule.go"),
Label("//rule:sort_labels.go"),
Label("//rule:types.go"),
Label("//rule:value.go"),
Label("//testtools:BUILD.bazel"),
Label("//testtools:config.go"),
Label("//testtools:files.go"),
Label("//walk:BUILD.bazel"),
Label("//walk:config.go"),
Label("//walk:walk.go"),
]
Loading

0 comments on commit f1b4e7b

Please sign in to comment.