1800b99b8Sopenharmony_ci# Copyright (c) 2021-2024 Huawei Device Co., Ltd.
2800b99b8Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License");
3800b99b8Sopenharmony_ci# you may not use this file except in compliance with the License.
4800b99b8Sopenharmony_ci# You may obtain a copy of the License at
5800b99b8Sopenharmony_ci#
6800b99b8Sopenharmony_ci#     http://www.apache.org/licenses/LICENSE-2.0
7800b99b8Sopenharmony_ci#
8800b99b8Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software
9800b99b8Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS,
10800b99b8Sopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11800b99b8Sopenharmony_ci# See the License for the specific language governing permissions and
12800b99b8Sopenharmony_ci# limitations under the License.
13800b99b8Sopenharmony_ci
14800b99b8Sopenharmony_ciimport("//base/hiviewdfx/faultloggerd/faultloggerd.gni")
15800b99b8Sopenharmony_ci
16800b99b8Sopenharmony_cifaultloggerd_sources = [
17800b99b8Sopenharmony_ci  "fault_logger_config.cpp",
18800b99b8Sopenharmony_ci  "fault_logger_daemon.cpp",
19800b99b8Sopenharmony_ci  "fault_logger_pipe.cpp",
20800b99b8Sopenharmony_ci  "main.cpp",
21800b99b8Sopenharmony_ci]
22800b99b8Sopenharmony_ci
23800b99b8Sopenharmony_ciif (defined(ohos_lite)) {
24800b99b8Sopenharmony_ci  copy("faultlogger.cfg") {
25800b99b8Sopenharmony_ci    sources = [ "$faultloggerd_path/services/config/faultloggerd.cfg" ]
26800b99b8Sopenharmony_ci    outputs = [ "$root_out_dir/etc/init/faultloggerd.cfg" ]
27800b99b8Sopenharmony_ci  }
28800b99b8Sopenharmony_ci
29800b99b8Sopenharmony_ci  copy("faultlogger.conf") {
30800b99b8Sopenharmony_ci    sources = [ "$faultloggerd_path/services/config/faultlogger.conf" ]
31800b99b8Sopenharmony_ci    outputs = [ "$root_out_dir/etc/faultlogger.conf" ]
32800b99b8Sopenharmony_ci  }
33800b99b8Sopenharmony_ci
34800b99b8Sopenharmony_ci  executable("faultloggerd") {
35800b99b8Sopenharmony_ci    visibility = [ "*:*" ]
36800b99b8Sopenharmony_ci
37800b99b8Sopenharmony_ci    include_dirs = [
38800b99b8Sopenharmony_ci      ".",
39800b99b8Sopenharmony_ci      "$c_utils_include_path",
40800b99b8Sopenharmony_ci      "$faultloggerd_interfaces_path/common",
41800b99b8Sopenharmony_ci      "$faultloggerd_path/common/dfxlog",
42800b99b8Sopenharmony_ci      "$faultloggerd_path/common/dfxutil",
43800b99b8Sopenharmony_ci      "$faultloggerd_path/tools/process_dump",
44800b99b8Sopenharmony_ci      "$hilog_lite_include_path",
45800b99b8Sopenharmony_ci      "$faultloggerd_path/interfaces/innerkits/faultloggerd_client/include",
46800b99b8Sopenharmony_ci      "$faultloggerd_path/interfaces/innerkits/faultloggerd_client",
47800b99b8Sopenharmony_ci    ]
48800b99b8Sopenharmony_ci
49800b99b8Sopenharmony_ci    sources = faultloggerd_sources
50800b99b8Sopenharmony_ci    sources += [ "$c_utils_src_path/directory_ex.cpp" ]
51800b99b8Sopenharmony_ci
52800b99b8Sopenharmony_ci    cflags = [ "-fstack-protector-strong" ]
53800b99b8Sopenharmony_ci
54800b99b8Sopenharmony_ci    deps = [
55800b99b8Sopenharmony_ci      ":faultlogger.conf",
56800b99b8Sopenharmony_ci      "$faultloggerd_common_path/trace:dfx_trace",
57800b99b8Sopenharmony_ci      "$faultloggerd_path/common/dfxlog:dfx_hilog",
58800b99b8Sopenharmony_ci      "$faultloggerd_path/common/dfxutil:dfx_util",
59800b99b8Sopenharmony_ci      "$faultloggerd_path/interfaces/innerkits/faultloggerd_client:libfaultloggerd",
60800b99b8Sopenharmony_ci    ]
61800b99b8Sopenharmony_ci
62800b99b8Sopenharmony_ci    external_deps = [ "hilog_lite:hilog_shared" ]
63800b99b8Sopenharmony_ci
64800b99b8Sopenharmony_ci    defines = [ "is_ohos_lite" ]
65800b99b8Sopenharmony_ci    if (faultloggerd_hisysevent_enable) {
66800b99b8Sopenharmony_ci      deps += [ "hisysevent:libhisysevent" ]
67800b99b8Sopenharmony_ci    } else {
68800b99b8Sopenharmony_ci      defines += [ "HISYSEVENT_DISABLE" ]
69800b99b8Sopenharmony_ci    }
70800b99b8Sopenharmony_ci  }
71800b99b8Sopenharmony_ci} else {
72800b99b8Sopenharmony_ci  config("faultloggerd_config") {
73800b99b8Sopenharmony_ci    visibility = [ ":*" ]
74800b99b8Sopenharmony_ci
75800b99b8Sopenharmony_ci    include_dirs = [
76800b99b8Sopenharmony_ci      ".",
77800b99b8Sopenharmony_ci      "$faultloggerd_interfaces_path/common",
78800b99b8Sopenharmony_ci      "$faultloggerd_path/common/dfxlog",
79800b99b8Sopenharmony_ci      "$faultloggerd_path/common/dfxutil",
80800b99b8Sopenharmony_ci      "$faultloggerd_path/tools/process_dump",
81800b99b8Sopenharmony_ci      "$faultloggerd_path/interfaces/innerkits/faultloggerd_client",
82800b99b8Sopenharmony_ci      "$faultloggerd_path/interfaces/innerkits/signal_handler",
83800b99b8Sopenharmony_ci    ]
84800b99b8Sopenharmony_ci  }
85800b99b8Sopenharmony_ci
86800b99b8Sopenharmony_ci  ohos_prebuilt_etc("faultloggerd.cfg") {
87800b99b8Sopenharmony_ci    if (use_musl) {
88800b99b8Sopenharmony_ci      source = "config/faultloggerd.cfg"
89800b99b8Sopenharmony_ci    } else {
90800b99b8Sopenharmony_ci      source = "config/bionic/faultloggerd.cfg"
91800b99b8Sopenharmony_ci    }
92800b99b8Sopenharmony_ci
93800b99b8Sopenharmony_ci    relative_install_dir = "init"
94800b99b8Sopenharmony_ci    part_name = "faultloggerd"
95800b99b8Sopenharmony_ci    subsystem_name = "hiviewdfx"
96800b99b8Sopenharmony_ci  }
97800b99b8Sopenharmony_ci
98800b99b8Sopenharmony_ci  ohos_prebuilt_etc("faultloggerd.para") {
99800b99b8Sopenharmony_ci    source = "config/faultloggerd.para"
100800b99b8Sopenharmony_ci    relative_install_dir = "param"
101800b99b8Sopenharmony_ci    part_name = "faultloggerd"
102800b99b8Sopenharmony_ci    subsystem_name = "hiviewdfx"
103800b99b8Sopenharmony_ci  }
104800b99b8Sopenharmony_ci
105800b99b8Sopenharmony_ci  ohos_prebuilt_etc("faultloggerd.para.dac") {
106800b99b8Sopenharmony_ci    source = "config/faultloggerd.para.dac"
107800b99b8Sopenharmony_ci    relative_install_dir = "param"
108800b99b8Sopenharmony_ci    part_name = "faultloggerd"
109800b99b8Sopenharmony_ci    subsystem_name = "hiviewdfx"
110800b99b8Sopenharmony_ci  }
111800b99b8Sopenharmony_ci
112800b99b8Sopenharmony_ci  ohos_prebuilt_etc("faultlogger.conf") {
113800b99b8Sopenharmony_ci    source = "config/faultlogger.conf"
114800b99b8Sopenharmony_ci    part_name = "faultloggerd"
115800b99b8Sopenharmony_ci    subsystem_name = "hiviewdfx"
116800b99b8Sopenharmony_ci  }
117800b99b8Sopenharmony_ci
118800b99b8Sopenharmony_ci  ohos_executable("faultloggerd") {
119800b99b8Sopenharmony_ci    install_enable = true
120800b99b8Sopenharmony_ci    configs = [
121800b99b8Sopenharmony_ci      ":faultloggerd_config",
122800b99b8Sopenharmony_ci      "$faultloggerd_path/common/build:coverage_flags",
123800b99b8Sopenharmony_ci    ]
124800b99b8Sopenharmony_ci    sources = faultloggerd_sources
125800b99b8Sopenharmony_ci
126800b99b8Sopenharmony_ci    cflags = [ "-fstack-protector-strong" ]
127800b99b8Sopenharmony_ci    cflags_cc = [ "-DDEBUG_CRASH_LOCAL_HANDLER" ]
128800b99b8Sopenharmony_ci    defines = [
129800b99b8Sopenharmony_ci      "DFX_LOG_HILOG_BASE",
130800b99b8Sopenharmony_ci      "DFX_ENABLE_TRACE",
131800b99b8Sopenharmony_ci    ]
132800b99b8Sopenharmony_ci
133800b99b8Sopenharmony_ci    deps = [
134800b99b8Sopenharmony_ci      ":faultlogger.conf",
135800b99b8Sopenharmony_ci      ":faultloggerd.para",
136800b99b8Sopenharmony_ci      ":faultloggerd.para.dac",
137800b99b8Sopenharmony_ci      "$faultloggerd_frameworks_path/localhandler:dfx_local_handler_src",
138800b99b8Sopenharmony_ci      "$faultloggerd_path/common/dfxlog:dfx_hilog_base",
139800b99b8Sopenharmony_ci      "$faultloggerd_path/common/dfxutil:dfx_util",
140800b99b8Sopenharmony_ci      "$faultloggerd_path/common/trace:dfx_trace",
141800b99b8Sopenharmony_ci      "$faultloggerd_path/interfaces/innerkits/faultloggerd_client:libfaultloggerd",
142800b99b8Sopenharmony_ci    ]
143800b99b8Sopenharmony_ci
144800b99b8Sopenharmony_ci    if (!is_asan) {
145800b99b8Sopenharmony_ci      deps += [ ":faultloggerd.cfg" ]
146800b99b8Sopenharmony_ci    }
147800b99b8Sopenharmony_ci
148800b99b8Sopenharmony_ci    external_deps = [
149800b99b8Sopenharmony_ci      "bounds_checking_function:libsec_shared",
150800b99b8Sopenharmony_ci      "c_utils:utils",
151800b99b8Sopenharmony_ci      "hilog:libhilog_base",
152800b99b8Sopenharmony_ci      "hisysevent:libhisysevent",
153800b99b8Sopenharmony_ci      "hitrace:hitrace_meter",
154800b99b8Sopenharmony_ci      "init:libbegetutil",
155800b99b8Sopenharmony_ci    ]
156800b99b8Sopenharmony_ci    version_script = "faultloggerd.map"
157800b99b8Sopenharmony_ci    install_images = [
158800b99b8Sopenharmony_ci      "system",
159800b99b8Sopenharmony_ci      "updater",
160800b99b8Sopenharmony_ci    ]
161800b99b8Sopenharmony_ci    part_name = "faultloggerd"
162800b99b8Sopenharmony_ci    subsystem_name = "hiviewdfx"
163800b99b8Sopenharmony_ci  }
164800b99b8Sopenharmony_ci
165800b99b8Sopenharmony_ci  ohos_source_set("faultloggerd_fuzzer_src") {
166800b99b8Sopenharmony_ci    configs = [ ":faultloggerd_config" ]
167800b99b8Sopenharmony_ci    defines = [
168800b99b8Sopenharmony_ci      "FAULTLOGGERD_FUZZER",
169800b99b8Sopenharmony_ci      "DFX_ENABLE_TRACE",
170800b99b8Sopenharmony_ci    ]
171800b99b8Sopenharmony_ci    sources = [
172800b99b8Sopenharmony_ci      "fault_logger_config.cpp",
173800b99b8Sopenharmony_ci      "fault_logger_daemon.cpp",
174800b99b8Sopenharmony_ci      "fault_logger_pipe.cpp",
175800b99b8Sopenharmony_ci    ]
176800b99b8Sopenharmony_ci
177800b99b8Sopenharmony_ci    deps = [
178800b99b8Sopenharmony_ci      "$faultloggerd_common_path/dfxlog:dfx_hilog",
179800b99b8Sopenharmony_ci      "$faultloggerd_common_path/dfxutil:dfx_util",
180800b99b8Sopenharmony_ci      "$faultloggerd_path/common/trace:dfx_trace",
181800b99b8Sopenharmony_ci      "$faultloggerd_path/interfaces/innerkits/faultloggerd_client:libfaultloggerd",
182800b99b8Sopenharmony_ci    ]
183800b99b8Sopenharmony_ci    external_deps = [
184800b99b8Sopenharmony_ci      "c_utils:utils",
185800b99b8Sopenharmony_ci      "hilog:libhilog_base",
186800b99b8Sopenharmony_ci      "hisysevent:libhisysevent",
187800b99b8Sopenharmony_ci      "hitrace:hitrace_meter",
188800b99b8Sopenharmony_ci      "init:libbegetutil",
189800b99b8Sopenharmony_ci    ]
190800b99b8Sopenharmony_ci    part_name = "faultloggerd"
191800b99b8Sopenharmony_ci    subsystem_name = "hiviewdfx"
192800b99b8Sopenharmony_ci  }
193800b99b8Sopenharmony_ci}
194