pgv: bazel plumbing for PGV support, some PGV related fixups. (#299)
* Added PGV C++ generation support. This (hopefully temporarily) abandons using native proto_library in favor of pgv_cc_proto_library. We maintain build support for proto_library for the glorious future in which we write a Bazel aspect to run PGV against the native proto_library shadow graph. * Replace min_len with min_bytes on strings, until PGV gets not-empty or min_len support for C++. * Various fixups for places where the PGV plugin objected to annotations. Signed-off-by: Harvey Tuch <htuch@google.com>pull/301/head
parent
65bb3f3717
commit
5cdd72f06c
24 changed files with 165 additions and 86 deletions
@ -0,0 +1,14 @@ |
||||
load("//bazel:api_build_system.bzl", "api_cc_test", "api_proto_library") |
||||
|
||||
licenses(["notice"]) # Apache 2 |
||||
|
||||
api_proto_library( |
||||
name = "test", |
||||
srcs = ["test.proto"], |
||||
) |
||||
|
||||
api_cc_test( |
||||
name = "pgv_test", |
||||
srcs = ["pgv_test.cc"], |
||||
proto_deps = [":test"], |
||||
) |
@ -0,0 +1,35 @@ |
||||
#include <iostream> |
||||
#include <cstdlib> |
||||
|
||||
#include "test/validate/test.pb.validate.h" |
||||
|
||||
// Basic protoc-gen-validate C++ validation header inclusion and Validate calls
|
||||
// from data-plane-api.
|
||||
// TODO(htuch): Switch to using real data-plane-api protos once we can support
|
||||
// the required field types.
|
||||
int main(int argc, char *argv[]) { |
||||
{ |
||||
test::validate::Foo empty; |
||||
|
||||
std::string err; |
||||
if (Validate(empty, &err)) { |
||||
std::cout << "Unexpected successful validation of empty proto." |
||||
<< std::endl; |
||||
exit(EXIT_FAILURE); |
||||
} |
||||
} |
||||
|
||||
{ |
||||
test::validate::Foo non_empty; |
||||
non_empty.mutable_baz(); |
||||
|
||||
std::string err; |
||||
if (!Validate(non_empty, &err)) { |
||||
std::cout << "Unexpected failed validation of empty proto: " << err |
||||
<< std::endl; |
||||
exit(EXIT_FAILURE); |
||||
} |
||||
} |
||||
|
||||
exit(EXIT_SUCCESS); |
||||
} |
@ -0,0 +1,13 @@ |
||||
syntax = "proto3"; |
||||
|
||||
package test.validate; |
||||
|
||||
import "validate/validate.proto"; |
||||
|
||||
message Bar { |
||||
uint32 xyz = 1; |
||||
} |
||||
|
||||
message Foo { |
||||
Bar baz = 1 [(.validate.rules).message.required = true]; |
||||
} |
Loading…
Reference in new issue