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

Add protoc command to Makefile #106

Closed
mic-max opened this issue Jun 3, 2022 · 1 comment · Fixed by #598
Closed

Add protoc command to Makefile #106

mic-max opened this issue Jun 3, 2022 · 1 comment · Fixed by #598
Labels
enhancement New feature or request

Comments

@mic-max
Copy link
Contributor

mic-max commented Jun 3, 2022

Feature Request

Add a single protoc command to the Makefile that will compile the demo.proto into all the services directories
Will probably also want to add rules to .gitignore that prevent them from being accidentally committed as well!

@mic-max mic-max added the enhancement New feature or request label Jun 3, 2022
@puckpuck
Copy link
Contributor

puckpuck commented Nov 4, 2022

I have this file in my local setup. After running all IDE compile errors go away and IntelliJ is happy.

._ide-gen-proto.sh

#!/bin/sh

base_dir=$(pwd)


gen_proto_java() {
  cd "$base_dir"/src/"$1" || return
  mkdir -p ./src/main/proto/
  cp -r "$base_dir"/pb/ ./src/main/proto/
  cd "$base_dir" || return
}

gen_proto_dotnet() {
  cd "$base_dir"/src/"$1" || return
  mkdir -p ./src/protos/
  cp -r "$base_dir"/pb/ ./src/protos/
  cd "$base_dir" || return
}

gen_proto_go() {
  cd "$base_dir"/src/"$1" || return
  protoc -I ../../pb ./../../pb/demo.proto --go_out=./ --go-grpc_out=./
  cd "$base_dir" || return
}

gen_proto_python() {
  cd "$base_dir"/src/"$1" || return
  python -m grpc_tools.protoc -I=../../pb --python_out=./ --grpc_python_out=./ ./../../pb/demo.proto
  cd "$base_dir" || return
}

gen_proto_js() {
  cd "$base_dir"/src/"$1" || return
  cp "$base_dir"/pb/demo.proto .
  cd "$base_dir" || return
}

gen_proto_ts() {
  cd "$base_dir"/src/"$1" || return
  cp -r "$base_dir"/pb .
  cd "$base_dir" || return
}

gen_proto_rust() {
  cd "$base_dir"/src/"$1" || return
  mkdir -p proto
  cp "$base_dir"/pb/demo.proto proto/demo.proto
  cargo build -r --features="dockerproto"
  cd "$base_dir" || return
}

gen_proto_elixir() {
  cd "$base_dir"/src/"$1" || return
  cp "$base_dir"/pb/demo.proto ./proto/demo.proto
  rebar3 grpc gen
  cd "$base_dir" || return
}

gen_proto_java adservice
gen_proto_dotnet cartservice
gen_proto_go checkoutservice
# gen_proto_cpp currencyservice
# gen_proto_ruby emailservice
gen_proto_ts frontend
gen_proto_js paymentservice
gen_proto_go productcatalogservice
gen_proto_python recommendationservice
gen_proto_rust shippingservice
# gen_proto_elixir featureflagservice

Looks like I still need to add a few more services to it, but it does the job.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants