• 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("../build/ts.gni")
16if (use_wasm) {
17  import("//gn/wasm.gni")
18}
19if (use_wasm) {
20  ohos_source_set("trace_streamer_builtin") {
21    subsystem_name = "developtools"
22    part_name = "smartperf_host"
23    sources = []
24    include_dirs = []
25    deps = []
26    public_deps = []
27  }
28}
29ohos_source_set("lib") {
30  subsystem_name = "developtools"
31  part_name = "smartperf_host"
32  sources = [ "main.cpp" ]
33  deps = [
34    ":trace_streamer_source",
35    "proto_reader:proto_reader",
36  ]
37  include_dirs = [
38    "base",
39    "..",
40    "trace_streamer",
41    "filter",
42    "table",
43    "trace_data",
44    "include",
45    "rpc",
46    "./",
47    "parser",
48    "cfg",
49    "proto_reader/include",
50    "${THIRD_PARTY}/sqlite/include",
51    "${THIRD_PARTY}/json-master/single_include/nlohmann",
52    "${THIRD_PARTY}/protobuf/src",
53    "${THIRD_PARTY}/hiperf/include",
54  ]
55
56  include_dirs += [
57    "parser/htrace_pbreader_parser",
58    "parser/htrace_pbreader_parser/htrace_event_parser",
59    "parser/htrace_pbreader_parser/htrace_cpu_parser",
60  ]
61
62  if (with_perf) {
63    include_dirs += [
64      "parser/hiperf_parser",
65      "${THIRD_PARTY}/hiperf/include",
66      "${THIRD_PARTY}/hiperf/include/nonlinux",
67      "${THIRD_PARTY}/hiperf/include/nonlinux/linux",
68      "${THIRD_PARTY}/perf_include/musl",
69    ]
70  }
71  public_deps = []
72  if (!use_wasm && !is_test && !is_fuzz) {
73    public_deps += [
74      "${OHOS_PROFILER_3RDPARTY_PROTOBUF_DIR}:protoc",
75      "proto_reader/protoc_plugin:protoreader_plugin",
76    ]
77  }
78}
79ohos_source_set("trace_streamer_source") {
80  subsystem_name = "developtools"
81  part_name = "smartperf_host"
82  sources = [
83    "cfg/trace_streamer_config.cpp",
84    "cfg/trace_streamer_config.h",
85    "rpc/http_server.cpp",
86    "rpc/http_socket.cpp",
87    "rpc/rpc_server.cpp",
88    "trace_streamer/trace_streamer_filters.cpp",
89    "trace_streamer/trace_streamer_filters.h",
90    "trace_streamer/trace_streamer_selector.cpp",
91    "trace_streamer/trace_streamer_selector.h",
92    "version.cpp",
93  ]
94  include_dirs = [
95    "base",
96    "..",
97    "trace_streamer",
98    "filter",
99    "table",
100    "trace_data",
101    "include",
102    "rpc",
103    "./",
104    "parser",
105    "cfg",
106    "proto_reader/include",
107    "parser/ebpf_parser",
108    "${THIRD_PARTY}/sqlite/include",
109    "${THIRD_PARTY}/protobuf/src",
110  ]
111  if (use_wasm) {
112    include_dirs +=
113        [ "../prebuilts/emsdk/emsdk/emscripten/cache/sysroot/include" ]
114  }
115  if (is_macx && !is_test) {
116    cflags = [ "-D_XOPEN_SOURCE=600" ]
117  }
118  if (is_test) {
119    include_dirs += [ "../prebuilts/emsdk/emsdk/emscripten/system/include" ]
120  }
121
122  include_dirs += [
123    "parser/htrace_pbreader_parser",
124    "parser/htrace_pbreader_parser/htrace_event_parser",
125    "parser/htrace_pbreader_parser/htrace_cpu_parser",
126  ]
127
128  include_dirs += [
129    "${THIRD_PARTY}/libunwind/include",
130    "${THIRD_PARTY}/libunwind/src",
131    "${THIRD_PARTY}/json-master/single_include/nlohmann",
132    "${THIRD_PARTY}/hiperf/include",
133    "${THIRD_PARTY}/hiperf/include/nonlinux/linux",
134    "${THIRD_PARTY}/hiperf/include/nonlinux",
135  ]
136
137  if (with_perf) {
138    include_dirs += [
139      "parser/hiperf_parser",
140      "${THIRD_PARTY}/perf_include/libbpf",
141      "${THIRD_PARTY}/perf_include/musl",
142    ]
143  }
144  public_deps = [
145    "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/services:all_type_cpp_standard",
146    "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/cpu_data:cpu_data_encoder",
147    "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/ftrace_data/${device_kernel_version}:ftrace_data_encoder",
148    "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/hilog_data:hilog_data_encoder",
149    "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/hisysevent_data:hisysevent_data_encoder",
150    "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/memory_data:memory_data_encoder",
151  ]
152
153  deps = [
154    "${THIRD_PARTY}/sqlite:sqlite",
155    "base:base",
156    "filter:filter",
157    "parser:parser",
158    "table:table",
159    "trace_data:trace_data",
160  ]
161  if (with_perf) {
162    deps += [ "parser/hiperf_parser:hiperf_parser" ]
163  } else {
164    deps += [ "${THIRD_PARTY}/hiperf:elf" ]
165  }
166
167  if (use_wasm) {
168    sources += [
169      "rpc/wasm_func.cpp",
170      "rpc/wasm_func.h",
171    ]
172  }
173  if (enable_ts_utest && !use_wasm) {
174    cflags = [
175      "-fprofile-arcs",
176      "-ftest-coverage",
177    ]
178    ldflags = [
179      "-fprofile-arcs",
180      "-ftest-coverage",
181      "--coverage",
182    ]
183    if (is_test) {
184      cflags += [ "-D IS_UT" ]
185    }
186  }
187}
188if (use_wasm) {
189  wasm_lib("trace_streamer_builtin_wasm") {
190    name = "trace_streamer_builtin"
191    deps = [ ":lib" ]
192  }
193} else {
194  if (!is_test && !is_fuzz) {
195    executable("trace_streamer") {
196      deps = [ ":lib" ]
197    }
198  }
199}
200