1# Copyright (c) 2021-2024 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("//base/hiviewdfx/hiview/build/hiview_var.gni")
15import("//base/hiviewdfx/hiview/hiview.gni")
16import("//build/ohos.gni")
17
18gen_plugin_script =
19    rebase_path("//base/hiviewdfx/hiview/build/gen_plugin_build.py")
20copy_plugin_script =
21    rebase_path("//base/hiviewdfx/hiview/build/copy_plugin_config.py")
22
23input_build_file =
24    rebase_path("//base/hiviewdfx/hiview/build/plugin_build.json")
25
26out_plugin_config_file = "${target_gen_dir}/plugin_config"
27out_plugin_build_file = "${target_gen_dir}/plugin_build.gni"
28out_plugin_config_file_tmp = "${target_gen_dir}/plugin_config_tmp"
29
30if (build_with_config) {
31  input_build_file = rebase_path(config_path)
32}
33
34arguments = [
35  "--input-file",
36  input_build_file,
37  "--plugin-config-file",
38  rebase_path(out_plugin_config_file_tmp),
39  "--plugin-build-file",
40  rebase_path(out_plugin_build_file),
41  "--target_os",
42  target_os,
43  "--double_framework",
44  "$is_double_framework",
45  "--target_platform",
46  target_platform,
47  "--target_cpu",
48  target_cpu,
49  "--plugin_so",
50  "$plugin_so",
51  "--plugin_target_platform",
52  plugin_target_platform,
53  "--plugin_target_ram",
54  plugin_target_ram,
55  "--plugin_target_rom",
56  plugin_target_rom,
57]
58
59result_ = exec_script(gen_plugin_script, arguments, "string")
60print(result_)
61action("copy_plugin_config") {
62  script = copy_plugin_script
63  outputs = [ out_plugin_config_file ]
64  args = [
65    "--src-file",
66    rebase_path(out_plugin_config_file_tmp),
67    "--dst-file",
68    rebase_path(out_plugin_config_file),
69  ]
70}
71
72import(out_plugin_build_file)
73ohos_prebuilt_etc("plugin_config") {
74  source = out_plugin_config_file
75  deps = [ ":copy_plugin_config" ]
76
77  part_name = "hiview"
78  subsystem_name = "hiviewdfx"
79  relative_install_dir = "hiview"
80}
81
82config("hiview_plus_config") {
83  visibility = [ ":*" ]
84  include_dirs = [ "include" ]
85}
86
87ohos_executable("hiview") {
88  branch_protector_ret = "pac_ret"
89  sanitize = {
90    cfi = true
91    cfi_cross_dso = true
92    cfi_vcall_icall_only = true
93    debug = false
94  }
95
96  install_enable = true
97
98  deps = [
99    "base:hiviewbase",
100    "core:hiview_core",
101    "service:hiview_service",
102  ]
103
104  sources = [ "main.cpp" ]
105
106  deps += plugin_static_deps
107
108  external_deps = [
109    "ffrt:libffrt",
110    "hidumper:hidumperservice_cpu_source",
111    "hilog:libhilog",
112  ]
113
114  part_name = "hiview"
115  subsystem_name = "hiviewdfx"
116}
117
118group("hiview_package") {
119  # root of all the hiview dependencies
120  deps = [
121    ":hiview",
122    ":plugin_config",
123    "$hiview_plugin/crash_validator:libcrashvalidator",
124    "$hiview_plugin/eventlogger:eventloggerso",
125    "$hiview_plugin/faultlogger:libfaultlogger",
126    "$hiview_plugin/performance:xperformance",
127    "$hiview_plugin/plugin_build:adft",
128    "$hiview_plugin/plugin_build:bdfr",
129  ]
130
131  if (enable_hiview_usage_event_report_build) {
132    deps += [ "plugins/usage_event_report/service:usage_report" ]
133  }
134
135  deps += plugin_dynamic_deps
136}
137
138group("hiview_test_package") {
139  testonly = true
140  deps = [
141    "$hiview_adapter:moduletest",
142    "$hiview_adapter:unittest",
143    "adapter/service:fuzztest",
144    "adapter/service:unittest",
145    "base/test:unittest",
146    "core/test:unittest",
147    "framework/native/unified_collection:unittest",
148    "interfaces/js/napi/test:unittest",
149    "plugins:fuzztest",
150    "plugins:moduletest",
151    "plugins:unittest",
152    "service:fuzztest",
153    "test:moduletest",
154    "test:unittest",
155    "utility/common_utils:unittest",
156    "utility/smart_parser:moduletest",
157  ]
158
159  deps += plugin_ut_deps
160  deps += plugin_mst_deps
161}
162