From 3cacecd613d55caa3ac4a4667a33923ca6ac7a22 Mon Sep 17 00:00:00 2001 From: Keivan Ipchi Hagh Date: Tue, 19 Mar 2024 01:30:44 +0330 Subject: [PATCH] feat: update build script --- .gitignore | 2 +- {protobufs => protos/athena}/athena.proto | 2 +- .../athena}/athena_struct.proto | 0 .../candlestick_struct.proto | 0 scripts/build.sh | 23 +++++-------------- 5 files changed, 8 insertions(+), 19 deletions(-) rename {protobufs => protos/athena}/athena.proto (92%) rename {protobufs => protos/athena}/athena_struct.proto (100%) rename {protobufs => protos}/candlestick_struct.proto (100%) diff --git a/.gitignore b/.gitignore index 119d948..4dda365 100644 --- a/.gitignore +++ b/.gitignore @@ -160,4 +160,4 @@ cython_debug/ #.idea/ # other -rpc/ \ No newline at end of file +protos/**/*.py \ No newline at end of file diff --git a/protobufs/athena.proto b/protos/athena/athena.proto similarity index 92% rename from protobufs/athena.proto rename to protos/athena/athena.proto index cff3aef..8e4f8f1 100644 --- a/protobufs/athena.proto +++ b/protos/athena/athena.proto @@ -2,7 +2,7 @@ syntax = "proto3"; package athena.v1; -import "athena_struct.proto"; +import "athena/athena_struct.proto"; import "candlestick_struct.proto"; // [Request] RequestBacktest diff --git a/protobufs/athena_struct.proto b/protos/athena/athena_struct.proto similarity index 100% rename from protobufs/athena_struct.proto rename to protos/athena/athena_struct.proto diff --git a/protobufs/candlestick_struct.proto b/protos/candlestick_struct.proto similarity index 100% rename from protobufs/candlestick_struct.proto rename to protos/candlestick_struct.proto diff --git a/scripts/build.sh b/scripts/build.sh index 3e78809..96d5cd3 100644 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -1,34 +1,23 @@ #!/bin/bash working_dir=$(pwd) -proto_dirs=($(pwd)/protobufs) # ./protobufs/ -python_dir=($(pwd)/rpc) # ./rpc/ - -# Create ./rpc/ dirctory -directory="rpc" -if [ ! -d "$directory" ]; then - # Create the directory - mkdir -p "$directory" - echo "Directory '$directory' created successfully." -else - echo "Directory '$directory' already exists." -fi +proto_dirs=($(pwd)/protos) # ./protos/ # Build *.proto files within the ./protobufs/ directory -for file in $proto_dirs/*.proto; do +for file in $(find "$proto_dirs" -type f); do filename=$(basename "$file") if echo "$filename" | grep -q "struct"; then # Only RPC for structs python3 -m grpc_tools.protoc\ --proto_path=$proto_dirs\ - --python_out=$python_dir\ + --python_out=$proto_dirs\ $file else # RPC and gRPC for non structs python3 -m grpc_tools.protoc\ --proto_path=$proto_dirs\ - --python_out=$python_dir\ - --grpc_python_out=$python_dir\ + --python_out=$proto_dirs\ + --grpc_python_out=$proto_dirs\ $file fi -done \ No newline at end of file +done