1# Copyright (c) Huawei Technologies Co., Ltd. 2023. 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)
20config("public_configs") {
21  include_dirs = [ "$proto_out_dir" ]
22}
23
24#######################################################
25all_type_proto = [
26  "./common_types.proto",
27  "./profiler_service_types.proto",
28  "./plugin_service_types.proto",
29]
30
31all_type_codegen = []
32all_type_codegen_standard = []
33all_type_codegen_reader = []
34all_type_codegen_all = []
35foreach(proto, all_type_proto) {
36  name = get_path_info(proto, "name")
37  all_type_codegen += [
38    "$proto_out_dir/$name.pb.h",
39    "$proto_out_dir/$name.pb.cc",
40  ]
41  all_type_codegen_reader += [ "$proto_out_dir/$name.pbreader.h" ]
42}
43all_type_codegen_all += all_type_codegen
44all_type_codegen_all += all_type_codegen_standard
45all_type_codegen_all += all_type_codegen_reader
46
47action("ts_all_type_gen") {
48  script = "${OHOS_TRACE_STREAMER_DIR_PROTOC}"
49  sources = all_type_proto
50  outputs = all_type_codegen_all
51  args = [
52    "$libc_dir_proto",
53    "$root_output_dir_proto",
54    "$proto_rel_out_dir",  # standard proto file destination path
55    "--cpp_out",
56    "$proto_rel_out_dir",
57    "--proto_path",
58    rebase_path(".", root_build_dir),
59  ]
60  args += rebase_path(sources, root_build_dir)
61  if (!use_wasm && !is_test && !is_fuzz) {
62    deps = [
63      "${OHOS_PROFILER_3RDPARTY_PROTOBUF_DIR}:protoc(${host_toolchain})",
64      "${SRC}/proto_reader/protoc_plugin:protoreader_plugin(${host_toolchain})",
65    ]
66  }
67}
68
69ohos_source_set("ts_all_type_cpp") {
70  subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}"
71  part_name = "${OHOS_PROFILER_PART_NAME}"
72  deps = [ ":ts_all_type_gen" ]
73  public_deps = [
74    "${OHOS_PROFILER_3RDPARTY_PROTOBUF_DIR}:protobuf_lite_static",
75    "${OHOS_PROFILER_3RDPARTY_PROTOBUF_DIR}:protobuf_static",
76  ]
77  include_dirs = [ "$proto_out_dir" ]
78  public_configs = [ ":public_configs" ]
79  sources = all_type_codegen
80}
81ohos_source_set("ts_all_type_cpp_standard") {
82  subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}"
83  part_name = "${OHOS_PROFILER_PART_NAME}"
84  deps = [ ":ts_all_type_gen" ]
85  public_deps = [
86    "${OHOS_PROFILER_3RDPARTY_PROTOBUF_DIR}:protobuf_lite_static",
87    "${OHOS_PROFILER_3RDPARTY_PROTOBUF_DIR}:protobuf_static",
88  ]
89  include_dirs = [ "$proto_out_dir" ]
90  public_configs = [ ":public_configs" ]
91  sources = all_type_codegen_standard
92  subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}"
93  part_name = "${OHOS_PROFILER_PART_NAME}"
94}
95