internal/cmd/generate-protos: initial commit
Create a single binary for handling generation of protos.
This replaces previous logic spread throughout the repo in:
* regenerate.bash
* cmd/protoc-gen-go/golden_test.go
* cmd/protoc-gen-go-grpc/golden_test.go
* (indirectly) internal/protogen/goldentest
One of the problems with the former approaches is that they relied on
a version of protoc that was specific to a developer's workstation.
This meant that the result of generation was not hermetic.
To address this, we rely on the hard-coded version of protobuf specified
in the test.bash script.
A summary of changes in this CL are:
* The internal_gengo.GenerateFile and internal_gengogrpc.GenerateFile
functions are unified to have consistent signatures. It seems that the
former accepted a *protogen.GeneratedFile to support v1 where gRPC code
was generated into the same file as the base .pb.go file. However, the
same functionality can be achieved by having the function return
the generated file object.
* The test.bash script patches the protobuf toolchain to have properly
specified go_package options in each proto source file.
* The test.bash script accepts a "-regenerate" argument.
* Add generation for the well-known types. Contrary to how these were
laid out in the v1 repo, all the well-known types are placed in the
same Go package.
* Add generation for the conformance proto.
* Remove regenerate.bash
* Remove internal/protogen
* Remove cmd/protoc-gen-go/golden_test.go
* Remove cmd/protoc-gen-go-grpc/golden_test.go
* Add cmd/protoc-gen-go/annotation_test.go
Change-Id: I4a1a97ae6f66e2fabcf4e4d292c95ab2a2db0248
Reviewed-on: https://go-review.googlesource.com/c/164477
Reviewed-by: Damien Neil <dneil@google.com>
diff --git a/internal/testprotos/test/test_weak.pb.go b/internal/testprotos/test/test_weak.pb.go
index 9b0583f..e42f7ff 100644
--- a/internal/testprotos/test/test_weak.pb.go
+++ b/internal/testprotos/test/test_weak.pb.go
@@ -1,5 +1,5 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
-// source: test_weak.proto
+// source: test/test_weak.proto
package test
@@ -24,13 +24,13 @@
}
func (m *WeakImportMessage) ProtoReflect() protoreflect.Message {
- return xxx_File_test_weak_proto_messageTypes[0].MessageOf(m)
+ return xxx_File_test_test_weak_proto_messageTypes[0].MessageOf(m)
}
func (m *WeakImportMessage) Reset() { *m = WeakImportMessage{} }
func (m *WeakImportMessage) String() string { return proto.CompactTextString(m) }
func (*WeakImportMessage) ProtoMessage() {}
func (*WeakImportMessage) Descriptor() ([]byte, []int) {
- return xxx_File_test_weak_proto_rawdesc_gzipped, []int{0}
+ return xxx_File_test_test_weak_proto_rawdesc_gzipped, []int{0}
}
func (m *WeakImportMessage) XXX_Unmarshal(b []byte) error {
@@ -52,47 +52,47 @@
var xxx_messageInfo_WeakImportMessage proto.InternalMessageInfo
func init() {
- proto.RegisterFile("test_weak.proto", xxx_File_test_weak_proto_rawdesc_gzipped)
+ proto.RegisterFile("test/test_weak.proto", xxx_File_test_test_weak_proto_rawdesc_gzipped)
proto.RegisterType((*WeakImportMessage)(nil), "goproto.proto.test.WeakImportMessage")
}
-var xxx_File_test_weak_proto_rawdesc = []byte{
- // 116 bytes of the wire-encoded FileDescriptorProto
- 0x0a, 0x0f, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x77, 0x65, 0x61, 0x6b, 0x2e, 0x70, 0x72, 0x6f, 0x74,
- 0x6f, 0x12, 0x12, 0x67, 0x6f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
- 0x2e, 0x74, 0x65, 0x73, 0x74, 0x22, 0x13, 0x0a, 0x11, 0x57, 0x65, 0x61, 0x6b, 0x49, 0x6d, 0x70,
- 0x6f, 0x72, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x42, 0x38, 0x5a, 0x36, 0x67, 0x69,
- 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x2f,
- 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x76, 0x32, 0x2f, 0x69, 0x6e, 0x74, 0x65,
- 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2f,
- 0x74, 0x65, 0x73, 0x74,
+var xxx_File_test_test_weak_proto_rawdesc = []byte{
+ // 121 bytes of the wire-encoded FileDescriptorProto
+ 0x0a, 0x14, 0x74, 0x65, 0x73, 0x74, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x77, 0x65, 0x61, 0x6b,
+ 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x12, 0x67, 0x6f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e,
+ 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x22, 0x13, 0x0a, 0x11, 0x57, 0x65,
+ 0x61, 0x6b, 0x49, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x42,
+ 0x38, 0x5a, 0x36, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f,
+ 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x76, 0x32,
+ 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x70, 0x72,
+ 0x6f, 0x74, 0x6f, 0x73, 0x2f, 0x74, 0x65, 0x73, 0x74,
}
-var xxx_File_test_weak_proto_rawdesc_gzipped = protoapi.CompressGZIP(xxx_File_test_weak_proto_rawdesc)
+var xxx_File_test_test_weak_proto_rawdesc_gzipped = protoapi.CompressGZIP(xxx_File_test_test_weak_proto_rawdesc)
const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
-var File_test_weak_proto protoreflect.FileDescriptor
+var File_test_test_weak_proto protoreflect.FileDescriptor
-var xxx_File_test_weak_proto_messageTypes [1]protoimpl.MessageType
-var xxx_File_test_weak_proto_goTypes = []interface{}{
+var xxx_File_test_test_weak_proto_messageTypes [1]protoimpl.MessageType
+var xxx_File_test_test_weak_proto_goTypes = []interface{}{
(*WeakImportMessage)(nil), // 0: goproto.proto.test.WeakImportMessage
}
-var xxx_File_test_weak_proto_depIdxs = []int32{}
+var xxx_File_test_test_weak_proto_depIdxs = []int32{}
func init() {
var messageTypes [1]protoreflect.MessageType
- File_test_weak_proto = protoimpl.FileBuilder{
- RawDescriptor: xxx_File_test_weak_proto_rawdesc,
- GoTypes: xxx_File_test_weak_proto_goTypes,
- DependencyIndexes: xxx_File_test_weak_proto_depIdxs,
+ File_test_test_weak_proto = protoimpl.FileBuilder{
+ RawDescriptor: xxx_File_test_test_weak_proto_rawdesc,
+ GoTypes: xxx_File_test_test_weak_proto_goTypes,
+ DependencyIndexes: xxx_File_test_test_weak_proto_depIdxs,
MessageOutputTypes: messageTypes[:],
}.Init()
- messageGoTypes := xxx_File_test_weak_proto_goTypes[0:][:1]
+ messageGoTypes := xxx_File_test_test_weak_proto_goTypes[0:][:1]
for i, mt := range messageTypes[:] {
- xxx_File_test_weak_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
- xxx_File_test_weak_proto_messageTypes[i].PBType = mt
+ xxx_File_test_test_weak_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
+ xxx_File_test_test_weak_proto_messageTypes[i].PBType = mt
}
- xxx_File_test_weak_proto_goTypes = nil
- xxx_File_test_weak_proto_depIdxs = nil
+ xxx_File_test_test_weak_proto_goTypes = nil
+ xxx_File_test_test_weak_proto_depIdxs = nil
}