1*c8dee2aaSAndroid Build Coastguard Worker"""This module defines the go_googleapis_compatibility_hack repository rule. 2*c8dee2aaSAndroid Build Coastguard Worker 3*c8dee2aaSAndroid Build Coastguard WorkerThis file is copied almost verbatim from the Skia Infrastructure repository: 4*c8dee2aaSAndroid Build Coastguard Workerhttps://skia.googlesource.com/buildbot/+/d32a5c6f592dfd0668001e57b0f4bb55523629f5/bazel/external/go_googleapis_compatibility_hack.bzl 5*c8dee2aaSAndroid Build Coastguard Worker""" 6*c8dee2aaSAndroid Build Coastguard Worker 7*c8dee2aaSAndroid Build Coastguard Workerdef _go_googleapis_compatibility_hack_impl(ctx): 8*c8dee2aaSAndroid Build Coastguard Worker if ctx.name != "go_googleapis": 9*c8dee2aaSAndroid Build Coastguard Worker fail("This rule should be named \"go_googleapis\" for this compatibility hack to work.") 10*c8dee2aaSAndroid Build Coastguard Worker 11*c8dee2aaSAndroid Build Coastguard Worker # The visibility of the below aliases should be limited to @com_github_bazelbuild_remote_apis 12*c8dee2aaSAndroid Build Coastguard Worker # to prevent accidental usages from other dependencies or from our own code. 13*c8dee2aaSAndroid Build Coastguard Worker 14*c8dee2aaSAndroid Build Coastguard Worker # Aliases @go_googleapis//google/api:annotations_go_proto. 15*c8dee2aaSAndroid Build Coastguard Worker ctx.file("google/api/BUILD.bazel", """ 16*c8dee2aaSAndroid Build Coastguard Worker# GENERATED FILE. See //bazel/external/go_googleapis_compatibility_hack.bzl in the Skia Buildbot 17*c8dee2aaSAndroid Build Coastguard Worker# repository. 18*c8dee2aaSAndroid Build Coastguard Worker 19*c8dee2aaSAndroid Build Coastguard Workeralias( 20*c8dee2aaSAndroid Build Coastguard Worker name = "annotations_go_proto", 21*c8dee2aaSAndroid Build Coastguard Worker actual = "@org_golang_google_genproto_googleapis_api//annotations", 22*c8dee2aaSAndroid Build Coastguard Worker visibility = ["@com_github_bazelbuild_remote_apis//:__subpackages__"], 23*c8dee2aaSAndroid Build Coastguard Worker) 24*c8dee2aaSAndroid Build Coastguard Worker""") 25*c8dee2aaSAndroid Build Coastguard Worker 26*c8dee2aaSAndroid Build Coastguard Worker # Aliases @go_googleapis//google/longrunning:longrunning_go_proto". 27*c8dee2aaSAndroid Build Coastguard Worker ctx.file("google/longrunning/BUILD.bazel", """ 28*c8dee2aaSAndroid Build Coastguard Worker# GENERATED FILE. See //bazel/external/go_googleapis_compatibility_hack.bzl in the Skia Buildbot 29*c8dee2aaSAndroid Build Coastguard Worker# repository. 30*c8dee2aaSAndroid Build Coastguard Worker 31*c8dee2aaSAndroid Build Coastguard Workeralias( 32*c8dee2aaSAndroid Build Coastguard Worker name = "longrunning_go_proto", 33*c8dee2aaSAndroid Build Coastguard Worker actual = "@org_golang_google_genproto//googleapis/longrunning", 34*c8dee2aaSAndroid Build Coastguard Worker visibility = ["@com_github_bazelbuild_remote_apis//:__subpackages__"], 35*c8dee2aaSAndroid Build Coastguard Worker) 36*c8dee2aaSAndroid Build Coastguard Worker""") 37*c8dee2aaSAndroid Build Coastguard Worker 38*c8dee2aaSAndroid Build Coastguard Worker # Aliases @go_googleapis//google/rpc:status_go_pro 39*c8dee2aaSAndroid Build Coastguard Worker ctx.file("google/rpc/BUILD.bazel", """ 40*c8dee2aaSAndroid Build Coastguard Worker# GENERATED FILE. See //bazel/external/go_googleapis_compatibility_hack.bzl in the Skia Buildbot 41*c8dee2aaSAndroid Build Coastguard Worker# repository. 42*c8dee2aaSAndroid Build Coastguard Worker 43*c8dee2aaSAndroid Build Coastguard Workeralias( 44*c8dee2aaSAndroid Build Coastguard Worker name = "status_go_proto", 45*c8dee2aaSAndroid Build Coastguard Worker actual = "@org_golang_google_genproto_googleapis_rpc//status", 46*c8dee2aaSAndroid Build Coastguard Worker visibility = ["@com_github_bazelbuild_remote_apis//:__subpackages__"], 47*c8dee2aaSAndroid Build Coastguard Worker) 48*c8dee2aaSAndroid Build Coastguard Worker""") 49*c8dee2aaSAndroid Build Coastguard Worker 50*c8dee2aaSAndroid Build Coastguard Workergo_googleapis_compatibility_hack = repository_rule( 51*c8dee2aaSAndroid Build Coastguard Worker doc = """Hack to make github.com/bazelbuild/remote-apis work with rules_go v0.41.0. 52*c8dee2aaSAndroid Build Coastguard Worker 53*c8dee2aaSAndroid Build Coastguard WorkerStarting with version v0.41.0, rules_go no longer ships with the @go_googleapis external 54*c8dee2aaSAndroid Build Coastguard Workerrepository: https://github.com/bazelbuild/rules_go/releases/tag/v0.41.0. As per the release notes, 55*c8dee2aaSAndroid Build Coastguard WorkerGo code imported generated Google API .pb.go files should use the @org_golang_google_genproto 56*c8dee2aaSAndroid Build Coastguard Workerrepository instead (https://github.com/googleapis/go-genproto). 57*c8dee2aaSAndroid Build Coastguard Worker 58*c8dee2aaSAndroid Build Coastguard WorkerAs of 2023-05-26, the github.com/googleapis/go-genproto Go module has been broken into smaller 59*c8dee2aaSAndroid Build Coastguard Workersubmodules as a usability improvements for customers that do not depend on Google Cloud: 60*c8dee2aaSAndroid Build Coastguard Workerhttps://github.com/googleapis/go-genproto/issues/1015. This means some former @go_googleapis 61*c8dee2aaSAndroid Build Coastguard Workerdependencies are now found in Go modules such as google.golang.org/genproto/googleapis/api and 62*c8dee2aaSAndroid Build Coastguard Workergoogle.golang.org/genproto/googleapis/rpc. In Bazel terms, the corresponding Gazelle-generated 63*c8dee2aaSAndroid Build Coastguard Workerexternal repositories will be @org_golang_google_genproto_googleapis_api and 64*c8dee2aaSAndroid Build Coastguard Worker@com_github_bazelbuild_remote_apis, respectively. 65*c8dee2aaSAndroid Build Coastguard Worker 66*c8dee2aaSAndroid Build Coastguard WorkerUnfortunately, as of 2023-10-30 the https://github.com/bazelbuild/remote-apis Go module is still 67*c8dee2aaSAndroid Build Coastguard Workerdistributed with BUILD files that reference the @go_googleapis repository: 68*c8dee2aaSAndroid Build Coastguard Workerhttps://github.com/bazelbuild/remote-apis/blob/6c32c3b917cc5d3cfee680c03179d7552832bb3f/build/bazel/remote/execution/v2/go/BUILD#L13. 69*c8dee2aaSAndroid Build Coastguard Worker 70*c8dee2aaSAndroid Build Coastguard WorkerAs a compatibility hack, this repository rule provides a fake @go_googleapis repository that 71*c8dee2aaSAndroid Build Coastguard Workeraliases the Bazel labels required by https://github.com/bazelbuild/remote-apis to point to the 72*c8dee2aaSAndroid Build Coastguard Workercorrect targets within @org_golang_google_genproto, @org_golang_google_genproto_googleapis_api, 73*c8dee2aaSAndroid Build Coastguard Workeretc. 74*c8dee2aaSAndroid Build Coastguard Worker 75*c8dee2aaSAndroid Build Coastguard WorkerWe should delete this rule if/when https://github.com/bazelbuild/remote-apis is updated to work 76*c8dee2aaSAndroid Build Coastguard Workerwith more recent versions of rules_go. 77*c8dee2aaSAndroid Build Coastguard Worker""", 78*c8dee2aaSAndroid Build Coastguard Worker implementation = _go_googleapis_compatibility_hack_impl, 79*c8dee2aaSAndroid Build Coastguard Worker) 80