• 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
17proto_types_defines = [
18  "./common_types.proto",
19  "./plugin_service_types.proto",
20  "./profiler_service_types.proto",
21]
22
23plugin_services_defines = [ "./plugin_service.proto" ]
24
25profiler_services_defines = [ "./profiler_service.proto" ]
26
27#######################################################
28proto_out_dir = "$root_gen_dir/cpp/" + rebase_path(".", "//")
29proto_rel_out_dir = rebase_path(proto_out_dir, root_build_dir)
30print("proto_out_dir", proto_out_dir, proto_rel_out_dir)
31
32grpc_cpp_plugin = "$subsys_x64_out/grpc_cpp_plugin"
33ipc_cpp_plugin = "$subsys_x64_out/protoc_gen_ipc"
34
35#######################################################
36proto_types_codegen = []
37foreach(proto, proto_types_defines) {
38  name = get_path_info(proto, "name")
39  proto_types_codegen += [
40    "$proto_out_dir/$name.pb.h",
41    "$proto_out_dir/$name.pb.cc",
42  ]
43}
44
45action("service_types_proto_gen") {
46  script = "${OHOS_PROFILER_DIR}/build/protoc.sh"
47  sources = proto_types_defines
48  outputs = proto_types_codegen
49  args = [
50    "$libc_dir_proto",
51    "$root_output_dir_proto",
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
64config("service_types_proto_config") {
65  include_dirs = [ "$proto_out_dir" ]
66}
67
68ohos_source_set("service_types_proto") {
69  deps = [ ":service_types_proto_gen" ]
70  public_deps = [
71    "${OHOS_PROFILER_3RDPARTY_PROTOBUF_DIR}:protobuf",
72    "${OHOS_PROFILER_3RDPARTY_PROTOBUF_DIR}:protobuf_lite",
73  ]
74  include_dirs = [ "$proto_out_dir" ]
75  public_configs = [ ":service_types_proto_config" ]
76  sources = proto_types_codegen
77}
78
79ohos_source_set("service_types_proto_static") {
80  deps = [ ":service_types_proto_gen" ]
81  public_deps = [
82    "${OHOS_PROFILER_3RDPARTY_PROTOBUF_DIR}:protobuf_lite_static",
83    "${OHOS_PROFILER_3RDPARTY_PROTOBUF_DIR}:protobuf_static",
84  ]
85  include_dirs = [ "$proto_out_dir" ]
86  public_configs = [ ":service_types_proto_config" ]
87  sources = proto_types_codegen
88}
89
90#######################################################
91profiler_services_codegen = []
92foreach(proto, profiler_services_defines) {
93  name = get_path_info(proto, "name")
94  profiler_services_codegen += [
95    "$proto_out_dir/$name.pb.h",
96    "$proto_out_dir/$name.pb.cc",
97    "$proto_out_dir/$name.grpc.pb.h",
98    "$proto_out_dir/$name.grpc.pb.cc",
99  ]
100}
101
102action("profiler_services_proto_gen") {
103  script = "${OHOS_PROFILER_DIR}/build/protoc.sh"
104  sources = profiler_services_defines
105  outputs = profiler_services_codegen
106  args = [
107    "$libc_dir_proto",
108    "$root_output_dir_proto",
109    "--plugin=protoc-gen-grpc=$grpc_cpp_plugin",
110    "--grpc_out",
111    "$proto_rel_out_dir",
112    "--cpp_out",
113    "$proto_rel_out_dir",
114    "--proto_path",
115    rebase_path(".", root_build_dir),
116  ]
117  args += rebase_path(sources, root_build_dir)
118  deps = [
119    "${OHOS_PROFILER_3RDPARTY_GRPC_DIR}:grpc_cpp_plugin(${host_toolchain})",
120    "${OHOS_PROFILER_3RDPARTY_PROTOBUF_DIR}:protoc(${host_toolchain})",
121  ]
122}
123
124config("profiler_services_proto_config") {
125  include_dirs = [ "$proto_out_dir" ]
126}
127
128ohos_source_set("profiler_services_proto") {
129  deps = [
130    ":profiler_services_proto_gen",
131    ":service_types_proto",
132  ]
133  public_deps = [
134    "${OHOS_PROFILER_3RDPARTY_GRPC_DIR}:grpc",
135    "${OHOS_PROFILER_3RDPARTY_GRPC_DIR}:grpcxx",
136    "${OHOS_PROFILER_3RDPARTY_PROTOBUF_DIR}:protobuf",
137    "${OHOS_PROFILER_3RDPARTY_PROTOBUF_DIR}:protobuf_lite",
138  ]
139  include_dirs = [ "$proto_out_dir" ]
140  public_configs = [ ":profiler_services_proto_config" ]
141  sources = profiler_services_codegen
142}
143
144#######################################################
145plugin_services_codegen = []
146foreach(proto, plugin_services_defines) {
147  name = get_path_info(proto, "name")
148  plugin_services_codegen += [
149    "$proto_out_dir/$name.pb.h",
150    "$proto_out_dir/$name.pb.cc",
151    "$proto_out_dir/$name.ipc.h",
152    "$proto_out_dir/$name.ipc.cc",
153  ]
154}
155
156action("plugin_services_proto_gen") {
157  script = "${OHOS_PROFILER_DIR}/build/protoc.sh"
158  sources = plugin_services_defines
159  outputs = plugin_services_codegen
160  args = [
161    "$libc_dir_proto",
162    "$root_output_dir_proto",
163    "--plugin=protoc-gen-ipc=$ipc_cpp_plugin",
164    "--ipc_out",
165    "$proto_rel_out_dir",
166    "--cpp_out",
167    "$proto_rel_out_dir",
168    "--proto_path",
169    rebase_path(".", root_build_dir),
170  ]
171  args += rebase_path(sources, root_build_dir)
172  deps = [
173    "${OHOS_PROFILER_3RDPARTY_PROTOBUF_DIR}:protoc(${host_toolchain})",
174    "${OHOS_PROFILER_DIR}/device/services/ipc:protoc_gen_ipc(${host_toolchain})",
175  ]
176}
177
178config("plugin_services_proto_config") {
179  include_dirs = [ "$proto_out_dir" ]
180}
181
182ohos_source_set("plugin_services_proto") {
183  deps = [
184    ":plugin_services_proto_gen",
185    ":service_types_proto",
186  ]
187  public_deps = [
188    "${OHOS_PROFILER_3RDPARTY_PROTOBUF_DIR}:protobuf",
189    "${OHOS_PROFILER_3RDPARTY_PROTOBUF_DIR}:protobuf_lite",
190    "${OHOS_PROFILER_DIR}/device/services/ipc:ipc",
191  ]
192  include_dirs = [
193    "$proto_out_dir",
194    "${OHOS_PROFILER_DIR}/device/services/ipc/include",
195  ]
196  public_configs = [ ":plugin_services_proto_config" ]
197  sources = plugin_services_codegen
198}
199
200ohos_source_set("plugin_services_proto_static") {
201  deps = [
202    ":plugin_services_proto_gen",
203    ":service_types_proto_static",
204  ]
205  public_deps = [
206    "${OHOS_PROFILER_3RDPARTY_PROTOBUF_DIR}:protobuf_lite_static",
207    "${OHOS_PROFILER_3RDPARTY_PROTOBUF_DIR}:protobuf_static",
208    "${OHOS_PROFILER_DIR}/device/services/ipc:ipc",
209  ]
210  include_dirs = [
211    "$proto_out_dir",
212    "${OHOS_PROFILER_DIR}/device/services/ipc/include",
213  ]
214  public_configs = [ ":plugin_services_proto_config" ]
215  sources = plugin_services_codegen
216}
217
218#######################################################
219ohos_source_set("proto_services_cpp") {
220  public_deps = [
221    ":plugin_services_proto",
222    ":profiler_services_proto",
223    ":service_types_proto",
224  ]
225}
226