• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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("cflags_config") {
18  cflags = [ "-O3" ]
19}
20
21config("hook_config") {
22  defines = [ "is_ohos=1" ]
23  defines += [
24    "HAVE_LIBUNWIND=1",
25    "HIPERF_DEBUG",
26    "CONFIG_NO_HILOG",
27    "NATIVEDAEMON_USE_CALLSTACK",
28  ]
29  defines += [ "target_cpu_${target_cpu}" ]
30}
31
32ohos_prebuilt_etc("hiprofiler_daemon.cfg") {
33  source = "../../etc/hiprofiler_daemon.cfg"
34  relative_install_dir = "init"
35  part_name = "${OHOS_PROFILER_PART_NAME}"
36  subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}"
37}
38
39ohos_executable("native_daemon") {
40  output_name = "native_daemon"
41  sources = [
42    "../api/src/buffer_writer.cpp",
43    "../api/src/command_poller.cpp",
44    "src/call_stack.cpp",
45    "src/debug_logger.cpp",
46    "src/dwarf_encoding.cpp",
47    "src/elf_file.cpp",
48    "src/elf_header.cpp",
49    "src/elf_symbol.cpp",
50    "src/get_thread_id.cpp",
51    "src/hook_manager.cpp",
52    "src/hook_service.cpp",
53    "src/hook_standalone.cpp",
54    "src/main.cpp",
55    "src/program_header.cpp",
56    "src/register.cpp",
57    "src/section_header.cpp",
58    "src/stack_data_repeater.cpp",
59    "src/stack_preprocess.cpp",
60    "src/symbols_file.cpp",
61    "src/utilities.cpp",
62    "src/virtual_runtime.cpp",
63    "src/virtual_thread.cpp",
64  ]
65  include_dirs = [
66    "./include",
67    "./src",
68    "../../base/include",
69    "../api/include",
70    "../api/src",
71    "${OHOS_PROFILER_DIR}/interfaces/kits",
72    "${OHOS_PROFILER_DIR}/device/services/ipc/include",
73    "${OHOS_PROFILER_DIR}/device/services/shared_memory/include",
74    "//base/startup/init/services/include/param",
75    "//third_party/bounds_checking_function/include",
76    "//third_party/googletest/googletest/include",
77  ]
78  deps = [
79    ":hiprofiler_daemon.cfg",
80    "${OHOS_PROFILER_DIR}/device/services/shared_memory:shared_memory",
81    "${OHOS_PROFILER_DIR}/protos/services:plugin_service_proto",
82    "${OHOS_PROFILER_DIR}/protos/services:profiler_service_all_type_source",
83    "${OHOS_PROFILER_DIR}/protos/types/plugins/native_hook:native_hook_cpp",
84    "${OHOS_PROFILER_DIR}/protos/types/plugins/native_hook:native_hook_cpp_standard",
85    "../../base:hiprofiler_base",
86    "//third_party/bounds_checking_function:libsec_static",
87    "//third_party/libunwind:unwind_source_${target_cpu}",
88    "//third_party/zlib:libz",
89  ]
90  configs = [ ":cflags_config" ]
91  public_configs = [
92    ":hook_config",
93    "${OHOS_PROFILER_DIR}/device/base:hiprofiler_test_config",
94  ]
95  external_deps = [ "init:libbegetutil" ]
96  if (current_toolchain != host_toolchain) {
97    defines = [ "HAVE_HILOG" ]
98    external_deps += [ "hilog:libhilog" ]
99  }
100  use_exceptions = true
101  install_enable = true
102  subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}"
103  part_name = "${OHOS_PROFILER_PART_NAME}"
104}
105