1# Copyright (c) 2021-2022 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("../toolchain.gni")
15
16config("ark_ecma_debugger_config") {
17  configs = [
18    "..:ark_toolchain_common_config",
19    "//arkcompiler/ets_runtime:ark_jsruntime_common_config",
20    "//arkcompiler/ets_runtime:ark_jsruntime_public_config",
21  ]
22
23  include_dirs = [ "." ]
24}
25
26debugger_sources = [
27  "../common/log_wrapper.cpp",
28  "agent/css_impl.cpp",
29  "agent/debugger_impl.cpp",
30  "agent/dom_impl.cpp",
31  "agent/overlay_impl.cpp",
32  "agent/page_impl.cpp",
33  "agent/runtime_impl.cpp",
34  "agent/target_impl.cpp",
35  "agent/tracing_impl.cpp",
36  "backend/debugger_executor.cpp",
37  "backend/js_pt_hooks.cpp",
38  "backend/js_single_stepper.cpp",
39  "base/pt_base64.cpp",
40  "base/pt_events.cpp",
41  "base/pt_json.cpp",
42  "base/pt_params.cpp",
43  "base/pt_returns.cpp",
44  "base/pt_script.cpp",
45  "base/pt_types.cpp",
46  "debugger_service.cpp",
47  "dispatcher.cpp",
48  "protocol_handler.cpp",
49  "utils/utils.cpp",
50]
51if (!is_mingw && !is_mac && target_os != "ios") {
52  debugger_sources += [
53    "agent/heapprofiler_impl.cpp",
54    "agent/profiler_impl.cpp",
55  ]
56}
57
58ohos_source_set("libark_ecma_debugger_set") {
59  stack_protector_ret = false
60  sources = debugger_sources
61
62  public_configs = [ ":ark_ecma_debugger_config" ]
63
64  defines = []
65  deps = []
66  external_deps = []
67  if (is_arkui_x && target_os == "ios") {
68    sources -= [ "../common/log_wrapper.cpp" ]
69    external_deps += [ "cJSON:cjson_static" ]
70  } else {
71    external_deps += [ "cJSON:cjson" ]
72  }
73  external_deps += [ "libuv:uv" ]
74
75  if (is_ohos && is_standard_system && !is_arkui_x) {
76    defines += [ "ENABLE_FFRT_INTERFACES" ]
77    external_deps += [ "ffrt:libffrt" ]
78  }
79
80  # hiviewdfx libraries
81  external_deps += hiviewdfx_ext_deps
82
83  external_deps += [ "runtime_core:libarkfile_static" ]
84  deps += hiviewdfx_deps
85
86  if (enable_leak_check) {
87    sources += [ "$js_root/ecmascript/dfx/native_dfx/backtrace.cpp" ]
88    defines += [
89      "ECMASCRIPT_ENABLE_HANDLE_LEAK_CHECK",
90      "ECMASCRIPT_ENABLE_GLOBAL_LEAK_CHECK",
91    ]
92  }
93
94  cflags_cc = [ "-fvisibility=hidden" ]
95  subsystem_name = "arkcompiler"
96  part_name = "toolchain"
97}
98
99ohos_shared_library("libark_ecma_debugger") {
100  stack_protector_ret = false
101  deps = [ ":libark_ecma_debugger_set" ]
102  external_deps = [ "libuv:uv" ]
103  if (is_mac) {
104    external_deps += [ "cJSON:cjson_static" ]
105  }
106
107  install_enable = true
108
109  # hiviewdfx libraries
110  external_deps += hiviewdfx_ext_deps
111  if (enable_hilog) {
112    external_deps += [ "hilog:libhilog" ]
113  }
114  if (!is_arkui_x) {
115    external_deps += [ "ets_runtime:libark_jsruntime" ]
116  } else {
117    deps += [ "../../ets_runtime:libark_jsruntime" ]
118  }
119  deps += hiviewdfx_deps
120
121  if (!is_mingw && !is_mac) {
122    output_extension = "so"
123  }
124
125  if (!is_standard_system) {
126    relative_install_dir = "ark"
127  }
128  innerapi_tags = [ "platformsdk" ]
129  subsystem_name = "arkcompiler"
130  part_name = "toolchain"
131  output_name = "libark_tooling"
132}
133
134ohos_shared_library("libark_ecma_debugger_test") {
135  testonly = true
136  stack_protector_ret = false
137  sources = debugger_sources
138
139  public_configs = [ ":ark_ecma_debugger_config" ]
140
141  defines = [ "OHOS_UNIT_TEST" ]
142
143  deps = [ "$js_root:libark_jsruntime_test" ]
144  external_deps = [ "libuv:uv" ]
145  if ((is_arkui_x && target_os == "ios") || target_os == "mac") {
146    external_deps += [ "cJSON:cjson_static" ]
147  } else {
148    external_deps += [ "cJSON:cjson" ]
149  }
150
151  # hiviewdfx libraries
152  external_deps += hiviewdfx_ext_deps
153  deps += hiviewdfx_deps
154  if (enable_hilog) {
155    external_deps += [ "hilog:libhilog" ]
156  }
157  install_enable = false
158
159  if (!is_mingw && !is_mac) {
160    output_extension = "so"
161  }
162  subsystem_name = "test"
163}
164