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 ] 52 53 if (is_mingw || is_mac) { 54 include_dirs += [ "${THIRD_PARTY}/libbpf/include/uapi" ] 55 } 56} 57 58config("trace_streamer_cfg") { 59 include_dirs = [ "." ] 60 if (enable_ts_utest && !use_wasm) { 61 cflags = [ 62 "-fprofile-arcs", 63 "-ftest-coverage", 64 ] 65 ldflags = [ 66 "-fprofile-arcs", 67 "-ftest-coverage", 68 "--coverage", 69 ] 70 if (is_test) { 71 cflags += [ "-D IS_UT" ] 72 } 73 } 74 if (!is_independent_compile) { 75 configs = [ "${TS_DIR}/gn:ts_config" ] 76 } 77 if (is_mingw || is_mac) { 78 include_dirs += [ 79 "${THIRD_PARTY}/libbpf/include/uapi", 80 "${THIRD_PARTY}/elfutils/libelf", 81 ] 82 } 83} 84 85ohos_source_set("trace_streamer_source") { 86 subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" 87 part_name = "${OHOS_PROFILER_PART_NAME}" 88 sources = [ 89 "cfg/trace_streamer_config.cpp", 90 "rpc/ffrt_converter.cpp", 91 "rpc/rpc_server.cpp", 92 "trace_streamer/trace_streamer_filters.cpp", 93 "trace_streamer/trace_streamer_selector.cpp", 94 "version.cpp", 95 ] 96 if (!is_test && !is_fuzz) { 97 sources += [ "main.cpp" ] 98 } 99 if (use_wasm) { 100 sources += [ "rpc/wasm_func.cpp" ] 101 } 102 deps = [ 103 ":ts_sqlite", 104 "base:base", 105 "filter:filter", 106 "metrics:metrics_parser", 107 "parser:parser", 108 "proto_reader:proto_reader", 109 "table:table", 110 "trace_data:trace_data", 111 "//third_party/bounds_checking_function:libsec_static", 112 "//third_party/perf_include/hiviewdfx:libfaultloggerd", 113 ] 114 public_configs = [ ":trace_streamer_cfg" ] 115 public_deps = [] 116 if (!use_wasm && !is_test && !is_fuzz) { 117 public_deps += [ 118 "${OHOS_PROFILER_3RDPARTY_PROTOBUF_DIR}:protoc(${host_toolchain})", 119 "proto_reader/protoc_plugin:protoreader_plugin(${host_toolchain})", 120 ] 121 } 122} 123 124if (use_wasm) { 125 ohos_source_set("trace_streamer_builtin") { 126 subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" 127 part_name = "${OHOS_PROFILER_PART_NAME}" 128 sources = [] 129 include_dirs = [] 130 deps = [] 131 public_deps = [] 132 } 133 wasm_lib("trace_streamer_builtin_wasm") { 134 name = "trace_streamer_builtin" 135 deps = [ ":trace_streamer_source" ] 136 } 137} else { 138 if (!is_test && !is_fuzz) { 139 ohos_executable("trace_streamer") { 140 subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" 141 part_name = "${OHOS_PROFILER_PART_NAME}" 142 sources = [] 143 deps = [ ":trace_streamer_source" ] 144 } 145 } 146} 147