• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2021-2025 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("../../dsoftbus.gni")
15import("../connection/common/conn_common.gni")
16import("../transmission/common/trans_common.gni")
17
18softbus_adapter_common = "${dsoftbus_root_path}/adapter/common"
19
20common_utils_src = [
21  "bitmap/softbus_bitmap.c",
22  "network/softbus_network_utils.c",
23  "json_utils/softbus_json_utils.c",
24  "queue/softbus_queue.c",
25  "security/sequence_verification/softbus_sequence_verification.c",
26  "softbus_property/softbus_feature_config.c",
27  "$dsoftbus_root_path/core/frame/common/src/softbus_init_common.c",
28  "utils/softbus_tlv_utils.c",
29  "utils/softbus_utils.c",
30  "$dsoftbus_dfx_path/event/legacy/softbus_hisysevt_bus_center.c",
31  "$dsoftbus_dfx_path/event/legacy/softbus_hisysevt_common.c",
32  "$dsoftbus_dfx_path/event/legacy/softbus_hisysevt_connreporter.c",
33  "$dsoftbus_dfx_path/event/legacy/softbus_hisysevt_discreporter.c",
34  "$dsoftbus_dfx_path/event/legacy/softbus_hisysevt_transreporter.c",
35]
36dsoftbus_plugin_inc = [
37  "$dsoftbus_root_path/interfaces/kits/adapter",
38  "$dsoftbus_root_path/interfaces/kits/authentication",
39  "$dsoftbus_root_path/interfaces/kits/authentication/enhance",
40  "$dsoftbus_root_path/interfaces/kits/broadcast",
41  "$dsoftbus_root_path/interfaces/kits/bus_center",
42  "$dsoftbus_root_path/interfaces/kits/connect",
43  "$dsoftbus_root_path/interfaces/kits/disc",
44  "$dsoftbus_root_path/interfaces/kits/lnn",
45  "$dsoftbus_root_path/interfaces/kits/lnn/enhance",
46  "$dsoftbus_root_path/interfaces/kits/transport",
47  "$dsoftbus_root_path/core/common/include",
48  "$dsoftbus_root_path/adapter/common/include",
49  "$dsoftbus_root_path/sdk/bus_center/interface/common",
50  "$dsoftbus_root_path/core/frame/init/include",
51  "$dsoftbus_root_path/core/connection/wifi_direct_cpp/adapter",
52  "$dsoftbus_root_path/core/connection/wifi_direct_cpp/entity",
53  "$dsoftbus_root_path/core/connection/wifi_direct_cpp/data",
54  "$dsoftbus_root_path/core/connection/wifi_direct_cpp",
55  "$dsoftbus_root_path/core/connection/wifi_direct_cpp/utils",
56  "$dsoftbus_root_path/core/connection/wifi_direct_cpp/protocol",
57  "$dsoftbus_root_path/interfaces/kits/broadcast/enhance",
58  "$dsoftbus_root_path/interfaces/kits/adapter/enhance",
59  "$dsoftbus_root_path/interfaces/kits/nstackx",
60  "$dsoftbus_root_path/interfaces/kits/sdk",
61  "$dsoftbus_root_path/sdk/transmission/trans_channel/udp/stream/libsoftbus_stream",
62  "$dsoftbus_root_path/interfaces/inner_kits/lnn",
63  "$dsoftbus_root_path/sdk/frame/init/include",
64  "$dsoftbus_root_path/core/frame/common/include",
65]
66external_deps = []
67
68if (defined(ohos_lite)) {
69  if (ohos_kernel_type == "liteos_m") {
70    diff_deps = [
71      "$hilog_lite_deps_path",
72      "//build/lite/config/component/cJSON:cjson_static",
73    ]
74    diff_external_deps = [ "bounds_checking_function:libsec_static" ]
75    build_type = "static_library"
76  } else {
77    diff_deps = [
78      "$hilog_lite_deps_path",
79      "//build/lite/config/component/cJSON:cjson_shared",
80    ]
81    diff_external_deps = [ "bounds_checking_function:libsec_shared" ]
82    build_type = "shared_library"
83  }
84  config("dsoftbus_utils_interface") {
85    include_dirs = [
86      "$dsoftbus_dfx_path/interface/include",
87      "$dsoftbus_root_path/core/common/include",
88      "$dsoftbus_root_path/interfaces/kits/common",
89      "$softbus_adapter_common/include",
90      "$hilog_lite_include_path",
91      "$utils_lite_include_path",
92    ]
93    include_dirs += conn_common_inc + trans_common_inc + dsoftbus_plugin_inc
94    if (board_toolchain_type != "iccarm") {
95      cflags = [
96        "-ffunction-sections",
97        "-fdata-sections",
98        "-Os",
99      ]
100    } else {
101      cflags = [
102        "--diag_suppress",
103        "Pe186",
104        "-Os",
105      ]
106    }
107    cflags_cc = cflags
108  }
109
110  target(build_type, "softbus_utils") {
111    include_dirs = [
112      "$dsoftbus_root_path/interfaces/kits/common",
113      "$dsoftbus_root_path/components/nstackx/nstackx_core/dfile/interface",
114      "$dsoftbus_root_path/core/frame/init/include",
115    ]
116    include_dirs += conn_common_inc + trans_common_inc + dsoftbus_plugin_inc
117    dfx_src =
118        [ "$dsoftbus_dfx_path/event/legacy/softbus_hisysevt_nstack_virtual.c" ]
119    sources = common_utils_src
120    sources += conn_common_src + trans_common_src + dfx_src
121    sources += [ "message_handler/message_handler.c" ]
122    if (board_toolchain_type != "iccarm") {
123      cflags = [
124        "-Wall",
125        "-fPIC",
126        "-std=c99",
127      ]
128    }
129    if (ohos_kernel_type == "liteos_m") {
130      defines += [ "SOFTBUS_LITEOS_M" ]
131      defines += [ "__STDC_FORMAT_MACROS" ]
132    } else {
133      defines += [ "DEFAULT_STORAGE_PATH=\"/storage/data\"" ]
134      defines += [ "__STDC_FORMAT_MACROS" ]
135      defines += [ "SOFTBUS_LITEOS_A" ]
136    }
137    deps = [
138      "$dsoftbus_dfx_path:softbus_dfx",
139      "$dsoftbus_root_path/adapter:softbus_adapter",
140    ]
141    deps += diff_deps
142    external_deps += diff_external_deps
143    public_configs = [ ":dsoftbus_utils_interface" ]
144  }
145} else {
146  dstream_native_source_path = rebase_path("$dsoftbus_root_path")
147  dstream_dep_file = "components/nstackx_enhanced/fillp/BUILD.gn"
148  enhanced = exec_script("$dsoftbus_root_path/check_sub_module.py",
149                         [
150                           "$dstream_native_source_path",
151                           "$dstream_dep_file",
152                         ],
153                         "value")
154
155  cflags = [ "-DFILLP_LINUX" ]
156  config("dsoftbus_utils_interface_L2") {
157    include_dirs = [
158      "$dsoftbus_dfx_path/interface/include",
159      "$dsoftbus_root_path/core/common/include",
160      "$dsoftbus_root_path/interfaces/kits/common",
161      "$softbus_adapter_common/include",
162      "$dsoftbus_root_path/components/nstackx/nstackx_core/dfile/interface",
163    ]
164    include_dirs += conn_common_inc + trans_common_inc + dsoftbus_plugin_inc
165  }
166  config("dsoftbus_utils_link_config") {
167    ldflags = [ "-Wl,--lto-O0" ]
168  }
169  ohos_shared_library("softbus_utils") {
170    sanitize = {
171      ubsan = true
172      integer_overflow = true
173      boundary_sanitize = true
174      cfi = true
175      cfi_cross_dso = true
176      debug = false
177    }
178    branch_protector_ret = "pac_ret"
179
180    include_dirs = [
181      "$dsoftbus_root_path/interfaces/kits/common",
182      "$dsoftbus_root_path/interfaces/kits/lnn",
183      "$dsoftbus_root_path/core/bus_center/utils/include",
184      "$dsoftbus_root_path/core/common/include",
185      "$dsoftbus_root_path/components/nstackx/fillp/include",
186      "$dsoftbus_root_path/components/nstackx/nstackx_core/dfile/interface",
187      "$dsoftbus_root_path/components/nstackx/nstackx_util/interface",
188      "$dsoftbus_root_path/components/nstackx/nstackx_ctrl/interface",
189      "$dsoftbus_root_path/interfaces/kits/nstackx",
190      "$dsoftbus_root_path/core/frame/init/include",
191    ]
192    include_dirs += conn_common_inc + trans_common_inc + dsoftbus_plugin_inc
193    dfx_source = [
194      "$dsoftbus_dfx_path/dumper/legacy/softbus_hidumper.c",
195      "$dsoftbus_dfx_path/dumper/legacy/softbus_hidumper_bc_mgr.c",
196      "$dsoftbus_dfx_path/dumper/legacy/softbus_hidumper_broadcast.c",
197      "$dsoftbus_dfx_path/dumper/legacy/softbus_hidumper_disc.c",
198      "$dsoftbus_dfx_path/dumper/legacy/softbus_hidumper_conn.c",
199      "$dsoftbus_dfx_path/dumper/legacy/softbus_hidumper_nstack.c",
200      "$dsoftbus_dfx_path/dumper/legacy/softbus_hidumper_trans.c",
201      "$dsoftbus_dfx_path/dumper/legacy/softbus_hidumper_buscenter.c",
202      "$dsoftbus_dfx_path/event/legacy/softbus_hisysevt_nstack.c",
203    ]
204    sources = common_utils_src + conn_common_src + trans_common_src + dfx_source
205    sources += [ "$dsoftbus_root_path/core/common/utils/sqlite3_utils.c" ]
206    defines += [ "DEFAULT_STORAGE_PATH=\"/data/service/el1/public\"" ]
207    defines += [ "__STDC_FORMAT_MACROS" ]
208    if (is_asan) {
209      defines += [ "ASAN_BUILD" ]
210    }
211
212    configs = [ ":dsoftbus_utils_link_config" ]
213    public_configs = [ ":dsoftbus_utils_interface_L2" ]
214    deps = [
215      "$dsoftbus_dfx_path:softbus_dfx",
216      "$dsoftbus_root_path/adapter:softbus_adapter",
217    ]
218    public_external_deps = [
219      "cJSON:cjson",
220      "sqlite:sqlite",
221    ]
222    external_deps += [
223      "bounds_checking_function:libsec_shared",
224      "cJSON:cjson",
225    ]
226    if (!enhanced) {
227      cflags += [ "-DFILLP_ENHANCED" ]
228      if (dsoftbus_feature_dfile) {
229        cflags += [ "-DDFILE_OPEN" ]
230      }
231      if (dsoftbus_feature_vtp) {
232        cflags += [ "-DDFILLP_OPEN" ]
233      }
234      deps += [
235        "$dsoftbus_root_path/components/nstackx/fillp:FillpSo.open",
236        "$dsoftbus_root_path/components/nstackx/nstackx_core/dfile:nstackx_dfile.open",
237        "$dsoftbus_root_path/components/nstackx/nstackx_ctrl:nstackx_ctrl",
238        "$dsoftbus_root_path/components/nstackx/nstackx_util:nstackx_util.open",
239      ]
240    }
241    if (is_standard_system) {
242      sources += [ "message_handler/message_handler_ffrt.cpp" ]
243      external_deps += [
244        "ffrt:libffrt",
245        "hilog:libhilog",
246        "hisysevent:libhisysevent",
247      ]
248    } else {
249      sources += [ "message_handler/message_handler.c" ]
250    }
251    innerapi_tags = [ "platformsdk_indirect" ]
252    part_name = "dsoftbus"
253    subsystem_name = "communication"
254  }
255}
256