Skip to content
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

build: update protoc generate to latest type. #158

Merged
merged 3 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
# protocol
# protocol

```shell
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
```

More to read [regenerate-grpc-code](https://grpc.io/docs/languages/go/quickstart/#regenerate-grpc-code).
14 changes: 12 additions & 2 deletions gen.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,27 @@ set "PROTO_NAMES=auth conversation errinfo relation group jssdk msg msggateway p

rem Loop through each element in the array
for %%i in (%PROTO_NAMES%) do (
protoc --go_out=plugins=grpc:./%%i --go_opt=module=github.com/openimsdk/protocol/%%i %%i/%%i.proto
protoc --go_out=./%%i --go_opt=module=github.com/openimsdk/protocol/%%i %%i/%%i.proto
if ERRORLEVEL 1 (
echo error processing %%i.proto
exit /b %ERRORLEVEL%
)
)

rem Generate Go-grpc code (optional, currently commented out)

rem for %%i in (%PROTO_NAMES%) do (
rem protoc --go-grpc_out=./%%i --go-grpc_opt=module=github.com/openimsdk/protocol/%%i %%i/%%i.proto
rem if ERRORLEVEL 1 (
rem echo error processing %%i.proto (go-grpc_out)
rem exit /b %ERRORLEVEL%
rem )
rem )


rem Replace "omitempty" in *.pb.go files with UTF-8 encoding
for /r %%f in (*.pb.go) do (
powershell -Command "(Get-Content -Path '%%f' -Encoding UTF8) -replace ',omitempty\"`"', '\"`"' | Set-Content -Path '%%f' -Encoding UTF8"
)


endlocal
28 changes: 12 additions & 16 deletions gen.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

PROTO_NAMES=(
"auth"
"conversation"
Expand All @@ -31,13 +17,23 @@ PROTO_NAMES=(
)

for name in "${PROTO_NAMES[@]}"; do
protoc --go_out=plugins=grpc:./${name} --go_opt=module=github.com/openimsdk/protocol/${name} ${name}/${name}.proto
protoc --go_out=./${name} --go_opt=module=github.com/openimsdk/protocol/${name} ${name}/${name}.proto
if [ $? -ne 0 ]; then
echo "error processing ${name}.proto"
echo "error processing ${name}.proto (go_out)"
exit $?
fi
done

# generate go-grpc

# for name in "${PROTO_NAMES[@]}"; do
# protoc --go-grpc_out=./${name} --go-grpc_opt=module=github.com/openimsdk/protocol/${name} ${name}/${name}.proto
# if [ $? -ne 0 ]; then
# echo "error processing ${name}.proto (go-grpc_out)"
# exit $?
# fi
# done

if [ "$(uname -s)" == "Darwin" ]; then
find . -type f -name '*.pb.go' -exec sed -i '' 's/,omitempty"`/\"\`/g' {} +
else
Expand Down
28 changes: 12 additions & 16 deletions gen_openmeeting.sh
Original file line number Diff line number Diff line change
@@ -1,31 +1,27 @@
# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

PROTO_NAMES=(
"admin"
"user"
"meeting"
)

for name in "${PROTO_NAMES[@]}"; do
protoc --go_out=plugins=grpc:./openmeeting/${name} --go_opt=module=github.com/openimsdk/protocol/openmeeting/${name} openmeeting/${name}/${name}.proto
protoc --go_out=./openmeeting/${name} --go_opt=module=github.com/openimsdk/protocol/openmeeting/${name} openmeeting/${name}/${name}.proto
if [ $? -ne 0 ]; then
echo "error processing ${name}.proto"
echo "error processing ${name}.proto (go_out)"
exit $?
fi
done

# generate go-grpc

# for name in "${PROTO_NAMES[@]}"; do
# protoc --go-grpc_out=./openmeeting/${name} --go_opt=module=github.com/openimsdk/protocol/openmeeting/${name} openmeeting/${name}/${name}.proto
# if [ $? -ne 0 ]; then
# echo "error processing ${name}.proto (go-grpc_out)"
# exit $?
# fi
# done

if [ "$(uname -s)" == "Darwin" ]; then
find . -type f -name '*.pb.go' -exec sed -i '' 's/,omitempty"`/\"\`/g' {} +
else
Expand Down