This repository has been archived by the owner on Jul 19, 2021. It is now read-only.
forked from stackb/rules_proto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BUILD.bazel
95 lines (85 loc) · 2.73 KB
/
BUILD.bazel
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
load("//:plugin.bzl", "proto_plugin")
proto_plugin(
name = "dart",
outputs = [
"{basename}.pb.dart",
"{basename}.pbjson.dart",
"{basename}.pbenum.dart",
],
tool = ":protoc-gen-dart",
visibility = ["//visibility:public"],
)
proto_plugin(
name = "grpc_dart",
options = [
"grpc",
],
outputs = [
"{basename}.pb.dart",
"{basename}.pbjson.dart",
"{basename}.pbenum.dart",
"{basename}.pbgrpc.dart",
# Unclear how the pbserver.dart file is used. This commit is left here
# to remind someone that it exists. If the 'grpc' option is provided,
# the 'pbgrpc' file is produced. If the file has services and the
# 'grpc' option is not provided, the 'pbserver' file is produced
# instead.
#
# "{basename}.pbserver.dart",
],
tool = ":protoc-gen-dart",
visibility = ["//visibility:public"],
)
load("@io_bazel_rules_dart//dart/build_rules:vm.bzl", "dart_vm_binary", "dart_vm_snapshot")
dart_vm_snapshot(
name = "protoc_plugin",
srcs = ["dart_protoc_plugin.dart"],
script_file = "dart_protoc_plugin.dart",
deps = [
"@vendor_crypto//:crypto",
"@vendor_front_end//:front_end",
"@vendor_glob//:glob",
"@vendor_html//:html",
"@vendor_logging//:logging",
"@vendor_meta//:meta",
"@vendor_protoc_plugin//:protoc_plugin",
"@vendor_pub_semver//:pub_semver",
"@vendor_typed_data//:typed_data",
"@vendor_watcher//:watcher",
],
)
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_embed_data", "go_library")
go_embed_data(
name = "assets",
srcs = [
":protoc_plugin",
"@dart_sdk//:bin/dart",
],
flatten = True,
package = "main",
var = "assets",
)
#
# To avoid the vagaries of using a *script* for a protoc plugin (in various
# bazel contexts), we bundle up the actual dependencies into its own standalone
# binary that can accept stdin and write stdout reliably. The dart binary
# itself and the application snapshot are embedded into the binary. When it
# runs, it writes those two files out to a tmp dir and executes the snapshot,
# then removes the directory. While in theory this sounds inefficient, in
# practice it works and is a rare event anyway, so we don't care.
#
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
go_library(
name = "go_default_library",
srcs = [
"protoc-gen-dart.go",
":assets",
],
importpath = "github.com/stackb/rules_proto/dart/protoc-gen-dart",
visibility = ["//visibility:public"],
)
go_binary(
name = "protoc-gen-dart",
embed = [":go_default_library"],
visibility = ["//visibility:public"],
)