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("../../build/ts.gni")
16if (use_wasm) {
17  import("../../gn/wasm.gni")
18}
19if (use_wasm) {
20  ohos_source_set("trace_streamer_sdk_builtin") {
21    subsystem_name = "trace_streamer"
22    part_name = "trace_streamer_sdk_builtin"
23    sources = []
24    include_dirs = []
25    deps = []
26  }
27}
28ohos_source_set("lib") {
29  subsystem_name = "trace_streamer"
30  part_name = "lib"
31  sources = [
32    "main.cpp",
33    "version.cpp",
34  ]
35  deps = [
36    ":trace_streamer_sdk",
37    "${THIRD_PARTY}/protobuf:protobuf_lite_static",
38    "${THIRD_PARTY}/protobuf:protobuf_static",
39  ]
40  include_dirs = [
41    "${SRC}/base",
42    "..",
43    "trace_streamer",
44    "table",
45    "trace_data",
46    "include",
47    "plugin",
48    "rpc",
49    "./",
50    "cfg",
51    "${THIRD_PARTY}/sqlite/include",
52    "${THIRD_PARTY}/protobuf/src",
53  ]
54  public_deps = [ "protos/types/plugins/mock_data:mock_data_cpp" ]
55}
56ohos_source_set("trace_streamer_sdk") {
57  subsystem_name = "trace_streamer"
58  part_name = "trace_streamer_sdk"
59  sources = [
60    "rpc/demo_rpc_server.cpp",
61    "rpc/demo_rpc_server.h",
62    "sdk/sdk_data_parser.cpp",
63    "sdk/sdk_data_parser.h",
64    "sdk/ts_sdk_api.cpp",
65    "sdk/ts_sdk_api.h",
66    "table/demo_meta_table.cpp",
67    "table/demo_meta_table.h",
68    "table/demo_table_base.cpp",
69    "table/gpu_counter_object_table.cpp",
70    "table/gpu_counter_object_table.h",
71    "table/gpu_counter_table.cpp",
72    "table/gpu_counter_table.h",
73    "table/slice_object_table.cpp",
74    "table/slice_object_table.h",
75    "table/slice_table.cpp",
76    "table/slice_table.h",
77    "trace_data/demo_trace_data_cache_reader.cpp",
78    "trace_data/demo_trace_data_cache_reader.h",
79    "trace_data/demo_trace_data_cache_writer.cpp",
80    "trace_data/demo_trace_data_cache_writer.h",
81    "trace_data/demo_trace_data_db.cpp",
82    "trace_data/demo_trace_data_db.h",
83    "trace_data/trace_data_cache.cpp",
84    "trace_data/trace_data_cache.h",
85    "trace_data/trace_data_cache_base.cpp",
86    "trace_data/trace_data_cache_base.h",
87    "trace_data/trace_stdtype.cpp",
88    "trace_data/trace_stdtype.h",
89    "trace_streamer/trace_streamer_selector.cpp",
90    "trace_streamer/trace_streamer_selector.h",
91  ]
92  include_dirs = [
93    "${SRC}/base",
94    "..",
95    "trace_streamer",
96    "filter",
97    "table",
98    "trace_data",
99    "include",
100    "plugin",
101    "rpc",
102    "sdk",
103    "./",
104    "cfg",
105    "${THIRD_PARTY}/sqlite/include",
106    "${THIRD_PARTY}/protobuf/src",
107    "${THIRD_PARTY}/json/single_include/nlohmann",
108    "${THIRD_PARTY}/bounds_checking_function/include",
109  ]
110  deps = [
111    "${SRC}/base:base",
112    "${THIRD_PARTY}/bounds_checking_function:libsec_static",
113    "${THIRD_PARTY}/sqlite:sqlite",
114    "plugin:sdk_plugin",
115  ]
116  public_deps = [ "protos/types/plugins/mock_data:mock_data_cpp" ]
117
118  if (use_wasm || enable_ts_utest) {
119    sources += [
120      "sdk/wasm_func.cpp",
121      "sdk/wasm_func.h",
122    ]
123  }
124  cflags = [ "-std=c++17" ]
125  if (enable_ts_utest && !use_wasm) {
126    cflags = [
127      "-fprofile-arcs",
128      "-ftest-coverage",
129      "-std=c++17",
130    ]
131    ldflags = [
132      "-fprofile-arcs",
133      "-ftest-coverage",
134      "--coverage",
135    ]
136  }
137}
138if (use_wasm) {
139  wasm_lib("trace_streamer_sdk_builtin_wasm") {
140    name = "trace_streamer_sdk_builtin"
141    deps = [ ":lib" ]
142  }
143} else {
144  if (!is_test && !is_fuzz) {
145    executable("trace_streamer111") {
146      deps = [ ":lib" ]
147    }
148  }
149}
150