• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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("../../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  "utils/softbus_utils.c",
28  "$dsoftbus_dfx_path/event/legacy/softbus_hisysevt_bus_center.c",
29  "$dsoftbus_dfx_path/event/legacy/softbus_hisysevt_common.c",
30  "$dsoftbus_dfx_path/event/legacy/softbus_hisysevt_connreporter.c",
31  "$dsoftbus_dfx_path/event/legacy/softbus_hisysevt_discreporter.c",
32  "$dsoftbus_dfx_path/event/legacy/softbus_hisysevt_transreporter.c",
33]
34external_deps = []
35
36if (defined(ohos_lite)) {
37  if (ohos_kernel_type == "liteos_m") {
38    diff_deps = [
39      "$hilog_lite_deps_path",
40      "//build/lite/config/component/cJSON:cjson_static",
41    ]
42    diff_external_deps = [ "bounds_checking_function:libsec_static" ]
43    build_type = "static_library"
44  } else {
45    diff_deps = [
46      "$hilog_lite_deps_path",
47      "//build/lite/config/component/cJSON:cjson_shared",
48    ]
49    diff_external_deps = [ "bounds_checking_function:libsec_shared" ]
50    build_type = "shared_library"
51  }
52  config("dsoftbus_utils_interface") {
53    include_dirs = [
54      "$dsoftbus_dfx_path/interface/include",
55      "$dsoftbus_root_path/core/common/include",
56      "$dsoftbus_root_path/interfaces/kits/common",
57      "$softbus_adapter_common/include",
58      "$hilog_lite_include_path",
59      "$utils_lite_include_path",
60    ]
61    include_dirs += conn_common_inc + trans_common_inc
62    if (board_toolchain_type != "iccarm") {
63      cflags = [
64        "-ffunction-sections",
65        "-fdata-sections",
66        "-Os",
67      ]
68    } else {
69      cflags = [
70        "--diag_suppress",
71        "Pe186",
72        "-Os",
73      ]
74    }
75    cflags_cc = cflags
76  }
77
78  target(build_type, "softbus_utils") {
79    include_dirs = [
80      "$dsoftbus_root_path/interfaces/kits/common",
81      "$dsoftbus_root_path/components/nstackx/nstackx_core/dfile/interface",
82    ]
83    include_dirs += conn_common_inc + trans_common_inc
84    dfx_src =
85        [ "$dsoftbus_dfx_path/event/legacy/softbus_hisysevt_nstack_virtual.c" ]
86    sources = common_utils_src
87    sources += conn_common_src + trans_common_src + dfx_src
88    sources += [ "message_handler/message_handler.c" ]
89    if (board_toolchain_type != "iccarm") {
90      cflags = [
91        "-Wall",
92        "-fPIC",
93        "-std=c99",
94      ]
95    }
96    if (ohos_kernel_type == "liteos_m") {
97      defines += [ "SOFTBUS_LITEOS_M" ]
98      defines += [ "__STDC_FORMAT_MACROS" ]
99    } else {
100      defines += [ "DEFAULT_STORAGE_PATH=\"/storage/data\"" ]
101      defines += [ "__STDC_FORMAT_MACROS" ]
102      defines += [ "SOFTBUS_LITEOS_A" ]
103    }
104    deps = [
105      "$dsoftbus_dfx_path:softbus_dfx",
106      "$dsoftbus_root_path/adapter:softbus_adapter",
107    ]
108    deps += diff_deps
109    external_deps += diff_external_deps
110    public_configs = [ ":dsoftbus_utils_interface" ]
111  }
112} else {
113  dstream_native_source_path = rebase_path("$dsoftbus_root_path")
114  dstream_dep_file = "components/nstackx_enhanced/fillp/BUILD.gn"
115  enhanced = exec_script("$dsoftbus_root_path/check_sub_module.py",
116                         [
117                           "$dstream_native_source_path",
118                           "$dstream_dep_file",
119                         ],
120                         "value")
121
122  cflags = [ "-DFILLP_LINUX" ]
123  config("dsoftbus_utils_interface_L2") {
124    include_dirs = [
125      "$dsoftbus_dfx_path/interface/include",
126      "$dsoftbus_root_path/core/common/include",
127      "$dsoftbus_root_path/interfaces/kits/common",
128      "$softbus_adapter_common/include",
129      "$dsoftbus_root_path/components/nstackx/nstackx_core/dfile/interface",
130    ]
131    include_dirs += conn_common_inc + trans_common_inc
132  }
133  ohos_shared_library("softbus_utils") {
134    sanitize = {
135      ubsan = true
136      integer_overflow = true
137      boundary_sanitize = true
138      cfi = true
139      cfi_cross_dso = true
140      debug = false
141    }
142    branch_protector_ret = "pac_ret"
143
144    include_dirs = [
145      "$dsoftbus_root_path/interfaces/kits/common",
146      "$dsoftbus_root_path/core/bus_center/utils/include",
147      "$dsoftbus_root_path/core/common/include",
148      "$dsoftbus_root_path/components/nstackx/fillp/include",
149      "$dsoftbus_root_path/components/nstackx/nstackx_core/dfile/interface",
150      "$dsoftbus_root_path/components/nstackx/nstackx_util/interface",
151      "$dsoftbus_root_path/components/nstackx/nstackx_ctrl/interface",
152    ]
153    include_dirs += conn_common_inc + trans_common_inc
154    dfx_source = [
155      "$dsoftbus_dfx_path/dumper/legacy/softbus_hidumper.c",
156      "$dsoftbus_dfx_path/dumper/legacy/softbus_hidumper_bc_mgr.c",
157      "$dsoftbus_dfx_path/dumper/legacy/softbus_hidumper_broadcast.c",
158      "$dsoftbus_dfx_path/dumper/legacy/softbus_hidumper_disc.c",
159      "$dsoftbus_dfx_path/dumper/legacy/softbus_hidumper_conn.c",
160      "$dsoftbus_dfx_path/dumper/legacy/softbus_hidumper_nstack.c",
161      "$dsoftbus_dfx_path/dumper/legacy/softbus_hidumper_trans.c",
162      "$dsoftbus_dfx_path/dumper/legacy/softbus_hidumper_buscenter.c",
163      "$dsoftbus_dfx_path/event/legacy/softbus_hisysevt_nstack.c",
164    ]
165    sources = common_utils_src + conn_common_src + trans_common_src + dfx_source
166    sources += [ "$dsoftbus_root_path/core/common/utils/sqlite3_utils.c" ]
167    defines += [ "DEFAULT_STORAGE_PATH=\"/data/service/el1/public\"" ]
168    defines += [ "__STDC_FORMAT_MACROS" ]
169    if (is_asan) {
170      defines += [ "ASAN_BUILD" ]
171    }
172
173    public_configs = [ ":dsoftbus_utils_interface_L2" ]
174    public_deps = [
175      "$dsoftbus_dfx_path:softbus_dfx",
176      "$dsoftbus_root_path/adapter:softbus_adapter",
177    ]
178    public_external_deps = [
179      "cJSON:cjson",
180      "sqlite:sqlite",
181    ]
182    external_deps += [
183      "bounds_checking_function:libsec_shared",
184      "cJSON:cjson",
185    ]
186    if (!enhanced) {
187      cflags += [ "-DFILLP_ENHANCED" ]
188      if (dsoftbus_feature_dfile) {
189        cflags += [ "-DDFILE_OPEN" ]
190      }
191      if (dsoftbus_feature_vtp) {
192        cflags += [ "-DDFILLP_OPEN" ]
193      }
194      public_deps += [
195        "$dsoftbus_root_path/components/nstackx/fillp:FillpSo.open",
196        "$dsoftbus_root_path/components/nstackx/nstackx_core/dfile:nstackx_dfile.open",
197        "$dsoftbus_root_path/components/nstackx/nstackx_ctrl:nstackx_ctrl",
198        "$dsoftbus_root_path/components/nstackx/nstackx_util:nstackx_util.open",
199      ]
200    }
201    if (is_standard_system) {
202      sources += [ "message_handler/message_handler_ffrt.cpp" ]
203      external_deps += [
204        "ffrt:libffrt",
205        "hilog:libhilog",
206        "hisysevent:libhisysevent",
207      ]
208    } else {
209      sources += [ "message_handler/message_handler.c" ]
210    }
211    innerapi_tags = [ "platformsdk_indirect" ]
212    part_name = "dsoftbus"
213    subsystem_name = "communication"
214  }
215}
216