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