|
1 | | -This is taken from code.cloudfoundry.org/go-log-cache/rpc/logcache_v1/generate.sh |
| 1 | +This is taken from [github.com/cloudfoundry/go-log-cache/rpc/logcache_v1/generate.sh](https://github.com/cloudfoundry/go-log-cache/blob/main/rpc/logcache_v1/generate.sh) |
2 | 2 |
|
3 | | -To generate the two logcache egress*pb.rb files: |
4 | | - |
5 | | -`grpc_tools_ruby_protoc` comes from doing `gem install grpc-tools` |
| 3 | +To generate the logcache protobuf files: |
6 | 4 |
|
7 | 5 | ``` |
8 | 6 | #!/bin/bash |
9 | 7 |
|
10 | | -
|
11 | | -go get github.com/golang/protobuf/{proto,protoc-gen-go} |
12 | | -go get github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway |
13 | | -go get code.cloudfoundry.org/log-cache |
| 8 | +gem install grpc-tools |
14 | 9 |
|
15 | 10 | tmp_dir=$(mktemp -d) |
16 | | -mkdir -p $tmp_dir/log-cache |
17 | | -
|
18 | | -trash_dir=$(mktemp -d) |
19 | | -
|
20 | | -cp $GOPATH/src/code.cloudfoundry.org/log-cache/api/v1/*proto $tmp_dir/log-cache |
| 11 | +echo "Temp dir: $tmp_dir" |
| 12 | +mkdir -p $tmp_dir/logcache |
21 | 13 |
|
22 | 14 | pushd $tmp_dir |
23 | | - git clone https://github.com/cloudfoundry/loggregator-api |
| 15 | + git clone --depth 1 https://github.com/cloudfoundry/loggregator-api.git |
| 16 | + git clone --depth 1 https://github.com/googleapis/googleapis.git |
| 17 | + mv googleapis/google . |
| 18 | + rm -rf googleapis |
| 19 | +
|
| 20 | + git clone --depth 1 https://github.com/cloudfoundry/go-log-cache.git |
| 21 | + cp go-log-cache/api/v1/*.proto logcache/ |
| 22 | + rm -rf go-log-cache |
24 | 23 | popd |
25 | 24 |
|
26 | | -RUBY_OUT=$trash_dir/log-cache/ruby-out |
27 | | -GRPC_OUT=$trash_dir/log-cache/grpc-out |
28 | | -mkdir -p $RUBY_OUT $GRPC_OUT |
29 | | -grpc_tools_ruby_protoc \ |
30 | | - $tmp_dir/log-cache/*.proto \ |
31 | | - --go_out=plugins=grpc,Mv2/envelope.proto=code.cloudfoundry.org/go-loggregator/rpc/loggregator_v2:. \ |
32 | | - --ruby_out=$RUBY_OUT \ |
33 | | - --grpc_out=$GRPC_OUT \ |
34 | | - --proto_path=$tmp_dir/log-cache \ |
35 | | - --grpc-gateway_out=logtostderr=true:. \ |
36 | | - -I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \ |
37 | | - -I=/usr/local/include \ |
38 | | - -I=$tmp_dir/log-cache \ |
39 | | - -I=$tmp_dir/loggregator-api/. |
40 | | -``` |
41 | | - |
42 | | -You want `$trash_dir/log-cache/ruby-out/egress_pb.rb` and `$trash_dir/log-cache/grpc-out/egress_services_pb.rb` |
43 | | - |
44 | | - |
45 | | -To generate the two v2/envelope_pb.rb file: |
46 | | - |
47 | | -``` |
48 | | -mkdir -p $tmp_dir/loggregator-api |
49 | | -cp $GOPATH/src/code.cloudfoundry.org/loggregator-api/v2/*proto $tmp_dir/loggregator-api/ |
50 | | -
|
51 | | -RUBY_OUT=$trash_dir/loggregator-api/ruby-out |
52 | | -GRPC_OUT=$trash_dir/loggregator-api/grpc-out |
| 25 | +out_dir=$(mktemp -d) |
| 26 | +echo "Out dir: $out_dir" |
| 27 | +RUBY_OUT=$out_dir/ruby-out |
| 28 | +GRPC_OUT=$out_dir/grpc-out |
53 | 29 | mkdir -p $RUBY_OUT $GRPC_OUT |
54 | | -grpc_tools_ruby_protoc \ |
55 | | - $tmp_dir/loggregator-api/*.proto \ |
56 | | - --go_out=plugins=grpc,Mv2/envelope.proto=code.cloudfoundry.org/go-loggregator/rpc/loggregator_v2:. \ |
57 | | - --ruby_out=$RUBY_OUT \ |
58 | | - --grpc_out=$GRPC_OUT \ |
59 | | - --proto_path=$tmp_dir/loggregator-api \ |
60 | | - --grpc-gateway_out=logtostderr=true:. \ |
61 | | - -I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \ |
62 | | - -I=/usr/local/include \ |
63 | | - -I=$tmp_dir/log-cache \ |
64 | | - -I=$GOPATH/src/code.cloudfoundry.org/loggregator-api/. |
65 | 30 |
|
| 31 | +protoc --plugin=protoc-gen-grpc=`which grpc_tools_ruby_protoc_plugin` --proto_path=$tmp_dir --ruby_out=$RUBY_OUT --grpc_out=$GRPC_OUT $tmp_dir/logcache/*.proto |
66 | 32 | ``` |
67 | 33 |
|
68 | | -You want `$trash_dir/ruby-out/envelope_pb.rb` |
| 34 | +Copy `$tmp_dir/ruby_out/logcache/*` and `$tmp_dir/grpc_out/logcache` into `lib/logcache`. |
0 commit comments