-
Notifications
You must be signed in to change notification settings - Fork 4
refactor: add setup.sh en lieu of Makefile #68
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
56f7834
build: remove Makefile, add setup.sh
antoniaelsen 9b4b40d
chore: lint
antoniaelsen 7af89ed
chore: update setup.sh
antoniaelsen 76b6c60
chore: update Makefile
antoniaelsen 1925f76
chore: update Makefile
antoniaelsen d510048
chore: update README.md
antoniaelsen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,24 +1,15 @@ | ||
| PROJECT_NAME := synapsectl | ||
| PROTOC := python -m grpc_tools.protoc | ||
| PROTO_DIR := ./synapse-api | ||
| PROTO_OUT := ./synapse | ||
| PROTOS := $(shell find ${PROTO_DIR} -name '*.proto' | sed 's|${PROTO_DIR}/||') | ||
|
|
||
| .PHONY: all | ||
| all: clean generate | ||
| all: | ||
| ./setup.sh all | ||
|
|
||
| .PHONY: clean | ||
| clean: | ||
| rm -rf bin ${PROTO_OUT}/api* | ||
| ./setup.sh clean | ||
|
|
||
| .PHONY: generate | ||
| generate: | ||
| mkdir -p bin | ||
| mkdir -p ${PROTO_OUT} | ||
| ${PROTOC} -I=${PROTO_DIR} --descriptor_set_out=bin/descriptors.binpb ${PROTOS} | ||
| ${PROTOC} -I=${PROTO_DIR} --python_out=${PROTO_OUT} ${PROTOS} | ||
| ${PROTOC} -I=${PROTO_DIR} --grpc_python_out=${PROTO_OUT} api/synapse.proto | ||
| protol --create-package --in-place --python-out ${PROTO_OUT} raw bin/descriptors.binpb | ||
| ./setup.sh generate | ||
|
|
||
| .PHONY: test | ||
| test: | ||
| pytest -v | ||
| ./setup.sh test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Define variables | ||
| PROTOC="python -m grpc_tools.protoc" | ||
| PROTO_DIR_SYNAPSE_API="./synapse-api" | ||
| PROTO_OUT_SYNAPSE_API="./synapse" | ||
|
|
||
| clean() { | ||
| echo "Cleaning up..." | ||
| rm -rf bin "${PROTO_OUT_SYNAPSE_API}/api"* | ||
| } | ||
|
|
||
| generate_protos() { | ||
| local input_proto_dir="$1" | ||
| local output_proto_dir="$2" | ||
| local service_proto="$3" | ||
|
|
||
| if [ -z "$input_proto_dir" ]; then | ||
| echo "Error: input proto directory is required" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [ -z "$output_proto_dir" ]; then | ||
| echo "Error: output proto directory is required" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [ -z "$service_proto" ]; then | ||
| echo "Error: service proto file is required" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "Generating protobuf files..." | ||
| echo "- input: ${input_proto_dir}" | ||
| echo "- output: ${output_proto_dir}" | ||
| echo "- service: ${service_proto}" | ||
|
|
||
| mkdir -p bin | ||
| mkdir -p "${output_proto_dir}" | ||
|
|
||
| # Store proto files in an array | ||
| PROTOS=($(find "${input_proto_dir}" -name "*.proto" | sed "s|${input_proto_dir}/||")) | ||
|
|
||
| # Generate descriptor set | ||
| ${PROTOC} -I="${input_proto_dir}" --descriptor_set_out=bin/descriptors.binpb "${PROTOS[@]}" | ||
|
|
||
| # Generate Python files | ||
| ${PROTOC} -I="${input_proto_dir}" --python_out="${output_proto_dir}" "${PROTOS[@]}" | ||
|
|
||
| # Generate gRPC Python files | ||
| ${PROTOC} -I="${input_proto_dir}" --grpc_python_out="${output_proto_dir}" "${service_proto}" | ||
|
|
||
| # Run protol | ||
| protol --create-package --in-place --python-out "${output_proto_dir}" raw bin/descriptors.binpb | ||
| } | ||
|
|
||
| generate() { | ||
| generate_protos "${PROTO_DIR_SYNAPSE_API}" "${PROTO_OUT_SYNAPSE_API}" "api/synapse.proto" | ||
| } | ||
|
|
||
| run_tests() { | ||
| echo "Running tests..." | ||
| pytest -v | ||
| } | ||
|
|
||
| # Main script logic | ||
| case "$1" in | ||
| "clean") | ||
| clean | ||
| ;; | ||
| "generate") | ||
| generate | ||
| ;; | ||
| "test") | ||
| run_tests | ||
| ;; | ||
| "all") | ||
| clean | ||
| generate | ||
| ;; | ||
| *) | ||
| echo "Usage: $0 {clean|generate|test|all}" | ||
| echo "For generate: $0 generate [input_proto_dir] [output_proto_dir] [service_proto]" | ||
| exit 1 | ||
| ;; | ||
| esac | ||
|
|
||
| exit 0 | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I think this generate helper doesn't take arguments anymore.