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