|
1 | | -load("//bzl:protoc.bzl", "EXECUTABLE", "implement") |
| 1 | +load("//bzl:protoc.bzl", "EXECUTABLE", "implement", "protoc_genrule") |
2 | 2 | load("//bzl:grpc_gateway/class.bzl", GRPC_GATEWAY = "CLASS") |
3 | 3 | load("@io_bazel_rules_go//go:def.bzl", "go_library") |
4 | 4 |
|
5 | | -grpc_gateway_proto_compile = implement(["go", "gateway"]) |
| 5 | +grpc_gateway_proto_compile = implement(["gateway"]) |
6 | 6 |
|
7 | 7 | def grpc_gateway_proto_library( |
8 | 8 | name, |
9 | 9 | protos, |
10 | | - copy_protos_to_genfiles = True, |
11 | | - deps = [], |
12 | | - grpc_plugin = None, |
13 | | - grpc_plugin_options = [], |
14 | | - imports = [], |
15 | 10 | lang = GRPC_GATEWAY, |
16 | | - proto_compile = grpc_gateway_proto_compile, |
17 | | - protobuf_plugin_options = [], |
18 | | - protobuf_plugin = None, |
19 | | - protoc = EXECUTABLE, |
20 | 11 | srcs = [], |
21 | | - verbose = 0, |
| 12 | + imports = [], |
22 | 13 | visibility = None, |
| 14 | + testonly = 0, |
| 15 | + protoc = None, |
| 16 | + protobuf_plugin = None, |
| 17 | + verbose = 0, |
23 | 18 | **kwargs): |
24 | 19 |
|
25 | | - args = {} |
26 | | - args["name"] = name + "_pb_gw" |
27 | | - args["copy_protos_to_genfiles"] = copy_protos_to_genfiles |
28 | | - args["deps"] = deps |
29 | | - args["imports"] = imports |
30 | | - args["gen_grpc_gateway"] = True |
31 | | - args["gen_protobuf_go_plugin"] = protobuf_plugin |
32 | | - args["gen_go_plugin_options"] = protobuf_plugin_options |
33 | | - #args["gen_grpc_" + lang.name + "_plugin"] = grpc_plugin |
34 | | - args["protoc"] = protoc |
35 | | - args["protos"] = protos |
36 | | - args["verbose"] = verbose |
37 | | - args["with_grpc"] = True |
38 | | - |
39 | | - proto_compile(**args) |
40 | | - |
41 | | - proto_deps = [str(Label(dep)) for dep in getattr(lang.grpc, "compile_deps", [])] |
| 20 | + result = protoc_genrule( |
| 21 | + spec = [lang], |
| 22 | + name = name + "_pb_gw", |
| 23 | + protos = protos, |
| 24 | + protoc = protoc, |
| 25 | + protobuf_plugin = protobuf_plugin, |
| 26 | + visibility = visibility, |
| 27 | + testonly = testonly, |
| 28 | + imports = imports, |
| 29 | + with_grpc = True, |
| 30 | + verbose = verbose, |
| 31 | + ) |
42 | 32 |
|
43 | | - grpc_gateway_deps = list(set(deps + proto_deps)) |
| 33 | + deps = [str(Label(dep)) for dep in getattr(lang.grpc, "compile_deps", [])] |
44 | 34 |
|
45 | 35 | go_library( |
46 | | - name = name, |
47 | | - srcs = srcs + [name + "_pb_gw"], |
48 | | - deps = grpc_gateway_deps, |
49 | | - **kwargs |
| 36 | + name = name, |
| 37 | + srcs = result.outs, |
| 38 | + deps = deps, |
| 39 | + **kwargs |
50 | 40 | ) |
51 | 41 |
|
52 | | -# grpc_gateway_proto_compile = implement(["grpc_gateway"]) |
53 | 42 |
|
54 | | -# def grpc_gateway_proto_library( |
| 43 | +# Not working yet as a rule... |
| 44 | +# |
| 45 | +# def grpc_gateway_proto_library_rule( |
55 | 46 | # name, |
56 | 47 | # protos, |
57 | | -# lang = GRPC_GATEWAY, |
58 | | -# srcs = [], |
| 48 | +# copy_protos_to_genfiles = True, |
| 49 | +# deps = [], |
| 50 | +# grpc_plugin = None, |
| 51 | +# grpc_plugin_options = [], |
59 | 52 | # imports = [], |
60 | | -# visibility = None, |
61 | | -# testonly = 0, |
62 | | -# protoc = None, |
| 53 | +# lang = GRPC_GATEWAY, |
| 54 | +# proto_compile = grpc_gateway_proto_compile, |
| 55 | +# protobuf_plugin_options = [], |
63 | 56 | # protobuf_plugin = None, |
| 57 | +# protoc = EXECUTABLE, |
| 58 | +# srcs = [], |
64 | 59 | # verbose = 0, |
| 60 | +# visibility = None, |
65 | 61 | # **kwargs): |
66 | 62 |
|
67 | | -# result = protoc_genrule( |
68 | | -# spec = [lang], |
69 | | -# name = name + "_pb_gw", |
70 | | -# protos = protos, |
71 | | -# protoc = protoc, |
72 | | -# protobuf_plugin = protobuf_plugin, |
73 | | -# visibility = visibility, |
74 | | -# testonly = testonly, |
75 | | -# imports = imports, |
76 | | -# with_grpc = True, |
77 | | -# verbose = verbose, |
78 | | -# ) |
| 63 | +# args = {} |
| 64 | +# args["name"] = name + "_pb_gw" |
| 65 | +# args["copy_protos_to_genfiles"] = copy_protos_to_genfiles |
| 66 | +# args["deps"] = deps |
| 67 | +# args["imports"] = imports |
| 68 | +# args["gen_grpc_gateway"] = True |
| 69 | +# args["gen_protobuf_go_plugin"] = protobuf_plugin |
| 70 | +# args["gen_go_plugin_options"] = protobuf_plugin_options |
| 71 | +# #args["gen_grpc_" + lang.name + "_plugin"] = grpc_plugin |
| 72 | +# args["protoc"] = protoc |
| 73 | +# args["protos"] = protos |
| 74 | +# args["verbose"] = verbose |
| 75 | +# args["with_grpc"] = True |
| 76 | + |
| 77 | +# proto_compile(**args) |
| 78 | + |
| 79 | +# proto_deps = [str(Label(dep)) for dep in getattr(lang.grpc, "compile_deps", [])] |
79 | 80 |
|
80 | | -# deps = [str(Label(dep)) for dep in getattr(lang.grpc, "compile_deps", [])] |
| 81 | +# grpc_gateway_deps = list(set(deps + proto_deps)) |
81 | 82 |
|
82 | 83 | # go_library( |
83 | | -# name = name, |
84 | | -# srcs = result.outs, |
85 | | -# deps = deps, |
86 | | -# **kwargs |
| 84 | +# name = name, |
| 85 | +# srcs = srcs + [name + "_pb_gw"], |
| 86 | +# deps = grpc_gateway_deps, |
| 87 | +# **kwargs |
87 | 88 | # ) |
0 commit comments