• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2021 Huawei Device Co., Ltd.
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
21grpc_cpp_plugin = "$subsys_x64_out/grpc_cpp_plugin"
22ipc_cpp_plugin = "$subsys_x64_out/protoc_gen_ipc"
23
24config("public_configs") {
25  include_dirs = [ "$proto_out_dir" ]
26}
27
28#######################################################
29all_type_proto = [
30  "./common_types.proto",
31  "./profiler_service_types.proto",
32  "./plugin_service_types.proto",
33]
34
35all_type_codegen = []
36foreach(proto, all_type_proto) {
37  name = get_path_info(proto, "name")
38  all_type_codegen += [
39    "$proto_out_dir/$name.pb.h",
40    "$proto_out_dir/$name.pb.cc",
41  ]
42}
43
44action("all_type_gen") {
45  script = "${OHOS_PROFILER_DIR}/build/protoc.sh"
46  sources = all_type_proto
47  outputs = all_type_codegen
48  args = [
49    "$libc_dir_proto",
50    "$root_output_dir_proto",
51    "$proto_rel_out_dir",  # standard proto file destination path
52    "--cpp_out",
53    "$proto_rel_out_dir",
54    "--proto_path",
55    rebase_path(".", root_build_dir),
56  ]
57  args += rebase_path(sources, root_build_dir)
58  deps = [
59    "${OHOS_PROFILER_3RDPARTY_GRPC_DIR}:grpc_cpp_plugin(${host_toolchain})",
60    "${OHOS_PROFILER_3RDPARTY_PROTOBUF_DIR}:protoc(${host_toolchain})",
61  ]
62}
63
64########################################################
65profiler_service_type_proto = [
66  "./common_types.proto",
67  "./profiler_service_types.proto",
68]
69
70profiler_service_type_codegen = []
71foreach(proto, profiler_service_type_proto) {
72  name = get_path_info(proto, "name")
73  profiler_service_type_codegen += [
74    "$proto_out_dir/$name.pb.h",
75    "$proto_out_dir/$name.pb.cc",
76  ]
77}
78
79ohos_source_set("profiler_service_type_source") {
80  deps = [ ":all_type_gen" ]
81  public_deps = [
82    "${OHOS_PROFILER_3RDPARTY_PROTOBUF_DIR}:protobuf",
83    "${OHOS_PROFILER_3RDPARTY_PROTOBUF_DIR}:protobuf_lite",
84  ]
85  include_dirs = [ "$proto_out_dir" ]
86  public_configs = [ ":public_configs" ]
87  sources = profiler_service_type_codegen
88}
89
90ohos_source_set("profiler_service_all_type_source") {
91  deps = [ ":all_type_gen" ]
92  public_deps = [
93    "${OHOS_PROFILER_3RDPARTY_PROTOBUF_DIR}:protobuf",
94    "${OHOS_PROFILER_3RDPARTY_PROTOBUF_DIR}:protobuf_lite",
95  ]
96  include_dirs = [ "$proto_out_dir" ]
97  public_configs = [ ":public_configs" ]
98  sources = all_type_codegen
99}
100
101########################################################
102profiler_service_interface_proto = [ "./profiler_service.proto" ]
103
104profiler_service_interface_codegen = []
105foreach(proto, profiler_service_interface_proto) {
106  name = get_path_info(proto, "name")
107  profiler_service_interface_codegen += [
108    "$proto_out_dir/$name.pb.h",
109    "$proto_out_dir/$name.pb.cc",
110    "$proto_out_dir/$name.grpc.pb.h",
111    "$proto_out_dir/$name.grpc.pb.cc",
112  ]
113}
114
115action("profiler_service_interface_gen") {
116  script = "${OHOS_PROFILER_DIR}/build/protoc.sh"
117  sources = profiler_service_interface_proto
118  outputs = profiler_service_interface_codegen
119  args = [
120    "$libc_dir_proto",
121    "$root_output_dir_proto",
122    "$proto_rel_out_dir",  # standard proto file destination path
123    "--plugin=protoc-gen-grpc=$grpc_cpp_plugin",
124    "--grpc_out",
125    "$proto_rel_out_dir",
126    "--cpp_out",
127    "$proto_rel_out_dir",
128    "--proto_path",
129    rebase_path(".", root_build_dir),
130  ]
131  args += rebase_path(sources, root_build_dir)
132  deps = [
133    ":all_type_gen",
134    "${OHOS_PROFILER_3RDPARTY_GRPC_DIR}:grpc_cpp_plugin(//build/toolchain/linux:clang_x64)",
135    "${OHOS_PROFILER_3RDPARTY_PROTOBUF_DIR}:protoc(//build/toolchain/linux:clang_x64)",
136  ]
137}
138
139ohos_source_set("profiler_service_proto") {
140  deps = [
141    ":all_type_gen",
142    ":profiler_service_interface_gen",
143  ]
144  public_deps = [
145    "${OHOS_PROFILER_3RDPARTY_GRPC_DIR}:grpc",
146    "${OHOS_PROFILER_3RDPARTY_GRPC_DIR}:grpcxx",
147    "${OHOS_PROFILER_3RDPARTY_PROTOBUF_DIR}:protobuf",
148    "${OHOS_PROFILER_3RDPARTY_PROTOBUF_DIR}:protobuf_lite",
149  ]
150  include_dirs = [ "$proto_out_dir" ]
151  public_configs = [ ":public_configs" ]
152  sources = profiler_service_interface_codegen
153}
154
155########################################################
156plugin_service_type_proto = [
157  "./common_types.proto",
158  "./plugin_service_types.proto",
159]
160
161plugin_service_type_codegen = []
162foreach(proto, plugin_service_type_proto) {
163  name = get_path_info(proto, "name")
164  plugin_service_type_codegen += [
165    "$proto_out_dir/$name.pb.h",
166    "$proto_out_dir/$name.pb.cc",
167  ]
168}
169
170########################################################
171plugin_service_interface_proto = [ "./plugin_service.proto" ]
172
173plugin_service_interface_codegen = []
174foreach(proto, plugin_service_interface_proto) {
175  name = get_path_info(proto, "name")
176  plugin_service_interface_codegen += [
177    "$proto_out_dir/$name.pb.h",
178    "$proto_out_dir/$name.pb.cc",
179    "$proto_out_dir/$name.ipc.h",
180    "$proto_out_dir/$name.ipc.cc",
181  ]
182}
183
184action("plugin_service_interface_proto_gen") {
185  script = "${OHOS_PROFILER_DIR}/build/protoc.sh"
186  sources = plugin_service_interface_proto
187  outputs = plugin_service_interface_codegen
188  args = [
189    "$libc_dir_proto",
190    "$root_output_dir_proto",
191    "$proto_rel_out_dir",  # standard proto file destination path
192    "--plugin=protoc-gen-ipc=$ipc_cpp_plugin",
193    "--ipc_out",
194    "$proto_rel_out_dir",
195    "--cpp_out",
196    "$proto_rel_out_dir",
197    "--proto_path",
198    rebase_path(".", root_build_dir),
199  ]
200  args += rebase_path(sources, root_build_dir)
201  deps = [
202    ":all_type_gen",
203    "${OHOS_PROFILER_3RDPARTY_PROTOBUF_DIR}:protoc(${host_toolchain})",
204    "${OHOS_PROFILER_DIR}/device/services/ipc:protoc_gen_ipc(${host_toolchain})",
205  ]
206}
207
208ohos_source_set("plugin_service_proto") {
209  deps = [
210    ":all_type_gen",
211    ":plugin_service_interface_proto_gen",
212  ]
213  public_deps = [
214    "${OHOS_PROFILER_3RDPARTY_PROTOBUF_DIR}:protobuf",
215    "${OHOS_PROFILER_3RDPARTY_PROTOBUF_DIR}:protobuf_lite",
216    "${OHOS_PROFILER_DIR}/device/services/ipc:ipc",
217  ]
218  include_dirs = [
219    "$proto_out_dir",
220    "${OHOS_PROFILER_DIR}/device/services/ipc/include",
221  ]
222  public_configs = [ ":public_configs" ]
223  sources = plugin_service_interface_codegen
224}
225
226#######################################################
227ohos_source_set("proto_services_cpp") {
228  public_deps = [
229    ":plugin_service_proto",
230    ":profiler_service_all_type_source",
231    ":profiler_service_proto",
232  ]
233}
234