Skip to content

Commit

Permalink
Merge pull request #7 from IITH-Compilers/default-path
Browse files Browse the repository at this point in the history
Added default Python-Utilities path
  • Loading branch information
svkeerthy authored Jan 22, 2024
2 parents 162e5ce + ea3d41e commit 3418a85
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions MLModelRunner/gRPCModelRunner/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,26 +51,30 @@ foreach(proto ${proto_list})
DEPENDS "${proto}"
)
endforeach()

set( PYTHON_UTILITIES_DIRECTORY "" CACHE PATH "Path to the directory containing the python utilities")
if(NOT PYTHON_UTILITIES_DIRECTORY STREQUAL "")
file(MAKE_DIRECTORY ${PYTHON_UTILITIES_DIRECTORY})
foreach(proto ${proto_list})
get_filename_component(proto_name ${proto} NAME_WLE)
set(proto_python_srcs_list ${proto_python_srcs_list} "${PYTHON_UTILITIES_DIRECTORY}/${proto_name}_pb2.py")

add_custom_command(
OUTPUT "${PYTHON_UTILITIES_DIRECTORY}/${proto_name}_pb2.py"
COMMAND ${_PROTOBUF_PROTOC}
ARGS --grpc_out "${PYTHON_UTILITIES_DIRECTORY}/"
--python_out "${PYTHON_UTILITIES_DIRECTORY}/"
-I "${proto_dir}"
--plugin=protoc-gen-grpc="${_GRPC_PYTHON_PLUGIN_EXECUTABLE}"
"${proto}"
DEPENDS "${proto}"
)
endforeach()
if(PYTHON_UTILITIES_DIRECTORY STREQUAL "")
set(PYTHON_UTILITIES_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Python-Utilities)
endif()

file(MAKE_DIRECTORY ${PYTHON_UTILITIES_DIRECTORY})
foreach(proto ${proto_list})
get_filename_component(proto_name ${proto} NAME_WLE)
set(proto_python_srcs_list ${proto_python_srcs_list} "${PYTHON_UTILITIES_DIRECTORY}/${proto_name}_pb2.py")

add_custom_command(
OUTPUT "${PYTHON_UTILITIES_DIRECTORY}/${proto_name}_pb2.py"
COMMAND ${_PROTOBUF_PROTOC}
ARGS --grpc_out "${PYTHON_UTILITIES_DIRECTORY}/"
--python_out "${PYTHON_UTILITIES_DIRECTORY}/"
-I "${proto_dir}"
--plugin=protoc-gen-grpc="${_GRPC_PYTHON_PLUGIN_EXECUTABLE}"
"${proto}"
DEPENDS "${proto}"
)
endforeach()

# Building the library
if(LLVM_MLBRIDGE)
add_llvm_component_library(gRPCModelRunnerLib
Expand Down

0 comments on commit 3418a85

Please sign in to comment.