• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
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 = [
23    "HAVE_LIBUNWIND=0",
24    "HAVE_LIBUNWINDER=1",
25    "HIPERF_DEBUG",
26    "CONFIG_NO_HILOG",
27    "NATIVEDAEMON_USE_CALLSTACK",
28  ]
29  defines += [ "target_cpu_${target_cpu}" ]
30  if (musl_use_jemalloc) {
31    defines += [ "USE_JEMALLOC" ]
32  }
33}
34
35config("profiler_sa_config") {
36  visibility = [ ":*" ]
37  include_dirs = [
38    "native_memory_profiler_sa/include",
39    "native_memory_profiler_sa/util/include",
40    "../../base/include",
41  ]
42}
43
44ohos_prebuilt_etc("hiprofiler_daemon.cfg") {
45  source = "../../etc/hiprofiler_daemon.cfg"
46  relative_install_dir = "init"
47  part_name = "${OHOS_PROFILER_PART_NAME}"
48  subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}"
49}
50
51ohos_executable("native_daemon") {
52  output_name = "native_daemon"
53  configs = [ ":cflags_config" ]
54  public_configs = [
55    ":hook_config",
56    "${OHOS_PROFILER_DIR}/device/base:hiprofiler_test_config",
57  ]
58  sources = [
59    "../api/src/buffer_writer.cpp",
60    "../api/src/command_poller.cpp",
61    "../api/src/writer_adapter.cpp",
62    "src/debug_logger.cpp",
63    "src/dwarf_encoding.cpp",
64    "src/get_thread_id.cpp",
65    "src/hook_manager.cpp",
66    "src/hook_service.cpp",
67    "src/hook_standalone.cpp",
68    "src/main.cpp",
69    "src/register.cpp",
70    "src/stack_data_repeater.cpp",
71    "src/stack_preprocess.cpp",
72    "src/symbols_file.cpp",
73    "src/utilities.cpp",
74    "src/virtual_runtime.cpp",
75    "src/virtual_thread.cpp",
76  ]
77
78  if (is_ohos) {
79    sources += [ "./src/call_stack.cpp" ]
80  }
81
82  include_dirs = [
83    "./include",
84    "./src",
85    "../../base/include",
86    "../api/include",
87    "../api/src",
88    "${OHOS_PROFILER_DIR}/interfaces/kits",
89    "${OHOS_PROFILER_DIR}/device/services/ipc/include",
90    "${OHOS_PROFILER_DIR}/device/services/shared_memory/include",
91  ]
92
93  include_dirs += [
94    "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/include",
95    "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/util/include",
96    "${OHOS_PROFILER_DIR}/device/services/profiler_service/src",
97  ]
98
99  sources += [
100    "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_config.cpp",
101    "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_death_recipient.cpp",
102    "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_service.cpp",
103    "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_stub.cpp",
104    "${OHOS_PROFILER_DIR}/device/services/profiler_service/src/trace_file_helper.cpp",
105    "${OHOS_PROFILER_DIR}/device/services/profiler_service/src/trace_file_writer.cpp",
106  ]
107
108  deps = [
109    ":hiprofiler_daemon.cfg",
110    "${OHOS_PROFILER_DIR}/device/services/shared_memory:shared_memory_source",
111    "${OHOS_PROFILER_DIR}/proto_encoder:proto_encoder_source",
112    "${OHOS_PROFILER_DIR}/protos/services:plugin_service_proto",
113    "${OHOS_PROFILER_DIR}/protos/services:profiler_service_all_type_source",
114    "${OHOS_PROFILER_DIR}/protos/types/plugins/native_hook:native_hook_cpp",
115    "${OHOS_PROFILER_DIR}/protos/types/plugins/native_hook:native_hook_cpp_standard",
116    "${OHOS_PROFILER_DIR}/protos/types/plugins/native_hook:native_hook_encoder",
117    "../../base:hiprofiler_base",
118  ]
119
120  if (hiprofiler_use_libunwind) {
121    deps += [ "//third_party/libunwind:unwind_source_${target_cpu}" ]
122  }
123
124  external_deps = [
125    "ability_base:extractortool",
126    "access_token:libaccesstoken_sdk",
127    "access_token:libtokensetproc_shared",
128    "bounds_checking_function:libsec_shared",
129    "init:libbegetutil",
130    "ipc:ipc_core",
131    "openssl:libcrypto_shared",
132    "protobuf:protobuf_lite",
133    "safwk:system_ability_fwk",
134    "samgr:samgr_proxy",
135    "zlib:libz",
136  ]
137
138  defines = [ "ENABLE_HAP_EXTRACTOR" ]
139
140  if (hiprofiler_use_libunwinder) {
141    external_deps += [ "faultloggerd:libunwinder" ]
142  }
143
144  if (current_toolchain != host_toolchain) {
145    defines += [ "HAVE_HILOG" ]
146    external_deps += [ "hilog:libhilog" ]
147  }
148  use_exceptions = true
149  install_enable = true
150  subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}"
151  part_name = "${OHOS_PROFILER_PART_NAME}"
152}
153
154ohos_executable("native_daemon_client") {
155  output_name = "native_daemon_client"
156  include_dirs = [
157    "../../base/include",
158    "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/include",
159    "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/util/include",
160  ]
161
162  sources = [
163    "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_client_manager.cpp",
164    "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_config.cpp",
165    "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_proxy.cpp",
166    "native_daemon_client.cpp",
167  ]
168
169  external_deps = [
170    "c_utils:utils",
171    "init:libbegetutil",
172    "ipc:ipc_core",
173    "safwk:system_ability_fwk",
174    "samgr:samgr_proxy",
175  ]
176
177  if (current_toolchain != host_toolchain) {
178    defines = [ "HAVE_HILOG" ]
179    external_deps += [ "hilog:libhilog" ]
180  }
181  install_enable = false
182  subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}"
183  part_name = "${OHOS_PROFILER_PART_NAME}"
184}
185
186ohos_shared_library("libnative_daemon_client") {
187  public_configs = [ ":profiler_sa_config" ]
188  include_dirs = [
189    "../../base/include",
190    "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/include",
191    "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/util/include",
192  ]
193
194  sources = [
195    "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_client_manager.cpp",
196    "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_config.cpp",
197    "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_proxy.cpp",
198    "../../base/src/common.cpp",
199  ]
200
201  external_deps = [
202    "bundle_framework:appexecfwk_base",
203    "bundle_framework:appexecfwk_core",
204    "c_utils:utils",
205    "init:libbegetutil",
206    "ipc:ipc_core",
207    "os_account:os_account_innerkits",
208    "safwk:system_ability_fwk",
209    "samgr:samgr_proxy",
210  ]
211
212  if (current_toolchain != host_toolchain) {
213    defines = [ "HAVE_HILOG" ]
214    external_deps += [ "hilog:libhilog" ]
215  }
216
217  innerapi_tags = [ "platformsdk" ]
218  subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}"
219  part_name = "${OHOS_PROFILER_PART_NAME}"
220}
221