xref: /aosp_15_r20/external/bazelbuild-rules_go/proto/gogo.bzl (revision 9bb1b549b6a84214c53be0924760be030e66b93a)
1*9bb1b549SSpandan Das# Copyright 2017 The Bazel Authors. All rights reserved.
2*9bb1b549SSpandan Das#
3*9bb1b549SSpandan Das# Licensed under the Apache License, Version 2.0 (the "License");
4*9bb1b549SSpandan Das# you may not use this file except in compliance with the License.
5*9bb1b549SSpandan Das# You may obtain a copy of the License at
6*9bb1b549SSpandan Das#
7*9bb1b549SSpandan Das#    http://www.apache.org/licenses/LICENSE-2.0
8*9bb1b549SSpandan Das#
9*9bb1b549SSpandan Das# Unless required by applicable law or agreed to in writing, software
10*9bb1b549SSpandan Das# distributed under the License is distributed on an "AS IS" BASIS,
11*9bb1b549SSpandan Das# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12*9bb1b549SSpandan Das# See the License for the specific language governing permissions and
13*9bb1b549SSpandan Das# limitations under the License.
14*9bb1b549SSpandan Das
15*9bb1b549SSpandan Dasdef _gogo_special_proto_impl(ctx):
16*9bb1b549SSpandan Das    ctx.file("WORKSPACE", 'workspace(name = "{}")'.format(ctx.name))
17*9bb1b549SSpandan Das    ctx.file("BUILD.bazel", "")
18*9bb1b549SSpandan Das    ctx.symlink(
19*9bb1b549SSpandan Das        ctx.path(Label("@com_github_gogo_protobuf//gogoproto:gogo.proto")),
20*9bb1b549SSpandan Das        "github.com/gogo/protobuf/gogoproto/gogo.proto",
21*9bb1b549SSpandan Das    )
22*9bb1b549SSpandan Das    ctx.file("github.com/gogo/protobuf/gogoproto/BUILD.bazel", """
23*9bb1b549SSpandan Dasload("@rules_proto//proto:defs.bzl", "proto_library")
24*9bb1b549SSpandan Das
25*9bb1b549SSpandan Dasproto_library(
26*9bb1b549SSpandan Das    name = "gogoproto",
27*9bb1b549SSpandan Das    srcs = [":gogo.proto"],
28*9bb1b549SSpandan Das    tags = ["manual"],
29*9bb1b549SSpandan Das    visibility = ["//visibility:public"],
30*9bb1b549SSpandan Das    deps = [
31*9bb1b549SSpandan Das        "@com_google_protobuf//:descriptor_proto",
32*9bb1b549SSpandan Das    ],
33*9bb1b549SSpandan Das)
34*9bb1b549SSpandan Das  """)
35*9bb1b549SSpandan Das
36*9bb1b549SSpandan Dasgogo_special_proto = repository_rule(
37*9bb1b549SSpandan Das    _gogo_special_proto_impl,
38*9bb1b549SSpandan Das    attrs = {
39*9bb1b549SSpandan Das        "proto": attr.label(allow_single_file = True),
40*9bb1b549SSpandan Das    },
41*9bb1b549SSpandan Das)
42