-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inline the binary protos #25
Conversation
@@ -101,6 +101,7 @@ public function Name(): string { | |||
} | |||
|
|||
public function FileDescriptorProtoBytes(): string { | |||
return (string)\gzuncompress(\file_get_contents(\realpath(\dirname(__FILE__)) . '/any_file_descriptor.pb.bin.gz')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anything in the generated/
directory is autogenerated through:
bazel run //:gen
The diffs are:
- All the files ending in
.pb.bin.gz
were removed. - We inlined their content in the associated
proto.php
.
// The protoc compiler will complain that this contains invalid UTF-8 data, | ||
// but we will ignore that for now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the reason we need this PR: the complain is turning into an error in newer version of the protoc
.
binaryProtoStr := "" | ||
for i := 0; i < len(binaryProto); i++ { | ||
c := binaryProto[i] | ||
binaryProtoStr += fmt.Sprintf("\\x%x", c) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
%x
prints a single byte in hexadecimal (perfect for the \x??
format in Hacklang)
protoc-gen-hack/plugin.go was generating the gzipped binary ProtoDescriptorProto and returning it to protoc so we could save it to a file. protoc was warning us about having those file's content being invalid UTF-8. Unfortunately newer protoc binary reject files with such a ayload. We do want to keep the binary FileDescriptorProto logic for servers that can send the binary descriptor to their clients but we can inline it in each generated file. While we don't need to gzip the content anymore, I kept this logic as we were generating large binary strings in Hacklang.
9c57b27
to
f50a83b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the inline comments!
Inlining the protobufs in #25 unblocked migrating to newer version of Protobuf as the proto compiler (protoc) error'd.
Inlining the protobufs in #25 unblocked migrating to newer version of Protobuf as the proto compiler (protoc) error'd.
protoc-gen-hack/plugin.go was generating the gzipped binary ProtoDescriptorProto and returning it to protoc so we could save it to a file. protoc was warning us about having those file's content being invalid UTF-8.
Unfortunately newer protoc binary reject files with such a ayload. We do want to keep the binary FileDescriptorProto logic for servers that can send the binary descriptor to their clients but we can inline it in each generated file.
While we don't need to gzip the content anymore, I kept this logic as we were generating large binary strings in Hacklang.