Skip to content

Commit 37e6333

Browse files
committed
Move proto generation code block out of if(WITH_MGR_DASHBOARD_FRONTEND).
- This ensures protos are built during the RPM build process. - gitignore the sourced gateway.proto file. Signed-off-by: Paulo E. Castro <[email protected]>
1 parent 7f2e191 commit 37e6333

File tree

2 files changed

+30
-29
lines changed

2 files changed

+30
-29
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,5 +99,6 @@ src/pybind/rgw/rgw.c
9999
src/pybind/rgw/rgw.egg-info/
100100

101101
# GRPC protobuff file generation #PR 61089
102+
src/pybind/mgr/dashboard/services/proto/gateway.proto
102103
src/pybind/mgr/dashboard/services/proto/gateway_pb2.py
103104
src/pybind/mgr/dashboard/services/proto/gateway_pb2_grpc.py

src/pybind/mgr/dashboard/CMakeLists.txt

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,32 @@
1+
# Required for building the dashboard grpc protos at build time
2+
set(CEPH_GRPC_VIRTUALENV ${CEPH_BUILD_VIRTUALENV}/ceph-grpc-virtualenv)
3+
set(CEPH_NVME_GATEWAY_PROTO_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/nvmeof/gateway/control/proto)
4+
5+
add_custom_command(
6+
OUTPUT ${CEPH_GRPC_VIRTUALENV}/lib/python*/site-packages/grpc_tools
7+
COMMAND ${CMAKE_SOURCE_DIR}/src/tools/setup-virtualenv.sh --python=${Python3_EXECUTABLE} ${CEPH_GRPC_VIRTUALENV}
8+
COMMAND ${CEPH_GRPC_VIRTUALENV}/bin/pip install grpcio-tools
9+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
10+
COMMENT "grpcio-tools is being installed")
11+
12+
# protobuffer files generation
13+
add_custom_command(
14+
OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/services/proto/gateway_pb2.py" "${CMAKE_CURRENT_SOURCE_DIR}/services/proto/gateway_pb2_grpc.py"
15+
COMMAND cp ${CEPH_NVME_GATEWAY_PROTO_DIR}/gateway.proto dashboard/services/proto/gateway.proto
16+
COMMAND . ${CEPH_GRPC_VIRTUALENV}/bin/activate && ${CEPH_GRPC_VIRTUALENV}/bin/python -m grpc_tools.protoc --proto_path=. --python_out=. --grpc_python_out=. dashboard/services/proto/gateway.proto && deactivate
17+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/..
18+
DEPENDS ${CEPH_NVME_GATEWAY_PROTO_DIR}/gateway.proto ${CEPH_GRPC_VIRTUALENV}/lib/python*/site-packages/grpc_tools
19+
COMMENT "proto generation for grpc deps")
20+
add_custom_target(mgr-dashboard-services-deps
21+
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/services/proto/gateway_pb2.py ${CMAKE_CURRENT_SOURCE_DIR}/services/proto/gateway_pb2_grpc.py
22+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
23+
24+
add_custom_target(mgr-dashboard-services-build
25+
ALL
26+
DEPENDS mgr-dashboard-services-deps)
27+
28+
add_dependencies(tests mgr-dashboard-services-build)
29+
130
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
231
DESTINATION ${CEPH_INSTALL_DATADIR}/mgr
332
${mgr_module_install_excludes}
@@ -15,35 +44,6 @@ if(WITH_MGR_DASHBOARD_FRONTEND)
1544
add_tox_test(mgr-dashboard-openapi TOX_ENVS openapi-check)
1645
endif()
1746

18-
# Required for building the dashboard grpc protos at build time
19-
set(CEPH_GRPC_VIRTUALENV ${CEPH_BUILD_VIRTUALENV}/ceph-grpc-virtualenv)
20-
set(CEPH_NVME_GATEWAY_PROTO_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/nvmeof/gateway/control/proto)
21-
22-
add_custom_command(
23-
OUTPUT ${CEPH_GRPC_VIRTUALENV}/lib/python*/site-packages/grpc_tools
24-
COMMAND ${CMAKE_SOURCE_DIR}/src/tools/setup-virtualenv.sh --python=${Python3_EXECUTABLE} ${CEPH_GRPC_VIRTUALENV}
25-
COMMAND ${CEPH_GRPC_VIRTUALENV}/bin/pip install grpcio-tools
26-
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
27-
COMMENT "grpcio-tools is being installed")
28-
29-
# protobuffer files generation
30-
add_custom_command(
31-
OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/services/proto/gateway_pb2.py" "${CMAKE_CURRENT_SOURCE_DIR}/services/proto/gateway_pb2_grpc.py"
32-
COMMAND cp ${CEPH_NVME_GATEWAY_PROTO_DIR}/gateway.proto dashboard/services/proto/gateway.proto
33-
COMMAND . ${CEPH_GRPC_VIRTUALENV}/bin/activate && ${CEPH_GRPC_VIRTUALENV}/bin/python -m grpc_tools.protoc --proto_path=. --python_out=. --grpc_python_out=. dashboard/services/proto/gateway.proto && deactivate
34-
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/..
35-
DEPENDS ${CEPH_NVME_GATEWAY_PROTO_DIR}/gateway.proto ${CEPH_GRPC_VIRTUALENV}/lib/python*/site-packages/grpc_tools
36-
COMMENT "proto generation for grpc deps")
37-
add_custom_target(mgr-dashboard-services-deps
38-
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/services/proto/gateway_pb2.py ${CMAKE_CURRENT_SOURCE_DIR}/services/proto/gateway_pb2_grpc.py
39-
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
40-
41-
add_custom_target(mgr-dashboard-services-build
42-
ALL
43-
DEPENDS mgr-dashboard-services-deps)
44-
45-
add_dependencies(tests mgr-dashboard-services-build)
46-
4747
else()
4848
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/frontend/dist)
4949
# prebuilt

0 commit comments

Comments
 (0)