Skip to content

Commit

Permalink
fix grpc: pass python binary to usrv plugin correctly
Browse files Browse the repository at this point in the history
commit_hash:b3a5f01c73626fa5f64eca2d066067056917689a
  • Loading branch information
Anton3 committed Dec 23, 2024
1 parent 0cc5c5f commit 01ab70c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 5 additions & 2 deletions cmake/UserverGrpcTargets.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ function(_userver_prepare_grpc)
REQUIREMENTS "${USERVER_GRPC_SCRIPTS_PATH}/${requirements_name}"
UNIQUE
)
set(ENV{USERVER_GRPC_PYTHON_BINARY} "${USERVER_GRPC_PYTHON_BINARY}")
set_property(GLOBAL PROPERTY userver_grpc_python_binary "${USERVER_GRPC_PYTHON_BINARY}")
endfunction()

_userver_prepare_grpc()
Expand All @@ -97,6 +97,7 @@ function(userver_generate_grpc_files)
cmake_parse_arguments(GEN_RPC "${options}" "${one_value_args}" "${multi_value_args}" ${ARGN})

get_property(USERVER_GRPC_SCRIPTS_PATH GLOBAL PROPERTY userver_grpc_scripts_path)
get_property(USERVER_GRPC_PYTHON_BINARY GLOBAL PROPERTY userver_grpc_python_binary)
get_property(PROTO_GRPC_CPP_PLUGIN GLOBAL PROPERTY userver_grpc_cpp_plugin)
get_property(PROTO_GRPC_PYTHON_PLUGIN GLOBAL PROPERTY userver_grpc_python_plugin)
get_property(PROTOBUF_PROTOC GLOBAL PROPERTY userver_protobuf_protoc)
Expand Down Expand Up @@ -235,7 +236,9 @@ function(userver_generate_grpc_files)
_userver_initialize_codegen_flag()
add_custom_command(
OUTPUT ${generated_cpps} ${generated_usrv_cpps}
COMMAND "${PROTOBUF_PROTOC}" ${protoc_flags} ${proto_abs_paths}
COMMAND
${CMAKE_COMMAND} -E env "USERVER_GRPC_PYTHON_BINARY=${USERVER_GRPC_PYTHON_BINARY}"
"${PROTOBUF_PROTOC}" ${protoc_flags} ${proto_abs_paths}
DEPENDS ${proto_dependencies}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
COMMENT "Running gRPC C++ protocol buffer compiler for ${root_path}"
Expand Down
4 changes: 1 addition & 3 deletions scripts/grpc/protoc_usrv_plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@
GRPC_SCRIPTS_PATH="$(dirname "$(realpath "$0")")"
GEN_USERVER_WRAPPERS="${GRPC_SCRIPTS_PATH}/generator.py"

USERVER_PYTHON="${USERVER_GRPC_PYTHON_BINARY:-python3}"

"${USERVER_PYTHON}" "${GEN_USERVER_WRAPPERS}" "$@"
"${USERVER_GRPC_PYTHON_BINARY}" "${GEN_USERVER_WRAPPERS}" "$@"

0 comments on commit 01ab70c

Please sign in to comment.