• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5#
6#     http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
14import("//build/ohos.gni")
15import("../protos.gni")
16
17#######################################################
18proto_out_dir = "$root_gen_dir/cpp/" + rebase_path(".", "//")
19proto_rel_out_dir = rebase_path(proto_out_dir, root_build_dir)
20
21if (ohos_indep_compiler_enable) {
22  grpc_dir_plugin = rebase_path("//binarys/third_party")
23  grpc_cpp_plugin = "$grpc_dir_plugin/grpc/innerapis/grpc_cpp_plugin/clang_x64/libs/grpc_cpp_plugin"
24} else {
25  grpc_cpp_plugin = "$subsys_x64_out/grpc_cpp_plugin"
26}
27
28ipc_cpp_plugin = "$proto_gen_ipc_dir/protoc_gen_ipc"
29
30config("public_configs") {
31  include_dirs = [ "$proto_out_dir" ]
32}
33
34#######################################################
35all_type_proto = [
36  "./common_types.proto",
37  "./profiler_service_types.proto",
38  "./plugin_service_types.proto",
39]
40
41common_type_proto = [ "./common_types.proto" ]
42
43all_type_codegen = []
44foreach(proto, all_type_proto) {
45  name = get_path_info(proto, "name")
46  all_type_codegen += [
47    "$proto_out_dir/$name.pb.h",
48    "$proto_out_dir/$name.pb.cc",
49  ]
50}
51
52lite_codegen = []
53foreach(proto, common_type_proto) {
54  name = get_path_info(proto, "name")
55  lite_codegen += [
56    "$proto_out_dir/${name}_lite.pb.h",
57    "$proto_out_dir/${name}_lite.pb.cc",
58  ]
59}
60
61action("all_type_gen") {
62  script = "${OHOS_PROFILER_DIR}/build/protoc.sh"
63  sources = all_type_proto
64  outputs = all_type_codegen
65  outputs += lite_codegen
66  args = [
67    "$libc_dir_proto",
68    "$root_output_dir_proto",
69    "$proto_rel_out_dir",  # standard proto file destination path
70    "--cpp_out",
71    "$proto_rel_out_dir",
72    "--proto_path",
73    rebase_path(".", root_build_dir),
74  ]
75  args += rebase_path(sources, root_build_dir)
76  args += [ "$ohos_indep_compiler_enable" ]
77  deps = [ "${OHOS_PROFILER_DIR}/device/services/ipc:protoencoder_plugin(${host_toolchain})" ]
78  external_deps = [
79    "grpc:grpc_cpp_plugin(${host_toolchain})",
80    "protobuf:protoc(${host_toolchain})",
81  ]
82}
83
84########################################################
85profiler_service_type_proto = [
86  "./common_types.proto",
87  "./profiler_service_types.proto",
88]
89
90profiler_service_type_codegen = []
91foreach(proto, profiler_service_type_proto) {
92  name = get_path_info(proto, "name")
93  profiler_service_type_codegen += [
94    "$proto_out_dir/$name.pb.h",
95    "$proto_out_dir/$name.pb.cc",
96  ]
97}
98
99ohos_source_set("profiler_service_type_source") {
100  deps = [ ":all_type_gen" ]
101  external_deps = [
102    "protobuf:protobuf_lite",
103  ]
104  include_dirs = [ "$proto_out_dir" ]
105  public_configs = [ ":public_configs" ]
106  sources = profiler_service_type_codegen
107  subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}"
108  part_name = "${OHOS_PROFILER_PART_NAME}"
109}
110
111ohos_source_set("profiler_service_all_type_source") {
112  deps = [ ":all_type_gen" ]
113  external_deps = [
114    "protobuf:protobuf_lite",
115  ]
116  include_dirs = [ "$proto_out_dir" ]
117  public_configs = [ ":public_configs" ]
118  sources = all_type_codegen
119  subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}"
120  part_name = "${OHOS_PROFILER_PART_NAME}"
121}
122
123########################################################
124profiler_service_interface_proto = [ "./profiler_service.proto" ]
125
126profiler_service_interface_codegen = []
127foreach(proto, profiler_service_interface_proto) {
128  name = get_path_info(proto, "name")
129  profiler_service_interface_codegen += [
130    "$proto_out_dir/$name.pb.h",
131    "$proto_out_dir/$name.pb.cc",
132    "$proto_out_dir/$name.grpc.pb.h",
133    "$proto_out_dir/$name.grpc.pb.cc",
134  ]
135}
136
137action("profiler_service_interface_gen") {
138  script = "${OHOS_PROFILER_DIR}/build/protoc.sh"
139  sources = profiler_service_interface_proto
140  outputs = profiler_service_interface_codegen
141  args = [
142    "$libc_dir_proto",
143    "$root_output_dir_proto",
144    "$proto_rel_out_dir",  # standard proto file destination path
145    "--plugin=protoc-gen-grpc=$grpc_cpp_plugin",
146    "--grpc_out",
147    "$proto_rel_out_dir",
148    "--cpp_out",
149    "$proto_rel_out_dir",
150    "--proto_path",
151    rebase_path(".", root_build_dir),
152  ]
153  args += rebase_path(sources, root_build_dir)
154  args += [ "$ohos_indep_compiler_enable" ]
155  deps = [ ":all_type_gen" ]
156  external_deps = [
157    "grpc:grpc_cpp_plugin(//build/toolchain/linux:clang_${host_cpu})",
158    "protobuf:protoc(//build/toolchain/linux:clang_${host_cpu})",
159  ]
160}
161
162ohos_source_set("profiler_service_proto") {
163  deps = [
164    ":all_type_gen",
165    ":profiler_service_interface_gen",
166  ]
167  external_deps = [
168    "abseil-cpp:absl_sync",
169    "grpc:grpc",
170    "grpc:grpcxx",
171    "protobuf:protobuf",
172    "protobuf:protobuf_lite",
173  ]
174  include_dirs = [ "$proto_out_dir" ]
175  public_configs = [ ":public_configs" ]
176  sources = profiler_service_interface_codegen
177  subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}"
178  part_name = "${OHOS_PROFILER_PART_NAME}"
179}
180
181########################################################
182plugin_service_type_proto = [
183  "./common_types.proto",
184  "./plugin_service_types.proto",
185]
186
187plugin_service_type_codegen = []
188foreach(proto, plugin_service_type_proto) {
189  name = get_path_info(proto, "name")
190  plugin_service_type_codegen += [
191    "$proto_out_dir/$name.pb.h",
192    "$proto_out_dir/$name.pb.cc",
193  ]
194}
195
196########################################################
197plugin_service_interface_proto = [ "./plugin_service.proto" ]
198
199plugin_service_interface_codegen = []
200foreach(proto, plugin_service_interface_proto) {
201  name = get_path_info(proto, "name")
202  plugin_service_interface_codegen += [
203    "$proto_out_dir/$name.pb.h",
204    "$proto_out_dir/$name.pb.cc",
205    "$proto_out_dir/$name.ipc.h",
206    "$proto_out_dir/$name.ipc.cc",
207  ]
208}
209
210action("plugin_service_interface_proto_gen") {
211  script = "${OHOS_PROFILER_DIR}/build/protoc.sh"
212  sources = plugin_service_interface_proto
213  outputs = plugin_service_interface_codegen
214  args = [
215    "$libc_dir_proto",
216    "$root_output_dir_proto",
217    "$proto_rel_out_dir",  # standard proto file destination path
218    "--plugin=protoc-gen-ipc=$ipc_cpp_plugin",
219    "--ipc_out",
220    "$proto_rel_out_dir",
221    "--cpp_out",
222    "$proto_rel_out_dir",
223    "--proto_path",
224    rebase_path(".", root_build_dir),
225  ]
226  args += rebase_path(sources, root_build_dir)
227  args += [ "$ohos_indep_compiler_enable" ]
228  deps = [
229    ":all_type_gen",
230    "${OHOS_PROFILER_DIR}/device/services/ipc:protoc_gen_ipc(${host_toolchain})",
231  ]
232  external_deps = [ "protobuf:protoc(${host_toolchain})" ]
233}
234
235ohos_source_set("plugin_service_proto") {
236  deps = [
237    ":all_type_gen",
238    ":plugin_service_interface_proto_gen",
239  ]
240  public_deps = [ "${OHOS_PROFILER_DIR}/device/services/ipc:ipc" ]
241  external_deps = [
242    "protobuf:protobuf_lite",
243  ]
244  include_dirs = [
245    "$proto_out_dir",
246    "${OHOS_PROFILER_DIR}/device/services/ipc/include",
247  ]
248  public_configs = [ ":public_configs" ]
249  sources = plugin_service_interface_codegen
250  subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}"
251  part_name = "${OHOS_PROFILER_PART_NAME}"
252}
253
254#######################################################
255ohos_source_set("proto_services_cpp") {
256  public_deps = [
257    ":plugin_service_proto",
258    ":profiler_service_all_type_source",
259    ":profiler_service_proto",
260  ]
261  subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}"
262  part_name = "${OHOS_PROFILER_PART_NAME}"
263}
264
265ohos_source_set("common_types_lite_proto") {
266  deps = [ ":all_type_gen" ]
267  external_deps = [
268    "protobuf:protobuf_lite",
269  ]
270  include_dirs = [ "$proto_out_dir" ]
271  public_configs = [ ":public_configs" ]
272  sources = lite_codegen
273  subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}"
274  part_name = "${OHOS_PROFILER_PART_NAME}"
275}
276