• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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}
19
20ohos_source_set("ts_sqlite") {
21  subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}"
22  part_name = "${OHOS_PROFILER_PART_NAME}"
23  sources = [ "//third_party/sqlite/src/sqlite3.c" ]
24  include_dirs = [ "//third_party/sqlite/include" ]
25  cflags = [
26    "-Wno-shorten-64-to-32",
27    "-Wno-double-promotion",
28    "-Wno-disabled-macro-expansion",
29    "-Wno-float-equal",
30    "-Wno-cast-qual",
31    "-Wno-conversion",
32    "-Wno-cast-align",
33    "-Wno-unused-macros",
34    "-Wno-comma",
35    "-Wno-unreachable-code-break",
36    "-Wno-unreachable-code",
37    "-Wno-unreachable-code-return",
38    "-DSQLITE_THREADSAFE=1",
39    "-DQLITE_DEFAULT_MEMSTATUS=0",
40    "-DSQLITE_LIKE_DOESNT_MATCH_BLOBS",
41    "-DSQLITE_OMIT_DEPRECATED",
42    "-DSQLITE_OMIT_SHARED_CACHE",
43    "-DHAVE_USLEEP",
44    "-DHAVE_UTIME",
45    "-DSQLITE_BYTEORDER=1234",
46    "-DSQLITE_DEFAULT_AUTOVACUUM=0",
47    "-DSQLITE_DEFAULT_MMAP_SIZE=0",
48    "-DSQLITE_CORE",
49    "-DSQLITE_TEMP_STORE=3",
50    "-DSQLITE_OMIT_LOAD_EXTENSION",
51    "-DSQLITE_EXPORT_SYMBOLS",
52  ]
53
54  if (is_mingw || is_mac) {
55    include_dirs += [ "${THIRD_PARTY}/libbpf/include/uapi" ]
56  }
57}
58
59config("trace_streamer_cfg") {
60  include_dirs = [ "." ]
61  if (enable_ts_utest && !use_wasm) {
62    cflags = [
63      "-fprofile-arcs",
64      "-ftest-coverage",
65    ]
66    ldflags = [
67      "-fprofile-arcs",
68      "-ftest-coverage",
69      "--coverage",
70    ]
71    if (is_test) {
72      cflags += [ "-D IS_UT" ]
73    }
74  }
75  if (!is_independent_compile) {
76    configs = [ "${TS_DIR}/gn:ts_config" ]
77  }
78  if (is_mingw || is_mac) {
79    include_dirs += [
80      "${THIRD_PARTY}/libbpf/include/uapi",
81      "${THIRD_PARTY}/elfutils/libelf",
82    ]
83  }
84}
85
86ohos_source_set("trace_streamer_source") {
87  subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}"
88  part_name = "${OHOS_PROFILER_PART_NAME}"
89  sources = [
90    "cfg/trace_streamer_config.cpp",
91    "rpc/ffrt_converter.cpp",
92    "rpc/rpc_server.cpp",
93    "trace_streamer/trace_streamer_filters.cpp",
94    "trace_streamer/trace_streamer_selector.cpp",
95    "version.cpp",
96  ]
97  if (!is_test && !is_fuzz) {
98    sources += [ "main.cpp" ]
99  }
100  if (use_wasm) {
101    sources += [ "rpc/wasm_func.cpp" ]
102  }
103  deps = [
104    ":ts_sqlite",
105    "base:base",
106    "filter:filter",
107    "metrics:metrics_parser",
108    "parser:parser",
109    "proto_reader:proto_reader",
110    "table:table",
111    "trace_data:trace_data",
112    "//third_party/bounds_checking_function:libsec_static",
113    "//third_party/perf_include/hiviewdfx:libfaultloggerd",
114  ]
115  public_configs = [ ":trace_streamer_cfg" ]
116  public_deps = []
117  if (!use_wasm && !is_test && !is_fuzz) {
118    public_deps += [
119      "${OHOS_PROFILER_3RDPARTY_PROTOBUF_DIR}:protoc(${host_toolchain})",
120      "proto_reader/protoc_plugin:protoreader_plugin(${host_toolchain})",
121    ]
122  }
123}
124
125if (use_wasm) {
126  ohos_source_set("trace_streamer_builtin") {
127    subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}"
128    part_name = "${OHOS_PROFILER_PART_NAME}"
129    sources = []
130    include_dirs = []
131    deps = []
132    public_deps = []
133  }
134  wasm_lib("trace_streamer_builtin_wasm") {
135    name = "trace_streamer_builtin"
136    deps = [ ":trace_streamer_source" ]
137  }
138} else {
139  if (!is_test && !is_fuzz) {
140    ohos_executable("trace_streamer") {
141      subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}"
142      part_name = "${OHOS_PROFILER_PART_NAME}"
143      sources = []
144      deps = [ ":trace_streamer_source" ]
145    }
146  }
147}
148