# Copyright (C) 2021 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import("../build/ohos.gni") import("../build/ts.gni") if (use_wasm) { import("//gn/wasm.gni") } if (use_wasm) { ohos_source_set("trace_streamer_builtin") { subsystem_name = "developtools" part_name = "smartperf_host" sources = [] include_dirs = [] deps = [] public_deps = [] } } ohos_source_set("lib") { subsystem_name = "developtools" part_name = "smartperf_host" sources = [ "main.cpp" ] deps = [ ":trace_streamer_source", "proto_reader:proto_reader", ] include_dirs = [ "base", "..", "trace_streamer", "filter", "table", "trace_data", "include", "rpc", "./", "parser", "cfg", "proto_reader/include", "${THIRD_PARTY}/sqlite/include", "${THIRD_PARTY}/json-master/single_include/nlohmann", "${THIRD_PARTY}/protobuf/src", "${THIRD_PARTY}/hiperf/include", ] include_dirs += [ "parser/htrace_pbreader_parser", "parser/htrace_pbreader_parser/htrace_event_parser", "parser/htrace_pbreader_parser/htrace_cpu_parser", ] if (with_perf) { include_dirs += [ "parser/hiperf_parser", "${THIRD_PARTY}/hiperf/include", "${THIRD_PARTY}/hiperf/include/nonlinux", "${THIRD_PARTY}/hiperf/include/nonlinux/linux", "${THIRD_PARTY}/perf_include/musl", ] } public_deps = [] if (!use_wasm && !is_test && !is_fuzz) { public_deps += [ "${OHOS_PROFILER_3RDPARTY_PROTOBUF_DIR}:protoc", "proto_reader/protoc_plugin:protoreader_plugin", ] } } ohos_source_set("trace_streamer_source") { subsystem_name = "developtools" part_name = "smartperf_host" sources = [ "cfg/trace_streamer_config.cpp", "cfg/trace_streamer_config.h", "rpc/http_server.cpp", "rpc/http_socket.cpp", "rpc/rpc_server.cpp", "trace_streamer/trace_streamer_filters.cpp", "trace_streamer/trace_streamer_filters.h", "trace_streamer/trace_streamer_selector.cpp", "trace_streamer/trace_streamer_selector.h", "version.cpp", ] include_dirs = [ "base", "..", "trace_streamer", "filter", "table", "trace_data", "include", "rpc", "./", "parser", "cfg", "proto_reader/include", "parser/ebpf_parser", "${THIRD_PARTY}/sqlite/include", "${THIRD_PARTY}/protobuf/src", ] if (use_wasm) { include_dirs += [ "../prebuilts/emsdk/emsdk/emscripten/cache/sysroot/include" ] } if (is_macx && !is_test) { cflags = [ "-D_XOPEN_SOURCE=600" ] } if (is_test) { include_dirs += [ "../prebuilts/emsdk/emsdk/emscripten/system/include" ] } include_dirs += [ "parser/htrace_pbreader_parser", "parser/htrace_pbreader_parser/htrace_event_parser", "parser/htrace_pbreader_parser/htrace_cpu_parser", ] include_dirs += [ "${THIRD_PARTY}/libunwind/include", "${THIRD_PARTY}/libunwind/src", "${THIRD_PARTY}/json-master/single_include/nlohmann", "${THIRD_PARTY}/hiperf/include", "${THIRD_PARTY}/hiperf/include/nonlinux/linux", "${THIRD_PARTY}/hiperf/include/nonlinux", ] if (with_perf) { include_dirs += [ "parser/hiperf_parser", "${THIRD_PARTY}/perf_include/libbpf", "${THIRD_PARTY}/perf_include/musl", ] } public_deps = [ "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/services:all_type_cpp_standard", "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/cpu_data:cpu_data_encoder", "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/ftrace_data/${device_kernel_version}:ftrace_data_encoder", "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/hilog_data:hilog_data_encoder", "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/hisysevent_data:hisysevent_data_encoder", "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/memory_data:memory_data_encoder", ] deps = [ "${THIRD_PARTY}/sqlite:sqlite", "base:base", "filter:filter", "parser:parser", "table:table", "trace_data:trace_data", ] if (with_perf) { deps += [ "parser/hiperf_parser:hiperf_parser" ] } else { deps += [ "${THIRD_PARTY}/hiperf:elf" ] } if (use_wasm) { sources += [ "rpc/wasm_func.cpp", "rpc/wasm_func.h", ] } if (enable_ts_utest && !use_wasm) { cflags = [ "-fprofile-arcs", "-ftest-coverage", ] ldflags = [ "-fprofile-arcs", "-ftest-coverage", "--coverage", ] if (is_test) { cflags += [ "-D IS_UT" ] } } } if (use_wasm) { wasm_lib("trace_streamer_builtin_wasm") { name = "trace_streamer_builtin" deps = [ ":lib" ] } } else { if (!is_test && !is_fuzz) { executable("trace_streamer") { deps = [ ":lib" ] } } }