diff --git a/BUILD.bazel b/BUILD.bazel index 40841dfe79..141aa7a520 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -1,13 +1,13 @@ load( - "@io_bazel_rules_go//go/private:tools/lines_sorted_test.bzl", + "@io_bazel_rules_go//go/private/tools:lines_sorted_test.bzl", "lines_sorted_test", ) load( - "@io_bazel_rules_go//go/private:rules/nogo.bzl", + "@io_bazel_rules_go//go/private/rules:nogo.bzl", "nogo", ) load( - "@io_bazel_rules_go//go/private:rules/info.bzl", + "@io_bazel_rules_go//go/private/rules:info.bzl", "go_info", ) load( @@ -22,7 +22,7 @@ load( "go_context_data", ) load( - "@io_bazel_rules_go//go/private:rules/stdlib.bzl", + "@io_bazel_rules_go//go/private/rules:stdlib.bzl", "stdlib", ) diff --git a/WORKSPACE b/WORKSPACE index bc6e2fe127..74897d4269 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -89,6 +89,9 @@ bazel_skylib_workspace() http_archive( name = "bazel_gazelle", + patches = [ + "//third_party:com_google_github_bazel_gazelle-internal-in-their-new-location.patch", + ], sha256 = "d8c45ee70ec39a57e7a05e5027c32b1576cc7f16d9dd37135b0eddde45cf1b10", urls = [ "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.20.0/bazel-gazelle-v0.20.0.tar.gz", diff --git a/extras/BUILD.bazel b/extras/BUILD.bazel index 833cf23633..6f0ca365f1 100644 --- a/extras/BUILD.bazel +++ b/extras/BUILD.bazel @@ -1,3 +1,5 @@ +load("@bazel_skylib//:bzl_library.bzl", "bzl_library") + filegroup( name = "all_rules", srcs = glob(["*.bzl"]) + ["//go/private:all_rules"], @@ -10,3 +12,32 @@ filegroup( srcs = glob(["**"]), visibility = ["//visibility:public"], ) + +bzl_library( + name = "bindata", + srcs = ["bindata.bzl"], + visibility = ["//visibility:public"], + deps = [ + "@io_bazel_rules_go//go:def", + "@io_bazel_rules_go//go/private/rules:rule", + ], +) + +bzl_library( + name = "embed_data", + srcs = ["embed_data.bzl"], + visibility = ["//visibility:public"], + deps = [ + "@io_bazel_rules_go//go/private:context", + "@io_bazel_rules_go//go/private/rules:rule", + ], +) + +bzl_library( + name = "embed_data_deps", + srcs = ["embed_data_deps.bzl"], + visibility = ["//visibility:public"], + deps = [ + #"@bazel_tools//tools/build_defs/repo:git", + ], +) diff --git a/extras/bindata.bzl b/extras/bindata.bzl index 45b73bde3c..e36537c748 100644 --- a/extras/bindata.bzl +++ b/extras/bindata.bzl @@ -19,7 +19,7 @@ load( "go_context", ) load( - "@io_bazel_rules_go//go/private:rules/rule.bzl", + "@io_bazel_rules_go//go/private/rules:rule.bzl", "go_rule", ) diff --git a/extras/embed_data.bzl b/extras/embed_data.bzl index 682e3401b7..1f5780f61c 100644 --- a/extras/embed_data.bzl +++ b/extras/embed_data.bzl @@ -19,7 +19,7 @@ load( "go_context", ) load( - "@io_bazel_rules_go//go/private:rules/rule.bzl", + "@io_bazel_rules_go//go/private/rules:rule.bzl", "go_rule", ) diff --git a/go/BUILD.bazel b/go/BUILD.bazel index 278c269130..8cb732a1f9 100644 --- a/go/BUILD.bazel +++ b/go/BUILD.bazel @@ -1,3 +1,5 @@ +load("@bazel_skylib//:bzl_library.bzl", "bzl_library") + filegroup( name = "all_files", testonly = True, @@ -25,3 +27,32 @@ toolchain_type( name = "toolchain", visibility = ["//visibility:public"], ) + +bzl_library( + name = "def", + srcs = ["def.bzl"], + visibility = ["//visibility:public"], + deps = [ + "@io_bazel_rules_go//extras:embed_data", + "@io_bazel_rules_go//go/private:context", + "@io_bazel_rules_go//go/private:go_toolchain", + "@io_bazel_rules_go//go/private:providers", + "@io_bazel_rules_go//go/private/rules:library", + "@io_bazel_rules_go//go/private/rules:nogo", + "@io_bazel_rules_go//go/private/rules:rule", + "@io_bazel_rules_go//go/private/rules:sdk", + "@io_bazel_rules_go//go/private/rules:source", + "@io_bazel_rules_go//go/private/rules:wrappers", + "@io_bazel_rules_go//go/private/tools:path", + ], +) + +bzl_library( + name = "deps", + srcs = ["deps.bzl"], + visibility = ["//visibility:public"], + deps = [ + "@io_bazel_rules_go//go/private:repositories", + "@io_bazel_rules_go//go/private:sdk", + ], +) diff --git a/go/def.bzl b/go/def.bzl index f0bc1cc5ff..445b434fab 100644 --- a/go/def.bzl +++ b/go/def.bzl @@ -36,7 +36,7 @@ load( _GoSource = "GoSource", ) load( - "@io_bazel_rules_go//go/private:rules/sdk.bzl", + "@io_bazel_rules_go//go/private/rules:sdk.bzl", _go_sdk = "go_sdk", ) load( @@ -45,13 +45,13 @@ load( _go_toolchain = "go_toolchain", ) load( - "@io_bazel_rules_go//go/private:rules/wrappers.bzl", + "@io_bazel_rules_go//go/private/rules:wrappers.bzl", _go_binary_macro = "go_binary_macro", _go_library_macro = "go_library_macro", _go_test_macro = "go_test_macro", ) load( - "@io_bazel_rules_go//go/private:rules/source.bzl", + "@io_bazel_rules_go//go/private/rules:source.bzl", _go_source = "go_source", ) load( @@ -59,19 +59,19 @@ load( _go_embed_data = "go_embed_data", ) load( - "@io_bazel_rules_go//go/private:tools/path.bzl", + "@io_bazel_rules_go//go/private/tools:path.bzl", _go_path = "go_path", ) load( - "@io_bazel_rules_go//go/private:rules/rule.bzl", + "@io_bazel_rules_go//go/private/rules:rule.bzl", _go_rule = "go_rule", ) load( - "@io_bazel_rules_go//go/private:rules/library.bzl", + "@io_bazel_rules_go//go/private/rules:library.bzl", _go_tool_library = "go_tool_library", ) load( - "@io_bazel_rules_go//go/private:rules/nogo.bzl", + "@io_bazel_rules_go//go/private/rules:nogo.bzl", _nogo = "nogo_wrapper", ) diff --git a/go/platform/BUILD.bazel b/go/platform/BUILD.bazel index e65bb65d68..2fc649a48a 100644 --- a/go/platform/BUILD.bazel +++ b/go/platform/BUILD.bazel @@ -1,3 +1,5 @@ +load("@bazel_skylib//:bzl_library.bzl", "bzl_library") + # This file declares a config_setting for each platform supported by the # Go SDK. These rules follow a goos_goarch naming convention, for example, # //go/platform:linux_amd64 @@ -23,3 +25,14 @@ filegroup( srcs = glob(["**"]), visibility = ["//visibility:public"], ) + +bzl_library( + name = "list", + srcs = ["list.bzl"], + deps = ["@io_bazel_rules_go//go/private:platforms"], +) + +bzl_library( + name = "apple", + srcs = ["apple.bzl"], +) diff --git a/go/private/BUILD.bazel b/go/private/BUILD.bazel index 5e393eb388..bd56cc3a36 100644 --- a/go/private/BUILD.bazel +++ b/go/private/BUILD.bazel @@ -1,3 +1,5 @@ +load("@bazel_skylib//:bzl_library.bzl", "bzl_library") + filegroup( name = "all_rules", srcs = glob(["**/*.bzl"]), @@ -30,3 +32,103 @@ config_setting( name = "stamp", values = {"stamp": "true"}, ) + +bzl_library( + name = "context", + srcs = ["context.bzl"], + visibility = [ + "//extras:__pkg__", + "//go:__subpackages__", + ], + deps = [ + "@bazel_skylib//lib:paths", + "@bazel_skylib//rules:common_settings", + #"@bazel_tools//tools/build_defs/cc:action_names", + #"@bazel_tools//tools/cpp:toolchain_utils", + "@io_bazel_rules_go//go/platform:apple", + ], +) + +bzl_library( + name = "go_toolchain", + srcs = ["go_toolchain.bzl"], + visibility = ["//go:__subpackages__"], + deps = [ + "@io_bazel_rules_go//go/private:platforms", + "@io_bazel_rules_go//go/private:providers", + "@io_bazel_rules_go//go/private/actions:archive", + "@io_bazel_rules_go//go/private/actions:asm", + "@io_bazel_rules_go//go/private/actions:binary", + "@io_bazel_rules_go//go/private/actions:compile", + "@io_bazel_rules_go//go/private/actions:cover", + "@io_bazel_rules_go//go/private/actions:link", + "@io_bazel_rules_go//go/private/actions:pack", + "@io_bazel_rules_go//go/private/actions:stdlib", + ], +) + +bzl_library( + name = "repositories", + srcs = ["repositories.bzl"], + visibility = ["//go:__subpackages__"], + deps = [ + #"@bazel_tools//tools/build_defs/repo:git", + #"@bazel_tools//tools/build_defs/repo:http", + "@io_bazel_rules_go//go/private:common", + "@io_bazel_rules_go//go/private:nogo", + "@io_bazel_rules_go//go/private/skylib/lib:versions", + "@io_bazel_rules_go//proto:gogo", + ], +) + +bzl_library( + name = "sdk", + srcs = ["sdk.bzl"], + visibility = ["//go:__subpackages__"], + deps = [ + "@io_bazel_rules_go//go/private:common", + "@io_bazel_rules_go//go/private:nogo", + "@io_bazel_rules_go//go/private:platforms", + "@io_bazel_rules_go//go/private:sdk_list", + "@io_bazel_rules_go//go/private/skylib/lib:versions", + ], +) + +bzl_library( + name = "common", + srcs = ["common.bzl"], + visibility = ["//go:__subpackages__"], +) + +bzl_library( + name = "mode", + srcs = ["mode.bzl"], + visibility = ["//go:__subpackages__"], +) + +bzl_library( + name = "nogo", + srcs = ["nogo.bzl"], + visibility = ["//go:__subpackages__"], +) + +bzl_library( + name = "platforms", + srcs = ["platforms.bzl"], + visibility = ["//go:__subpackages__"], +) + +bzl_library( + name = "providers", + srcs = ["providers.bzl"], + visibility = [ + "//go:__subpackages__", + "//proto:__pkg__", # keep + ], +) + +bzl_library( + name = "sdk_list", + srcs = ["sdk_list.bzl"], + visibility = ["//go:__subpackages__"], +) diff --git a/go/private/BUILD.sdk.bazel b/go/private/BUILD.sdk.bazel index 322baaa391..179672bb66 100644 --- a/go/private/BUILD.sdk.bazel +++ b/go/private/BUILD.sdk.bazel @@ -1,5 +1,5 @@ -load("@io_bazel_rules_go//go/private:rules/binary.bzl", "go_tool_binary") -load("@io_bazel_rules_go//go/private:rules/sdk.bzl", "package_list") +load("@io_bazel_rules_go//go/private/rules:binary.bzl", "go_tool_binary") +load("@io_bazel_rules_go//go/private/rules:sdk.bzl", "package_list") load("@io_bazel_rules_go//go:def.bzl", "declare_toolchains", "go_sdk") package(default_visibility = ["//visibility:public"]) diff --git a/go/private/actions/BUILD.bazel b/go/private/actions/BUILD.bazel new file mode 100644 index 0000000000..bfae98d1a2 --- /dev/null +++ b/go/private/actions/BUILD.bazel @@ -0,0 +1,84 @@ +load("@bazel_skylib//:bzl_library.bzl", "bzl_library") + +bzl_library( + name = "archive", + srcs = ["archive.bzl"], + visibility = ["//go:__subpackages__"], + deps = [ + "@io_bazel_rules_go//go/private:common", + "@io_bazel_rules_go//go/private:mode", + "@io_bazel_rules_go//go/private:providers", + "@io_bazel_rules_go//go/private/actions:compilepkg", + "@io_bazel_rules_go//go/private/rules:cgo", + ], +) + +bzl_library( + name = "asm", + srcs = ["asm.bzl"], + visibility = ["//go:__subpackages__"], + deps = ["@io_bazel_rules_go//go/private:mode"], +) + +bzl_library( + name = "binary", + srcs = ["binary.bzl"], + visibility = ["//go:__subpackages__"], + deps = [ + "@io_bazel_rules_go//go/private:common", + "@io_bazel_rules_go//go/private:mode", + ], +) + +bzl_library( + name = "compile", + srcs = ["compile.bzl"], + visibility = ["//go:__subpackages__"], + deps = ["@io_bazel_rules_go//go/private:mode"], +) + +bzl_library( + name = "compilepkg", + srcs = ["compilepkg.bzl"], + visibility = ["//go:__subpackages__"], + deps = [ + "@bazel_skylib//lib:shell", + "@io_bazel_rules_go//go/private:mode", + ], +) + +bzl_library( + name = "cover", + srcs = ["cover.bzl"], + visibility = ["//go:__subpackages__"], + deps = [ + "@bazel_skylib//lib:structs", + "@io_bazel_rules_go//go/private:providers", + ], +) + +bzl_library( + name = "link", + srcs = ["link.bzl"], + visibility = ["//go:__subpackages__"], + deps = [ + "@io_bazel_rules_go//go/private:common", + "@io_bazel_rules_go//go/private:mode", + ], +) + +bzl_library( + name = "pack", + srcs = ["pack.bzl"], + visibility = ["//go/private:__subpackages__"], +) + +bzl_library( + name = "stdlib", + srcs = ["stdlib.bzl"], + visibility = ["//go/private:__subpackages__"], + deps = [ + "@io_bazel_rules_go//go/private:mode", + "@io_bazel_rules_go//go/private:providers", + ], +) diff --git a/go/private/actions/archive.bzl b/go/private/actions/archive.bzl index b002dc5ec6..683124859e 100644 --- a/go/private/actions/archive.bzl +++ b/go/private/actions/archive.bzl @@ -31,11 +31,11 @@ load( "get_archive", ) load( - "@io_bazel_rules_go//go/private:rules/cgo.bzl", + "@io_bazel_rules_go//go/private/rules:cgo.bzl", "cgo_configure", ) load( - "@io_bazel_rules_go//go/private:actions/compilepkg.bzl", + "@io_bazel_rules_go//go/private/actions:compilepkg.bzl", "emit_compilepkg", ) diff --git a/go/private/go_toolchain.bzl b/go/private/go_toolchain.bzl index cbcd3eab10..6d4cfbd3ed 100644 --- a/go/private/go_toolchain.bzl +++ b/go/private/go_toolchain.bzl @@ -17,14 +17,14 @@ Toolchain rules used by go. load("@io_bazel_rules_go//go/private:platforms.bzl", "PLATFORMS") load("@io_bazel_rules_go//go/private:providers.bzl", "GoSDK") -load("@io_bazel_rules_go//go/private:actions/archive.bzl", "emit_archive") -load("@io_bazel_rules_go//go/private:actions/asm.bzl", "emit_asm") -load("@io_bazel_rules_go//go/private:actions/binary.bzl", "emit_binary") -load("@io_bazel_rules_go//go/private:actions/compile.bzl", "emit_compile") -load("@io_bazel_rules_go//go/private:actions/cover.bzl", "emit_cover") -load("@io_bazel_rules_go//go/private:actions/link.bzl", "emit_link") -load("@io_bazel_rules_go//go/private:actions/pack.bzl", "emit_pack") -load("@io_bazel_rules_go//go/private:actions/stdlib.bzl", "emit_stdlib") +load("@io_bazel_rules_go//go/private/actions:archive.bzl", "emit_archive") +load("@io_bazel_rules_go//go/private/actions:asm.bzl", "emit_asm") +load("@io_bazel_rules_go//go/private/actions:binary.bzl", "emit_binary") +load("@io_bazel_rules_go//go/private/actions:compile.bzl", "emit_compile") +load("@io_bazel_rules_go//go/private/actions:cover.bzl", "emit_cover") +load("@io_bazel_rules_go//go/private/actions:link.bzl", "emit_link") +load("@io_bazel_rules_go//go/private/actions:pack.bzl", "emit_pack") +load("@io_bazel_rules_go//go/private/actions:stdlib.bzl", "emit_stdlib") def _go_toolchain_impl(ctx): sdk = ctx.attr.sdk[GoSDK] diff --git a/go/private/repositories.bzl b/go/private/repositories.bzl index 1f7b1de561..f028edde6c 100644 --- a/go/private/repositories.bzl +++ b/go/private/repositories.bzl @@ -15,7 +15,7 @@ # Once nested repositories work, this file should cease to exist. load("//go/private:common.bzl", "MINIMUM_BAZEL_VERSION") -load("//go/private:skylib/lib/versions.bzl", "versions") +load("//go/private/skylib/lib:versions.bzl", "versions") load("//go/private:nogo.bzl", "DEFAULT_NOGO", "go_register_nogo") load("//proto:gogo.bzl", "gogo_special_proto") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") diff --git a/go/private/rules/BUILD.bazel b/go/private/rules/BUILD.bazel new file mode 100644 index 0000000000..9e4ed31990 --- /dev/null +++ b/go/private/rules/BUILD.bazel @@ -0,0 +1,140 @@ +load("@bazel_skylib//:bzl_library.bzl", "bzl_library") + +bzl_library( + name = "aspect", + srcs = ["aspect.bzl"], + visibility = ["//go:__subpackages__"], + deps = [ + "@io_bazel_rules_go//go/platform:list", + "@io_bazel_rules_go//go/private:context", + "@io_bazel_rules_go//go/private:mode", + "@io_bazel_rules_go//go/private:providers", + ], +) + +bzl_library( + name = "binary", + srcs = ["binary.bzl"], + visibility = ["//go:__subpackages__"], + deps = ["@bazel_skylib//lib:shell"], +) + +bzl_library( + name = "cgo", + srcs = ["cgo.bzl"], + visibility = ["//go:__subpackages__"], + deps = [ + "@io_bazel_rules_go//go/private:common", + "@io_bazel_rules_go//go/private:mode", + # "@rules_cc//cc:defs", + ], +) + +bzl_library( + name = "info", + srcs = ["info.bzl"], + visibility = ["//go:__subpackages__"], + deps = [ + "@io_bazel_rules_go//go/private:context", + "@io_bazel_rules_go//go/private/rules:rule", + ], +) + +bzl_library( + name = "library", + srcs = ["library.bzl"], + visibility = ["//go:__subpackages__"], + deps = [ + "@io_bazel_rules_go//go/private:common", + "@io_bazel_rules_go//go/private:context", + "@io_bazel_rules_go//go/private:providers", + ], +) + +bzl_library( + name = "nogo", + srcs = ["nogo.bzl"], + visibility = ["//go:__subpackages__"], + deps = [ + "@io_bazel_rules_go//go/private:context", + "@io_bazel_rules_go//go/private:providers", + ], +) + +bzl_library( + name = "rule", + srcs = ["rule.bzl"], + visibility = [ + "//extras:__pkg__", + "//go:__subpackages__", + "//proto:__pkg__", + ], +) + +bzl_library( + name = "sdk", + srcs = ["sdk.bzl"], + visibility = ["//go:__subpackages__"], + deps = ["@io_bazel_rules_go//go/private:providers"], +) + +bzl_library( + name = "source", + srcs = ["source.bzl"], + visibility = ["//go:__subpackages__"], + deps = [ + "@io_bazel_rules_go//go/private:context", + "@io_bazel_rules_go//go/private:providers", + ], +) + +bzl_library( + name = "stdlib", + srcs = ["stdlib.bzl"], + visibility = ["//go:__subpackages__"], + deps = [ + "@io_bazel_rules_go//go/private:context", + "@io_bazel_rules_go//go/private:providers", + ], +) + +bzl_library( + name = "test", + srcs = ["test.bzl"], + visibility = ["//go:__subpackages__"], + deps = [ + "@bazel_skylib//lib:structs", + "@io_bazel_rules_go//go/private:common", + "@io_bazel_rules_go//go/private:context", + "@io_bazel_rules_go//go/private:mode", + "@io_bazel_rules_go//go/private:providers", + "@io_bazel_rules_go//go/private/rules:binary", + "@io_bazel_rules_go//go/private/rules:transition", + ], +) + +bzl_library( + name = "transition", + srcs = ["transition.bzl"], + visibility = ["//go:__subpackages__"], + deps = [ + "@io_bazel_rules_go//go/private:mode", + "@io_bazel_rules_go//go/private:platforms", + "@io_bazel_rules_go//go/private:providers", + # Removed because it doesn't really exist. + #"@io_bazel_rules_go_name_hack//:def", + ], +) + +bzl_library( + name = "wrappers", + srcs = ["wrappers.bzl"], + visibility = ["//go:__subpackages__"], + deps = [ + "@io_bazel_rules_go//go/private/rules:binary", + "@io_bazel_rules_go//go/private/rules:cgo", + "@io_bazel_rules_go//go/private/rules:library", + "@io_bazel_rules_go//go/private/rules:test", + "@io_bazel_rules_go//go/private/rules:transition", + ], +) diff --git a/go/private/rules/binary.bzl b/go/private/rules/binary.bzl index b88dfd96f9..9f17366631 100644 --- a/go/private/rules/binary.bzl +++ b/go/private/rules/binary.bzl @@ -13,26 +13,26 @@ # limitations under the License. load( - ":context.bzl", + "//go/private:context.bzl", "go_context", ) load( - ":common.bzl", + "//go/private:common.bzl", "asm_exts", "cgo_exts", "go_exts", ) load( - ":providers.bzl", + "//go/private:providers.bzl", "GoLibrary", "GoSDK", ) load( - ":rules/transition.bzl", + "//go/private/rules:transition.bzl", "go_transition_rule", ) load( - ":mode.bzl", + "//go/private:mode.bzl", "LINKMODE_PLUGIN", "LINKMODE_SHARED", ) diff --git a/go/private/rules/info.bzl b/go/private/rules/info.bzl index 503b0e4f22..b02391637f 100644 --- a/go/private/rules/info.bzl +++ b/go/private/rules/info.bzl @@ -17,7 +17,7 @@ load( "go_context", ) load( - "@io_bazel_rules_go//go/private:rules/rule.bzl", + "@io_bazel_rules_go//go/private/rules:rule.bzl", "go_rule", ) diff --git a/go/private/rules/nogo.bzl b/go/private/rules/nogo.bzl index 6ece16a7ff..2a66491062 100644 --- a/go/private/rules/nogo.bzl +++ b/go/private/rules/nogo.bzl @@ -24,7 +24,7 @@ load( "get_archive", ) load( - "@io_bazel_rules_go//go/private:rules/transition.bzl", + "@io_bazel_rules_go//go/private/rules:transition.bzl", "go_reset_transition", ) diff --git a/go/private/rules/stdlib.bzl b/go/private/rules/stdlib.bzl index b255dd1f9b..064f4d24e2 100644 --- a/go/private/rules/stdlib.bzl +++ b/go/private/rules/stdlib.bzl @@ -13,11 +13,11 @@ # limitations under the License. load( - ":context.bzl", + "//go/private:context.bzl", "go_context", ) load( - ":providers.bzl", + "//go/private:providers.bzl", "CgoContextInfo", "GoConfigInfo", ) diff --git a/go/private/rules/test.bzl b/go/private/rules/test.bzl index 17516ad72d..79a0374cc8 100644 --- a/go/private/rules/test.bzl +++ b/go/private/rules/test.bzl @@ -13,11 +13,11 @@ # limitations under the License. load( - ":context.bzl", + "//go/private:context.bzl", "go_context", ) load( - ":common.bzl", + "//go/private:common.bzl", "asm_exts", "cgo_exts", "go_exts", @@ -25,11 +25,11 @@ load( "split_srcs", ) load( - ":rules/binary.bzl", + "//go/private/rules:binary.bzl", "gc_linkopts", ) load( - ":providers.bzl", + "//go/private:providers.bzl", "GoArchive", "GoLibrary", "GoSource", @@ -37,11 +37,11 @@ load( "get_archive", ) load( - ":rules/transition.bzl", + "//go/private/rules:transition.bzl", "go_transition_rule", ) load( - ":mode.bzl", + "//go/private:mode.bzl", "LINKMODE_NORMAL", ) load( diff --git a/go/private/rules/transition.bzl b/go/private/rules/transition.bzl index faa614f1ba..9be3bff155 100644 --- a/go/private/rules/transition.bzl +++ b/go/private/rules/transition.bzl @@ -13,17 +13,17 @@ # limitations under the License. load( - ":mode.bzl", + "//go/private:mode.bzl", "LINKMODES", "LINKMODE_NORMAL", ) load( - ":platforms.bzl", + "//go/private:platforms.bzl", "CGO_GOOS_GOARCH", "GOOS_GOARCH", ) load( - ":providers.bzl", + "//go/private:providers.bzl", "GoArchive", "GoLibrary", "GoSource", diff --git a/go/private/rules/wrappers.bzl b/go/private/rules/wrappers.bzl index 4a3789eeff..c1c3d50126 100644 --- a/go/private/rules/wrappers.bzl +++ b/go/private/rules/wrappers.bzl @@ -13,25 +13,25 @@ # limitations under the License. load( - ":rules/library.bzl", + "//go/private/rules:library.bzl", "go_library", ) load( - ":rules/binary.bzl", + "//go/private/rules:binary.bzl", "go_binary", "go_transition_binary", ) load( - ":rules/test.bzl", + "//go/private/rules:test.bzl", "go_test", "go_transition_test", ) load( - ":rules/cgo.bzl", + "//go/private/rules:cgo.bzl", "go_binary_c_archive_shared", ) load( - ":rules/transition.bzl", + "//go/private/rules:transition.bzl", "go_transition_wrapper", ) diff --git a/go/private/sdk.bzl b/go/private/sdk.bzl index 03b3bb35f0..c916143fc7 100644 --- a/go/private/sdk.bzl +++ b/go/private/sdk.bzl @@ -31,7 +31,7 @@ load( "generate_toolchain_names", ) load( - "@io_bazel_rules_go//go/private:skylib/lib/versions.bzl", + "@io_bazel_rules_go//go/private/skylib/lib:versions.bzl", "versions", ) diff --git a/go/private/skylib/lib/BUILD.bazel b/go/private/skylib/lib/BUILD.bazel new file mode 100644 index 0000000000..2727a141d9 --- /dev/null +++ b/go/private/skylib/lib/BUILD.bazel @@ -0,0 +1,7 @@ +load("@bazel_skylib//:bzl_library.bzl", "bzl_library") + +bzl_library( + name = "versions", + srcs = ["versions.bzl"], + visibility = ["//go:__subpackages__"], +) diff --git a/go/private/tools/BUILD.bazel b/go/private/tools/BUILD.bazel new file mode 100644 index 0000000000..5c6e7026f6 --- /dev/null +++ b/go/private/tools/BUILD.bazel @@ -0,0 +1,11 @@ +load("@bazel_skylib//:bzl_library.bzl", "bzl_library") + +bzl_library( + name = "path", + srcs = ["path.bzl"], + visibility = ["//go:__subpackages__"], + deps = [ + "@io_bazel_rules_go//go/private:common", + "@io_bazel_rules_go//go/private:providers", + ], +) diff --git a/go/private/tools/lines_sorted_test.bzl b/go/private/tools/lines_sorted_test.bzl index a08aa97cbf..dd02da01ac 100644 --- a/go/private/tools/lines_sorted_test.bzl +++ b/go/private/tools/lines_sorted_test.bzl @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -load("@io_bazel_rules_go//go/private:tools/files_equal_test.bzl", "files_equal_test") +load("@io_bazel_rules_go//go/private/tools:files_equal_test.bzl", "files_equal_test") def lines_sorted_test(name, file, cmd = "cat $< >$@", visibility = None, **kwargs): """Tests that lines within a file are sorted.""" diff --git a/go/toolchain/BUILD.bazel b/go/toolchain/BUILD.bazel index 4158a788ad..d40fbc6543 100644 --- a/go/toolchain/BUILD.bazel +++ b/go/toolchain/BUILD.bazel @@ -1,3 +1,4 @@ +load("@bazel_skylib//:bzl_library.bzl", "bzl_library") load( ":toolchains.bzl", "declare_constraints", @@ -19,3 +20,13 @@ filegroup( srcs = glob(["**"]), visibility = ["//visibility:public"], ) + +bzl_library( + name = "toolchains", + srcs = ["toolchains.bzl"], + deps = [ + "@io_bazel_rules_go//go/private:platforms", + "@io_bazel_rules_go//go/private:sdk", + "@io_bazel_rules_go//go/private:sdk_list", + ], +) diff --git a/go/tools/bazel_testing/BUILD.bazel b/go/tools/bazel_testing/BUILD.bazel index 54c9e4a43c..48c56e29ef 100644 --- a/go/tools/bazel_testing/BUILD.bazel +++ b/go/tools/bazel_testing/BUILD.bazel @@ -1,3 +1,4 @@ +load("@bazel_skylib//:bzl_library.bzl", "bzl_library") load("@io_bazel_rules_go//go:def.bzl", "go_library") go_library( @@ -17,3 +18,10 @@ filegroup( srcs = glob(["**"]), visibility = ["//visibility:public"], ) + +bzl_library( + name = "def", + srcs = ["def.bzl"], + visibility = ["//visibility:public"], + deps = ["@io_bazel_rules_go//go:def"], +) diff --git a/go/tools/builders/BUILD.bazel b/go/tools/builders/BUILD.bazel index b95a21eea0..86ca858dc5 100644 --- a/go/tools/builders/BUILD.bazel +++ b/go/tools/builders/BUILD.bazel @@ -1,5 +1,5 @@ load("//go:def.bzl", "go_binary", "go_source", "go_test") -load("//go/private:rules/transition.bzl", "go_reset_target") +load("//go/private/rules:transition.bzl", "go_reset_target") go_test( name = "filter_test", diff --git a/go/tools/coverdata/BUILD.bazel b/go/tools/coverdata/BUILD.bazel index 02a108be81..82a2343c73 100644 --- a/go/tools/coverdata/BUILD.bazel +++ b/go/tools/coverdata/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_go//go/private:rules/library.bzl", "go_tool_library") +load("@io_bazel_rules_go//go/private/rules:library.bzl", "go_tool_library") go_tool_library( name = "coverdata", diff --git a/proto/BUILD.bazel b/proto/BUILD.bazel index 71be587383..13156324a7 100644 --- a/proto/BUILD.bazel +++ b/proto/BUILD.bazel @@ -1,3 +1,4 @@ +load("@bazel_skylib//:bzl_library.bzl", "bzl_library") load( "//proto:compiler.bzl", "go_proto_compiler", @@ -123,3 +124,33 @@ filegroup( srcs = glob(["**"]) + ["//proto/wkt:all_files"], visibility = ["//:__subpackages__"], ) + +bzl_library( + name = "compiler", + srcs = ["compiler.bzl"], + visibility = ["//visibility:public"], + deps = [ + "@bazel_skylib//lib:paths", + "@io_bazel_rules_go//go:def", + "@io_bazel_rules_go//go/private/rules:rule", + ], +) + +bzl_library( + name = "def", + srcs = ["def.bzl"], + visibility = ["//visibility:public"], + deps = [ + "@io_bazel_rules_go//go:def", + "@io_bazel_rules_go//go/private:providers", + "@io_bazel_rules_go//go/private/rules:rule", + "@io_bazel_rules_go//proto:compiler", + #"@rules_proto//proto:defs", + ], +) + +bzl_library( + name = "gogo", + srcs = ["gogo.bzl"], + visibility = ["//visibility:public"], +) diff --git a/proto/compiler.bzl b/proto/compiler.bzl index d5526ad08f..c85b161815 100644 --- a/proto/compiler.bzl +++ b/proto/compiler.bzl @@ -22,7 +22,7 @@ load( "go_context", ) load( - "//go/private:rules/transition.bzl", + "//go/private/rules:transition.bzl", "go_reset_target", ) diff --git a/proto/def.bzl b/proto/def.bzl index 80ba9d5546..aaaca65f55 100644 --- a/proto/def.bzl +++ b/proto/def.bzl @@ -24,7 +24,7 @@ load( "proto_path", ) load( - "@io_bazel_rules_go//go/private:rules/rule.bzl", + "@io_bazel_rules_go//go/private/rules:rule.bzl", "go_rule", ) load( diff --git a/proto/wkt/BUILD.bazel b/proto/wkt/BUILD.bazel index 69605fb464..7b2f18f666 100644 --- a/proto/wkt/BUILD.bazel +++ b/proto/wkt/BUILD.bazel @@ -1,3 +1,4 @@ +load("@bazel_skylib//:bzl_library.bzl", "bzl_library") load(":well_known_types.bzl", "go_proto_wrapper") load("//proto:def.bzl", "go_proto_library") @@ -176,3 +177,10 @@ filegroup( srcs = glob(["**"]), visibility = ["//visibility:public"], ) + +bzl_library( + name = "well_known_types", + srcs = ["well_known_types.bzl"], + visibility = ["//visibility:public"], + deps = ["@io_bazel_rules_go//proto:def"], +) diff --git a/tests/BUILD.bazel b/tests/BUILD.bazel index 34719c5b8a..e1b781c726 100644 --- a/tests/BUILD.bazel +++ b/tests/BUILD.bazel @@ -1,10 +1,20 @@ +load("@bazel_skylib//:bzl_library.bzl", "bzl_library") load(":buildifier_test.bzl", "buildifier_test") buildifier_test( name = "buildifier_test", + size = "small", data = [ ":buildifier_test.bzl", "//:all_files", ], - size = "small", +) + +bzl_library( + name = "grpc_repos", + srcs = ["grpc_repos.bzl"], + visibility = ["//visibility:public"], + deps = [ + #"@bazel_gazelle//:deps", + ], ) diff --git a/tests/core/cross/BUILD.bazel b/tests/core/cross/BUILD.bazel index 02cacb9366..46967d0d57 100644 --- a/tests/core/cross/BUILD.bazel +++ b/tests/core/cross/BUILD.bazel @@ -1,3 +1,4 @@ +load("@bazel_skylib//:bzl_library.bzl", "bzl_library") load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library", "go_source", "go_test") load("@io_bazel_rules_go//go/tools/bazel_testing:def.bzl", "go_bazel_test") load(":def.bzl", "no_context_info") @@ -77,3 +78,10 @@ go_bazel_test( no_context_info( name = "no_context_info", ) + +bzl_library( + name = "def", + srcs = ["def.bzl"], + visibility = ["//visibility:public"], + deps = ["@io_bazel_rules_go//go:def"], +) diff --git a/tests/core/nogo/BUILD.bazel b/tests/core/nogo/BUILD.bazel index 46c7ee89e2..5e2253d137 100644 --- a/tests/core/nogo/BUILD.bazel +++ b/tests/core/nogo/BUILD.bazel @@ -1,5 +1,13 @@ +load("@bazel_skylib//:bzl_library.bzl", "bzl_library") + filegroup( name = "rules_go_deps", srcs = [":common.bzl"], visibility = ["//visibility:public"], ) + +bzl_library( + name = "common", + srcs = ["common.bzl"], + visibility = ["//visibility:public"], +) diff --git a/tests/examples/executable_name/BUILD.bazel b/tests/examples/executable_name/BUILD.bazel index c597aa855e..58d31061cd 100644 --- a/tests/examples/executable_name/BUILD.bazel +++ b/tests/examples/executable_name/BUILD.bazel @@ -16,5 +16,5 @@ sh_test( name = "executable_name", size = "small", srcs = ["name_test.sh"], - data = [ ":normalised_binary" ], + data = [":normalised_binary"], ) diff --git a/tests/integration/popular_repos/BUILD.bazel b/tests/integration/popular_repos/BUILD.bazel index 10312342ab..08fada490d 100644 --- a/tests/integration/popular_repos/BUILD.bazel +++ b/tests/integration/popular_repos/BUILD.bazel @@ -15,6 +15,9 @@ ############################## # Generated file, do not edit! ############################## + +# gazelle:exclude popular_repos.bzl + test_suite( name = "org_golang_x_crypto", tests = [ diff --git a/tests/integration/popular_repos/popular_repos.py b/tests/integration/popular_repos/popular_repos.py index 8fcb11bac6..6cdff2d23b 100755 --- a/tests/integration/popular_repos/popular_repos.py +++ b/tests/integration/popular_repos/popular_repos.py @@ -247,7 +247,10 @@ def _maybe(repo_rule, name, **kwargs): def popular_repos(): """ -BUILD_HEADER = COPYRIGHT_HEADER +BUILD_HEADER = COPYRIGHT_HEADER + """ + +# gazelle:exclude popular_repos.bzl +""" DOCUMENTATION_HEADER = """ Popular repository tests diff --git a/tests/legacy/binary_test_outputs/BUILD.bazel b/tests/legacy/binary_test_outputs/BUILD.bazel index d966a2b60f..1d34c4ca11 100644 --- a/tests/legacy/binary_test_outputs/BUILD.bazel +++ b/tests/legacy/binary_test_outputs/BUILD.bazel @@ -2,7 +2,7 @@ # See documentation in single_output_test.bzl. load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_test") -load("@io_bazel_rules_go//go/private:tools/single_output_test.bzl", "single_output_test") +load("@io_bazel_rules_go//go/private/tools:single_output_test.bzl", "single_output_test") single_output_test( name = "binary_single_output_test", diff --git a/tests/legacy/providers/BUILD.bazel b/tests/legacy/providers/BUILD.bazel index 34eb889798..c0cca5fa46 100644 --- a/tests/legacy/providers/BUILD.bazel +++ b/tests/legacy/providers/BUILD.bazel @@ -1,3 +1,4 @@ +load("@bazel_skylib//:bzl_library.bzl", "bzl_library") load("//go:def.bzl", "go_source") load("//tests/legacy/providers:test.bzl", "test_source") @@ -20,3 +21,10 @@ sh_test( ":foo", ], ) + +bzl_library( + name = "test", + srcs = ["test.bzl"], + visibility = ["//visibility:public"], + deps = ["@io_bazel_rules_go//go:def"], +) diff --git a/tests/legacy/test_chdir/BUILD.bazel b/tests/legacy/test_chdir/BUILD.bazel index 7e06b0ed34..318f467a0c 100644 --- a/tests/legacy/test_chdir/BUILD.bazel +++ b/tests/legacy/test_chdir/BUILD.bazel @@ -1,3 +1,4 @@ +load("@bazel_skylib//:bzl_library.bzl", "bzl_library") load("@io_bazel_rules_go//go:def.bzl", "go_test") go_test( @@ -11,3 +12,9 @@ test_suite( name = "remote_test", tests = ["@test_chdir_remote//sub:go_default_test"], ) + +bzl_library( + name = "remote", + srcs = ["remote.bzl"], + visibility = ["//visibility:public"], +) diff --git a/third_party/com_google_github_bazel_gazelle-internal-in-their-new-location.patch b/third_party/com_google_github_bazel_gazelle-internal-in-their-new-location.patch new file mode 100644 index 0000000000..01fc9f7310 --- /dev/null +++ b/third_party/com_google_github_bazel_gazelle-internal-in-their-new-location.patch @@ -0,0 +1,12 @@ +diff --git internal/gazelle_binary.bzl internal/gazelle_binary.bzl +--- internal/gazelle_binary.bzl ++++ internal/gazelle_binary.bzl +@@ -19,7 +19,7 @@ load( + "go_rule", + ) + load( +- "@io_bazel_rules_go//go/private:rules/aspect.bzl", ++ "@io_bazel_rules_go//go/private/rules:aspect.bzl", + "go_archive_aspect", + ) + load(