1800b99b8Sopenharmony_ci# Copyright (c) 2021 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_ciif (defined(ohos_lite)) {
17800b99b8Sopenharmony_ci  shared_library("dfx_signalhandler") {
18800b99b8Sopenharmony_ci    defines = [
19800b99b8Sopenharmony_ci      "is_ohos=${is_ohos}",
20800b99b8Sopenharmony_ci      "is_ohos_lite",
21800b99b8Sopenharmony_ci    ]
22800b99b8Sopenharmony_ci    visibility = [ "*:*" ]
23800b99b8Sopenharmony_ci    include_dirs = [
24800b99b8Sopenharmony_ci      "include",
25800b99b8Sopenharmony_ci      "$c_utils_include_path",
26800b99b8Sopenharmony_ci      "$faultloggerd_interfaces_path/common",
27800b99b8Sopenharmony_ci      "$faultloggerd_path/common/cutil",
28800b99b8Sopenharmony_ci      "$faultloggerd_path/common/dfxlog",
29800b99b8Sopenharmony_ci    ]
30800b99b8Sopenharmony_ci    sources = [
31800b99b8Sopenharmony_ci      "dfx_dumprequest.c",
32800b99b8Sopenharmony_ci      "dfx_signal_handler.c",
33800b99b8Sopenharmony_ci      "dfx_signalhandler_exception.c",
34800b99b8Sopenharmony_ci    ]
35800b99b8Sopenharmony_ci
36800b99b8Sopenharmony_ci    deps = [ "$faultloggerd_path/common/cutil:dfx_cutil" ]
37800b99b8Sopenharmony_ci
38800b99b8Sopenharmony_ci    external_deps = [ "bounds_checking_function:libsec_shared" ]
39800b99b8Sopenharmony_ci
40800b99b8Sopenharmony_ci    cflags = [
41800b99b8Sopenharmony_ci      "-fPIC",
42800b99b8Sopenharmony_ci      "-fno-builtin",
43800b99b8Sopenharmony_ci      "-DDFX_NO_PRINT_LOG",
44800b99b8Sopenharmony_ci    ]
45800b99b8Sopenharmony_ci  }
46800b99b8Sopenharmony_ci} else {
47800b99b8Sopenharmony_ci  inherited_configs = [
48800b99b8Sopenharmony_ci    "//build/config/compiler:afdo",
49800b99b8Sopenharmony_ci    "//build/config/compiler:afdo_optimize_size",
50800b99b8Sopenharmony_ci    "//build/config/compiler:compiler",
51800b99b8Sopenharmony_ci    "//build/config/compiler:compiler_arm_fpu",
52800b99b8Sopenharmony_ci    "//build/config/compiler:compiler_arm_thumb",
53800b99b8Sopenharmony_ci    "//build/config/compiler:chromium_code",
54800b99b8Sopenharmony_ci    "//build/config/compiler:default_include_dirs",
55800b99b8Sopenharmony_ci    "//build/config/compiler:default_optimization",
56800b99b8Sopenharmony_ci    "//build/config/compiler:default_stack_frames",
57800b99b8Sopenharmony_ci    "//build/config/compiler:default_symbols",
58800b99b8Sopenharmony_ci    "//build/config/compiler:export_dynamic",
59800b99b8Sopenharmony_ci    "//build/config/compiler:no_exceptions",
60800b99b8Sopenharmony_ci    "//build/config/compiler:no_rtti",
61800b99b8Sopenharmony_ci    "//build/config/compiler:runtime_library",
62800b99b8Sopenharmony_ci    "//build/config/compiler:thin_archive",
63800b99b8Sopenharmony_ci    "//build/config/sanitizers:default_sanitizer_flags",
64800b99b8Sopenharmony_ci  ]
65800b99b8Sopenharmony_ci
66800b99b8Sopenharmony_ci  config("dfx_signal_handler_config") {
67800b99b8Sopenharmony_ci    visibility = [ "*:*" ]
68800b99b8Sopenharmony_ci    include_dirs = [
69800b99b8Sopenharmony_ci      "include",
70800b99b8Sopenharmony_ci      "$faultloggerd_interfaces_path/common",
71800b99b8Sopenharmony_ci    ]
72800b99b8Sopenharmony_ci  }
73800b99b8Sopenharmony_ci
74800b99b8Sopenharmony_ci  config("static_sighandler_config") {
75800b99b8Sopenharmony_ci    include_dirs = [
76800b99b8Sopenharmony_ci      "include",
77800b99b8Sopenharmony_ci      "$faultloggerd_common_path/cutil",
78800b99b8Sopenharmony_ci      "$faultloggerd_common_path/dfxlog",
79800b99b8Sopenharmony_ci      "$faultloggerd_interfaces_path/common",
80800b99b8Sopenharmony_ci    ]
81800b99b8Sopenharmony_ci
82800b99b8Sopenharmony_ci    defines = []
83800b99b8Sopenharmony_ci    configs = []
84800b99b8Sopenharmony_ci    if (is_posix) {
85800b99b8Sopenharmony_ci      configs += [ "//build/config/posix:runtime_library" ]
86800b99b8Sopenharmony_ci    }
87800b99b8Sopenharmony_ci
88800b99b8Sopenharmony_ci    cflags_cc = []
89800b99b8Sopenharmony_ci    libs = []
90800b99b8Sopenharmony_ci
91800b99b8Sopenharmony_ci    defines = [
92800b99b8Sopenharmony_ci      "__GNU_SOURCE=1",  # Necessary for clone().
93800b99b8Sopenharmony_ci      "CHROMIUM_CXX_TWEAK_INLINES",  # Saves binary size.
94800b99b8Sopenharmony_ci    ]
95800b99b8Sopenharmony_ci
96800b99b8Sopenharmony_ci    defines += [
97800b99b8Sopenharmony_ci      "__MUSL__",
98800b99b8Sopenharmony_ci      "_LIBCPP_HAS_MUSL_LIBC",
99800b99b8Sopenharmony_ci      "__BUILD_LINUX_WITH_CLANG",
100800b99b8Sopenharmony_ci      "ENABLE_SIGHAND_MUSL_LOG",
101800b99b8Sopenharmony_ci      "ENABLE_MUSL_CUTIL",
102800b99b8Sopenharmony_ci    ]
103800b99b8Sopenharmony_ci
104800b99b8Sopenharmony_ci    ldflags = [ "-nostdlib" ]
105800b99b8Sopenharmony_ci  }
106800b99b8Sopenharmony_ci
107800b99b8Sopenharmony_ci  ohos_shared_library("dfx_signalhandler") {
108800b99b8Sopenharmony_ci    branch_protector_ret = "pac_ret"
109800b99b8Sopenharmony_ci    public_configs = [
110800b99b8Sopenharmony_ci      ":dfx_signal_handler_config",
111800b99b8Sopenharmony_ci      "$faultloggerd_common_path/build:coverage_flags",
112800b99b8Sopenharmony_ci    ]
113800b99b8Sopenharmony_ci    include_dirs = [
114800b99b8Sopenharmony_ci      "$faultloggerd_common_path/cutil",
115800b99b8Sopenharmony_ci      "$faultloggerd_common_path/dfxlog",
116800b99b8Sopenharmony_ci    ]
117800b99b8Sopenharmony_ci    defines = [ "DFX_LOG_HILOG_BASE" ]
118800b99b8Sopenharmony_ci    version_script = "libdfx_signalhandler.map"
119800b99b8Sopenharmony_ci    sources = [
120800b99b8Sopenharmony_ci      "dfx_dumprequest.c",
121800b99b8Sopenharmony_ci      "dfx_signalhandler_exception.c",
122800b99b8Sopenharmony_ci    ]
123800b99b8Sopenharmony_ci
124800b99b8Sopenharmony_ci    deps = [
125800b99b8Sopenharmony_ci      "$faultloggerd_common_path/cutil:dfx_cutil",
126800b99b8Sopenharmony_ci      "$faultloggerd_common_path/dfxlog:dfx_hilog_base",
127800b99b8Sopenharmony_ci    ]
128800b99b8Sopenharmony_ci
129800b99b8Sopenharmony_ci    external_deps = [
130800b99b8Sopenharmony_ci      "c_utils:utils",
131800b99b8Sopenharmony_ci      "hilog:libhilog_base",
132800b99b8Sopenharmony_ci    ]
133800b99b8Sopenharmony_ci
134800b99b8Sopenharmony_ci    innerapi_tags = [
135800b99b8Sopenharmony_ci      "chipsetsdk_indirect",
136800b99b8Sopenharmony_ci      "platformsdk_indirect",
137800b99b8Sopenharmony_ci    ]
138800b99b8Sopenharmony_ci    install_enable = true
139800b99b8Sopenharmony_ci    install_images = [
140800b99b8Sopenharmony_ci      "system",
141800b99b8Sopenharmony_ci      "updater",
142800b99b8Sopenharmony_ci    ]
143800b99b8Sopenharmony_ci
144800b99b8Sopenharmony_ci    part_name = "faultloggerd"
145800b99b8Sopenharmony_ci    subsystem_name = "hiviewdfx"
146800b99b8Sopenharmony_ci    kernel_permission_path = "./encaps.json"
147800b99b8Sopenharmony_ci  }
148800b99b8Sopenharmony_ci
149800b99b8Sopenharmony_ci  static_library("dfxsignalhandler") {
150800b99b8Sopenharmony_ci    cflags = [ "-DDFX_SIGNAL_LIBC" ]
151800b99b8Sopenharmony_ci
152800b99b8Sopenharmony_ci    sources = [
153800b99b8Sopenharmony_ci      "dfx_signal_handler.c",
154800b99b8Sopenharmony_ci      "dfx_signalhandler_exception.c",
155800b99b8Sopenharmony_ci      "musl_log.c",
156800b99b8Sopenharmony_ci    ]
157800b99b8Sopenharmony_ci
158800b99b8Sopenharmony_ci    configs -= inherited_configs
159800b99b8Sopenharmony_ci    configs += [
160800b99b8Sopenharmony_ci      "//build/config/compiler:compiler",
161800b99b8Sopenharmony_ci      ":static_sighandler_config",
162800b99b8Sopenharmony_ci    ]
163800b99b8Sopenharmony_ci  }
164800b99b8Sopenharmony_ci}
165