blob: accf473e45dfbf8882c545d2c52f92fcb0aec341 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
From 466309bc0aafe61ebed5c71012e28b9912783b60 Mon Sep 17 00:00:00 2001
From: Xuepeng Xu <xuxuepeng1@huawei.com>
Date: Thu, 9 Feb 2023 14:32:59 +0800
Subject: [PATCH 03/53] Add macro for protoc cmake
Signed-off-by: Xuepeng Xu <xuxuepeng1@huawei.com>
---
cmake/protoc.cmake | 98 +++++++++++++---------------------------------
1 file changed, 28 insertions(+), 70 deletions(-)
diff --git a/cmake/protoc.cmake b/cmake/protoc.cmake
index 5c433e5c..23b8c077 100644
--- a/cmake/protoc.cmake
+++ b/cmake/protoc.cmake
@@ -11,89 +11,47 @@ if (ENABLE_NATIVE_NETWORK)
set(NETWORK_PROTOS_OUT_PATH ${GRPC_OUT_PRE_PATH}/src/api/services/network)
endif()
+macro(PROTOC_CPP_GEN proto_name cpp_out_path proto_path)
+ execute_process(COMMAND ${CMD_PROTOC} -I ${PROTOS_PATH}/${proto_name} --cpp_out=${cpp_out_path} ${proto_path} ERROR_VARIABLE cpp_err)
+ if (cpp_err)
+ message("Parse ${proto_path} failed: ")
+ message(FATAL_ERROR ${cpp_err})
+ endif()
+endmacro(PROTOC_CPP_GEN)
+
+macro(PROTOC_GRPC_GEN proto_name grpc_out_path proto_path)
+ execute_process(COMMAND ${CMD_PROTOC} -I ${PROTOS_PATH}/${proto_name} --grpc_out=${grpc_out_path} --plugin=protoc-gen-grpc=${CMD_GRPC_CPP_PLUGIN} ${proto_path} ERROR_VARIABLE grpc_err)
+ if (grpc_err)
+ message("Parse ${proto_path} failed: ")
+ message(FATAL_ERROR ${grpc_err})
+ endif()
+endmacro(PROTOC_GRPC_GEN)
+
if (GRPC_CONNECTOR)
execute_process(COMMAND mkdir -p ${CONTAINER_PROTOS_OUT_PATH})
execute_process(COMMAND mkdir -p ${IMAGE_PROTOS_OUT_PATH})
execute_process(COMMAND mkdir -p ${VOLUME_PROTOS_OUT_PATH})
execute_process(COMMAND mkdir -p ${CRI_PROTOS_OUT_PATH})
- execute_process(COMMAND ${CMD_PROTOC} -I ${PROTOS_PATH}/containers --cpp_out=${CONTAINER_PROTOS_OUT_PATH}
- ${PROTOS_PATH}/containers/container.proto ERROR_VARIABLE containers_err)
- if (containers_err)
- message("Parse ${PROTOS_PATH}/containers/container.proto failed: ")
- message(FATAL_ERROR ${containers_err})
- endif()
- execute_process(COMMAND ${CMD_PROTOC} -I ${PROTOS_PATH}/containers --grpc_out=${CONTAINER_PROTOS_OUT_PATH} --plugin=protoc-gen-grpc=${CMD_GRPC_CPP_PLUGIN} ${PROTOS_PATH}/containers/container.proto ERROR_VARIABLE containers_err)
- if (containers_err)
- message("Parse ${PROTOS_PATH}/containers/container.proto plugin failed: ")
- message(FATAL_ERROR ${containers_err})
- endif()
+ PROTOC_CPP_GEN(containers ${CONTAINER_PROTOS_OUT_PATH} ${PROTOS_PATH}/containers/container.proto)
+ PROTOC_GRPC_GEN(containers ${CONTAINER_PROTOS_OUT_PATH} ${PROTOS_PATH}/containers/container.proto)
- execute_process(COMMAND ${CMD_PROTOC} -I ${PROTOS_PATH}/images --cpp_out=${IMAGE_PROTOS_OUT_PATH} ${PROTOS_PATH}/images/images.proto ERROR_VARIABLE images_err)
- if (images_err)
- message("Parse ${PROTOS_PATH}/images/images.proto failed: ")
- message(FATAL_ERROR ${images_err})
- endif()
+ PROTOC_CPP_GEN(images ${IMAGE_PROTOS_OUT_PATH} ${PROTOS_PATH}/images/images.proto)
+ PROTOC_GRPC_GEN(images ${IMAGE_PROTOS_OUT_PATH} ${PROTOS_PATH}/images/images.proto)
- execute_process(COMMAND ${CMD_PROTOC} -I ${PROTOS_PATH}/images --grpc_out=${IMAGE_PROTOS_OUT_PATH} --plugin=protoc-gen-grpc=${CMD_GRPC_CPP_PLUGIN} ${PROTOS_PATH}/images/images.proto ERROR_VARIABLE images_err)
- if (images_err)
- message("Parse ${PROTOS_PATH}/images/images.proto plugin failed: ")
- message(FATAL_ERROR ${images_err})
- endif()
+ PROTOC_CPP_GEN(volumes ${VOLUME_PROTOS_OUT_PATH} ${PROTOS_PATH}/volumes/volumes.proto)
+ PROTOC_GRPC_GEN(volumes ${VOLUME_PROTOS_OUT_PATH} ${PROTOS_PATH}/volumes/volumes.proto)
- execute_process(COMMAND ${CMD_PROTOC} -I ${PROTOS_PATH}/volumes --cpp_out=${VOLUME_PROTOS_OUT_PATH} ${PROTOS_PATH}/volumes/volumes.proto ERROR_VARIABLE volumes_err)
- if (volumes_err)
- message("Parse ${PROTOS_PATH}/volumes/volumes.proto failed: ")
- message(FATAL_ERROR ${volumes_err})
- endif()
+ PROTOC_CPP_GEN(cri ${CRI_PROTOS_OUT_PATH} ${PROTOS_PATH}/cri/api.proto)
+ PROTOC_GRPC_GEN(cri ${CRI_PROTOS_OUT_PATH} ${PROTOS_PATH}/cri/api.proto)
- execute_process(COMMAND ${CMD_PROTOC} -I ${PROTOS_PATH}/volumes --grpc_out=${VOLUME_PROTOS_OUT_PATH} --plugin=protoc-gen-grpc=${CMD_GRPC_CPP_PLUGIN} ${PROTOS_PATH}/volumes/volumes.proto ERROR_VARIABLE volumes_err)
- if (volumes_err)
- message("Parse ${PROTOS_PATH}/volumes/volumes.proto plugin failed: ")
- message(FATAL_ERROR ${volumes_err})
- endif()
-
- execute_process(COMMAND ${CMD_PROTOC} -I ${PROTOS_PATH}/cri --cpp_out=${CRI_PROTOS_OUT_PATH} ${PROTOS_PATH}/cri/api.proto
- ERROR_VARIABLE cri_err)
- if (cri_err)
- message("Parse ${PROTOS_PATH}/cri/api.proto failed: ")
- message(FATAL_ERROR ${cri_err})
- endif()
-
- execute_process(COMMAND ${CMD_PROTOC} -I ${PROTOS_PATH}/cri --grpc_out=${CRI_PROTOS_OUT_PATH}
- --plugin=protoc-gen-grpc=${CMD_GRPC_CPP_PLUGIN} ${PROTOS_PATH}/cri/api.proto ERROR_VARIABLE cri_err)
- if (cri_err)
- message("Parse ${PROTOS_PATH}/cri/api.proto plugin failed: ")
- message(FATAL_ERROR ${cri_err})
- endif()
- execute_process(COMMAND ${CMD_PROTOC} -I ${PROTOS_PATH}/cri --cpp_out=${CRI_PROTOS_OUT_PATH} ${PROTOS_PATH}/cri/gogo.proto
- ERROR_VARIABLE cri_err)
- if (cri_err)
- message("Parse ${PROTOS_PATH}/cri/gogo.proto failed: ")
- message(FATAL_ERROR ${cri_err})
- endif()
- execute_process(COMMAND ${CMD_PROTOC} -I ${PROTOS_PATH}/cri --grpc_out=${CRI_PROTOS_OUT_PATH}
- --plugin=protoc-gen-grpc=${CMD_GRPC_CPP_PLUGIN} ${PROTOS_PATH}/cri/gogo.proto ERROR_VARIABLE cri_err)
- if (cri_err)
- message("Parse ${PROTOS_PATH}/cri/gogo.proto plugin failed: ")
- message(FATAL_ERROR ${cri_err})
- endif()
+ PROTOC_CPP_GEN(cri ${CRI_PROTOS_OUT_PATH} ${PROTOS_PATH}/cri/gogo.proto)
+ PROTOC_GRPC_GEN(cri ${CRI_PROTOS_OUT_PATH} ${PROTOS_PATH}/cri/gogo.proto)
if (ENABLE_NATIVE_NETWORK)
execute_process(COMMAND mkdir -p ${NETWORK_PROTOS_OUT_PATH})
- execute_process(COMMAND ${CMD_PROTOC} -I ${PROTOS_PATH}/network
- --cpp_out=${NETWORK_PROTOS_OUT_PATH} ${PROTOS_PATH}/network/network.proto ERROR_VARIABLE network_err)
- if (network_err)
- message("Parse ${PROTOS_PATH}/network/network.proto failed: ")
- message(FATAL_ERROR ${network_err})
- endif()
-
- execute_process(COMMAND ${CMD_PROTOC} -I ${PROTOS_PATH}/network --grpc_out=${NETWORK_PROTOS_OUT_PATH}
- --plugin=protoc-gen-grpc=${CMD_GRPC_CPP_PLUGIN} ${PROTOS_PATH}/network/network.proto ERROR_VARIABLE network_err)
- if (network_err)
- message("Parse ${PROTOS_PATH}/network/network.proto plugin failed: ")
- message(FATAL_ERROR ${network_err})
- endif()
+ PROTOC_CPP_GEN(network ${NETWORK_PROTOS_OUT_PATH} ${PROTOS_PATH}/network/network.proto)
+ PROTOC_GRPC_GEN(network ${NETWORK_PROTOS_OUT_PATH} ${PROTOS_PATH}/network/network.proto)
endif()
endif()
--
2.25.1
|