# Copyright (c) 2023 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("//base/hiviewdfx/faultloggerd/faultloggerd.gni") if (!defined(ohos_lite)) { callstack_sources = [ "src/callstack.cpp", "src/register.cpp", ] config("common_callstack_config") { visibility = [ ":*" ] include_dirs = [ "include", "$faultloggerd_path/common", ] defines = [ "HAVE_LIBUNWIND" ] cflags = [ "-Wno-unused-private-field" ] ldflags = [] if (is_mingw) { # lld: error: unable to find library -latomic # lld: error: unable to find library -ldl # lld: error: unable to find library -lrt ldflags += [ "-Wl,--whole-archive", "-lpthread", "-Wl,--no-whole-archive", ] } else if (is_linux) { ldflags += [ "-lpthread", "-latomic", "-ldl", "-lrt", "-Wl,--no-whole-archive", ] } cflags += [ "-std=c++17" ] defines += [ "is_mingw=${is_mingw}" ] if (is_ohos) { defines += [ "CALLSTACK_PRINT_LOG" ] } if (is_mingw) { cflags += [ "-includeMingW64Fix.h" ] defines += [ "WIN32_LEAN_AND_MEAN" ] defines += [ "__LITTLE_ENDIAN_BITFIELD" ] include_dirs += [ "../../../../../../developtools/hiperf/include/nonlinux/", "../../../../../../kernel/linux/patches/linux-5.10/prebuilts/usr/include", ] } } config("hiperf_callstack_config") { defines = [ "HIPERF_USE_CALLSTACK" ] include_dirs = [ "../../../../../../developtools/hiperf/include" ] } config("nativedaemon_callstack_config") { defines = [ "NATIVEDAEMON_USE_CALLSTACK" ] include_dirs = [ "../../../../../../developtools/profiler/device/plugins/native_daemon/include" ] } # callstack_perf static library only support for hiperf currently. # some configs have to be exposed. ohos_static_library("callstack_perf") { public_configs = [ ":common_callstack_config", ":hiperf_callstack_config", "../../../../../../commonlibrary/c_utils/base:utils_config", "//third_party/bounds_checking_function:libsec_public_config", "//third_party/googletest:gtest_config", "$faultloggerd_path/common/build:coverage_flags", ] include_dirs = [ "$faultloggerd_path/common/dfxlog", "$faultloggerd_path/common/dfxutil", ] sources = callstack_sources deps = [] public_deps = [] if (is_ohos) { deps += [ "$faultloggerd_path/common/dfxlog:static_common_log", "//third_party/bounds_checking_function:libsec_shared", ] if (target_cpu == "arm64") { public_deps += [ "//third_party/libunwind:unwind_source_arm64_opt" ] } else { public_deps += [ "//third_party/libunwind:unwind_source_${target_cpu}" ] } external_deps = [ "c_utils:utils" ] } else { deps += [ "//third_party/bounds_checking_function:libsec_static" ] public_deps += [ "//third_party/libunwind:unwind_source_${host_cpu}" ] } part_name = "faultloggerd" subsystem_name = "hiviewdfx" } # callstack_nativedaemon static library only support for profiler nativedaemon plugin currently. # some configs have to be exposed. ohos_static_library("callstack_nativedaemon") { public_configs = [ ":common_callstack_config", ":nativedaemon_callstack_config", "../../../../../../commonlibrary/c_utils/base:utils_config", "//third_party/bounds_checking_function:libsec_public_config", "//third_party/googletest:gtest_config", "$faultloggerd_path/common/build:coverage_flags", ] include_dirs = [ "$faultloggerd_path/common/dfxlog", "$faultloggerd_path/common/dfxutil", ] sources = callstack_sources deps = [] public_deps = [] if (is_ohos) { deps += [ "$faultloggerd_path/common/dfxlog:static_common_log", "//third_party/bounds_checking_function:libsec_shared", ] if (target_cpu == "arm64") { public_deps += [ "//third_party/libunwind:unwind_source_arm64_opt" ] } else { public_deps += [ "//third_party/libunwind:unwind_source_${target_cpu}" ] } external_deps = [ "c_utils:utils" ] } else { deps += [ "//third_party/bounds_checking_function:libsec_static" ] public_deps += [ "//third_party/libunwind:unwind_source_${host_cpu}" ] } part_name = "faultloggerd" subsystem_name = "hiviewdfx" } }