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("../../base/config.gni") 16 17config("hook_config") { 18 defines = [ "is_ohos=1" ] 19 defines += [ 20 "HAVE_LIBUNWIND=1", 21 "HIPERF_DEBUG", 22 "CONFIG_NO_HILOG", 23 ] 24 defines += [ "target_cpu_${target_cpu}" ] 25} 26 27ohos_shared_library("native_hook") { 28 use_exceptions = true 29 output_name = "native_hook" 30 sources = [ 31 "../../services/ipc/src/socket_context.cpp", 32 "../../services/ipc/src/unix_socket_client.cpp", 33 "../native_daemon/src/debug_logger.cpp", 34 "../native_daemon/src/get_thread_id.cpp", 35 "../native_daemon/src/register.cpp", 36 "../native_daemon/src/utilities.cpp", 37 "src/hook_client.cpp", 38 "src/hook_socket_client.cpp", 39 "src/runtime_stack_range.cpp", 40 "src/stack_writer.cpp", 41 ] 42 include_dirs = [ 43 "./include", 44 "../api/include", 45 "../api/src", 46 "../../base/include/", 47 "../native_daemon/include", 48 "${OHOS_PROFILER_DIR}/interfaces/kits", 49 "${OHOS_PROFILER_DIR}/device/services/ipc/include", 50 "${OHOS_PROFILER_DIR}/device/services/shared_memory/include", 51 "//utils/native/base/include", 52 "//third_party/googletest/googletest/include", 53 ] 54 public_configs = [ 55 ":hook_config", 56 "${OHOS_PROFILER_DIR}/device/base:hiprofiler_test_config", 57 ] 58 deps = [ 59 "${OHOS_PROFILER_DIR}/device/services/shared_memory:shared_memory_lite", 60 "../../base:hiprofiler_base", 61 "//third_party/zlib:libz", 62 "//utils/native/base:utilsecurec", 63 ] 64 65 public_deps = [ "//third_party/libunwind:unwind_source_${target_cpu}" ] 66 67 if (current_toolchain != host_toolchain) { 68 defines = [ "HAVE_HILOG" ] 69 if (build_l2) { 70 external_deps = [ "shared_library:libhilog" ] 71 } else { 72 external_deps = [ "hiviewdfx_hilog_native:libhilog" ] 73 } 74 } 75 defines += [ "NO_PROTOBUF" ] 76 cflags = [ 77 "-Wno-error=inline-asm", 78 "-DPERF_TEST_DATA", 79 "-O3", 80 ] 81 install_enable = true 82 subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" 83 part_name = "${OHOS_PROFILER_PART_NAME}" 84} 85 86ohos_executable("nativetest_c") { 87 output_name = "nativetest_c" 88 sources = [ "test/hook_test.c" ] 89 90 if (current_toolchain != host_toolchain) { 91 defines = [ "HAVE_HILOG" ] 92 if (build_l2) { 93 external_deps = [ "shared_library:libhilog" ] 94 } else { 95 external_deps = [ "hiviewdfx_hilog_native:libhilog" ] 96 } 97 } 98 99 cflags = [ 100 "-Wno-error=inline-asm", 101 "-O3", 102 ] 103 ldflags = [ "-rdynamic" ] 104 install_enable = false 105 subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" 106 part_name = "${OHOS_PROFILER_PART_NAME}" 107} 108 109ohos_executable("nativetest_cpp") { 110 output_name = "nativetest_cpp" 111 sources = [ "test/hook_test.cpp" ] 112 113 if (current_toolchain != host_toolchain) { 114 defines = [ "HAVE_HILOG" ] 115 if (build_l2) { 116 external_deps = [ "shared_library:libhilog" ] 117 } else { 118 external_deps = [ "hiviewdfx_hilog_native:libhilog" ] 119 } 120 } 121 122 cflags = [ 123 "-Wno-error=inline-asm", 124 "-O3", 125 ] 126 ldflags = [ "-rdynamic" ] 127 install_enable = false 128 subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" 129 part_name = "${OHOS_PROFILER_PART_NAME}" 130} 131 132ohos_executable("perf_test_data") { 133 output_name = "perf_test_data" 134 sources = [ "test/perf_test_data.cpp" ] 135 136 if (current_toolchain != host_toolchain) { 137 defines = [ "HAVE_HILOG" ] 138 if (build_l2) { 139 external_deps = [ "shared_library:libhilog" ] 140 } else { 141 external_deps = [ "hiviewdfx_hilog_native:libhilog" ] 142 } 143 } 144 145 cflags = [ "-Wno-error=inline-asm" ] 146 install_enable = false 147 ldflags = [ "-rdynamic" ] 148 subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" 149 part_name = "${OHOS_PROFILER_PART_NAME}" 150} 151