Fix rust proto compile example rulegen
This commit is contained in:
parent
4cc5cc68d5
commit
209b776169
|
@ -72,16 +72,29 @@ Full example project can be found `here <https://github.com/rules-proto-grpc/rul
|
|||
|
||||
rust_prost_proto_compile(
|
||||
name = "person_rust_proto",
|
||||
declared_proto_packages = ["example.proto"],
|
||||
options = {
|
||||
"//rust:rust_prost_plugin": ["type_attribute=.other.space.Person=#[derive(Eq\\,Hash)]"],
|
||||
},
|
||||
protos = ["@rules_proto_grpc//example/proto:person_proto"],
|
||||
)
|
||||
|
||||
rust_prost_proto_compile(
|
||||
name = "place_rust_proto",
|
||||
declared_proto_packages = ["example.proto"],
|
||||
options = {
|
||||
"//rust:rust_prost_plugin": ["type_attribute=.other.space.Place=#[derive(Eq\\,Hash)]"],
|
||||
},
|
||||
protos = ["@rules_proto_grpc//example/proto:place_proto"],
|
||||
)
|
||||
|
||||
rust_prost_proto_compile(
|
||||
name = "thing_rust_proto",
|
||||
declared_proto_packages = ["example.proto"],
|
||||
options = {
|
||||
# Known limitation, can't derive if the type contains a pbjson type.
|
||||
# "//rust:rust_prost_plugin": ["type_attribute=.other.space.Thing=#[derive(Eq\\,Hash)]"],
|
||||
},
|
||||
protos = ["@rules_proto_grpc//example/proto:thing_proto"],
|
||||
)
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
load("@rules_proto_grpc//rust:defs.bzl", "rust_prost_proto_compile")
|
||||
|
||||
rust_prost_proto_compile(
|
||||
name = "person_prost",
|
||||
name = "person_rust_proto",
|
||||
declared_proto_packages = ["example.proto"],
|
||||
options = {
|
||||
"//rust:rust_prost_plugin": ["type_attribute=.other.space.Person=#[derive(Eq\\,Hash)]"],
|
||||
|
@ -10,22 +10,20 @@ rust_prost_proto_compile(
|
|||
)
|
||||
|
||||
rust_prost_proto_compile(
|
||||
name = "place_prost",
|
||||
name = "place_rust_proto",
|
||||
declared_proto_packages = ["example.proto"],
|
||||
options = {
|
||||
"//rust:rust_prost_plugin": ["type_attribute=.other.space.Place=#[derive(Eq\\,Hash)]"],
|
||||
},
|
||||
protos = ["@rules_proto_grpc//example/proto:place_proto"],
|
||||
|
||||
prost_proto_deps = []
|
||||
)
|
||||
|
||||
rust_prost_proto_compile(
|
||||
name = "thing_prost",
|
||||
name = "thing_rust_proto",
|
||||
declared_proto_packages = ["example.proto"],
|
||||
options = {
|
||||
# Known limitation, can't derive if the type contains a pbjson type.
|
||||
# "//rust:rust_prost_plugin": ["type_attribute=.other.space.Thing=#[derive(Eq\\,Hash)]"],
|
||||
},
|
||||
protos = ["@rules_proto_grpc//example/proto:thing_proto"],
|
||||
)
|
||||
)
|
||||
|
|
|
@ -141,6 +141,36 @@ var rustTonicGrpcLibraryRuleTemplate = mustTemplate(rustLibraryRuleTemplateStrin
|
|||
{{ .Common.LibraryArgsForwardingSnippet }}
|
||||
)`)
|
||||
|
||||
var rustProtoCompileExampleTemplate = mustTemplate(`load("@rules_proto_grpc//{{ .Lang.Dir }}:defs.bzl", "{{ .Rule.Name }}")
|
||||
|
||||
{{ .Rule.Name }}(
|
||||
name = "person_{{ .Lang.Name }}_{{ .Rule.Kind }}",
|
||||
declared_proto_packages = ["example.proto"],
|
||||
options = {
|
||||
"//rust:rust_prost_plugin": ["type_attribute=.other.space.Person=#[derive(Eq\\,Hash)]"],
|
||||
},
|
||||
protos = ["@rules_proto_grpc//example/proto:person_proto"],
|
||||
)
|
||||
|
||||
{{ .Rule.Name }}(
|
||||
name = "place_{{ .Lang.Name }}_{{ .Rule.Kind }}",
|
||||
declared_proto_packages = ["example.proto"],
|
||||
options = {
|
||||
"//rust:rust_prost_plugin": ["type_attribute=.other.space.Place=#[derive(Eq\\,Hash)]"],
|
||||
},
|
||||
protos = ["@rules_proto_grpc//example/proto:place_proto"],
|
||||
)
|
||||
|
||||
{{ .Rule.Name }}(
|
||||
name = "thing_{{ .Lang.Name }}_{{ .Rule.Kind }}",
|
||||
declared_proto_packages = ["example.proto"],
|
||||
options = {
|
||||
# Known limitation, can't derive if the type contains a pbjson type.
|
||||
# "//rust:rust_prost_plugin": ["type_attribute=.other.space.Thing=#[derive(Eq\\,Hash)]"],
|
||||
},
|
||||
protos = ["@rules_proto_grpc//example/proto:thing_proto"],
|
||||
)`)
|
||||
|
||||
// For rust, produce one library for all protos, since they are all in the same crate
|
||||
var rustProtoLibraryExampleTemplate = mustTemplate(`load("@rules_proto_grpc//{{ .Lang.Dir }}:defs.bzl", "{{ .Rule.Name }}")
|
||||
|
||||
|
@ -206,7 +236,7 @@ func makeRust() *Language {
|
|||
Implementation: rustCompileRuleTemplate,
|
||||
Plugins: []string{"//rust:rust_prost_plugin", "//rust:rust_crate_plugin", "//rust:rust_serde_plugin"},
|
||||
WorkspaceExample: rustWorkspaceTemplate,
|
||||
BuildExample: protoCompileExampleTemplate,
|
||||
BuildExample: rustProtoCompileExampleTemplate,
|
||||
Doc: "Generates Rust protobuf ``.rs`` files using prost",
|
||||
Attrs: compileRuleAttrs,
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue