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("../core/common/dfx/dsoftbus_dfx.gni")
15import("../dsoftbus.gni")
16import("bus_center/bus_center_sdk.gni")
17import("frame/frame_sdk.gni")
18import("transmission/trans_sdk.gni")
19
20dsoftbus_root_path = ".."
21
22common_client_src = bus_center_sdk_src + softbus_client_frame_src +
23                    trans_session_manager_sdk_src
24common_client_inc = bus_center_sdk_inc + softbus_client_frame_inc +
25                    trans_session_manager_sdk_inc
26common_client_deps = bus_center_sdk_deps + trans_session_manager_sdk_deps
27
28common_client_ext_deps = []
29
30common_client_deps += [
31  "$dsoftbus_dfx_path/anonymize:softbus_dfx_anonymizer",
32  "$dsoftbus_dfx_path/log:softbus_dfx_log",
33  "$dsoftbus_root_path/adapter:softbus_adapter",
34  "$dsoftbus_root_path/core/common:softbus_utils",
35]
36
37if (defined(ohos_lite)) {
38  if (dsoftbus_feature_build_shared_sdk == true) {
39    build_type = "shared_library"
40  } else {
41    build_type = "static_library"
42  }
43  if (ohos_kernel_type != "liteos_m") {
44    common_client_deps += [
45      "//foundation/communication/ipc/interfaces/innerkits/c/ipc:ipc_single",
46      "//foundation/systemabilitymgr/samgr_lite/samgr:samgr",
47    ]
48    common_client_ext_deps += [ "bounds_checking_function:libsec_shared" ]
49  }
50} else {
51  if (dsoftbus_feature_build_shared_sdk == true) {
52    build_type = "ohos_shared_library"
53  } else {
54    build_type = "ohos_static_library"
55  }
56  common_client_ext_deps += [
57    "access_token:libaccesstoken_sdk",
58    "bounds_checking_function:libsec_shared",
59  ]
60}
61
62config("dsoftbus_sdk_interface") {
63  include_dirs = [
64    "$dsoftbus_root_path/interfaces/kits",
65    "$dsoftbus_root_path/interfaces/inner_kits/lnn",
66    "$dsoftbus_root_path/interfaces/kits/bus_center",
67    "$dsoftbus_root_path/interfaces/kits/common",
68    "$dsoftbus_root_path/interfaces/kits/discovery",
69    "$dsoftbus_root_path/interfaces/kits/transport",
70    "$dsoftbus_root_path/sdk/transmission/session/cpp/include",
71    "$dsoftbus_root_path/interfaces/inner_kits/transport",
72    "$dsoftbus_root_path/core/common/dfx/hisysevent_adapter/include",
73    "$dsoftbus_root_path/core/common/dfx/interface/include",
74  ]
75
76  if (enhanced_kits_broadcast) {
77    include_dirs +=
78        [ "$dsoftbus_root_path/dsoftbus_enhance/interfaces/kits/broadcast" ]
79  }
80
81  if (dsoftbus_feature_ex_kits) {
82    include_dirs +=
83        [ "$dsoftbus_root_path/dsoftbus_enhance/interfaces/kits/bus_center" ]
84  }
85
86  if (schema_enhanced) {
87    include_dirs += [
88      "$dsoftbus_root_path/dsoftbus_enhance/interfaces/kits/transport",
89      "$dsoftbus_root_path/core/transmission/common/include",
90    ]
91  }
92}
93
94target(build_type, "softbus_client") {
95  sources = common_client_src
96  include_dirs = common_client_inc
97  deps = common_client_deps
98  external_deps = common_client_ext_deps + libsoftbus_stream_ext_deps
99  all_dependent_configs = [ ":dsoftbus_sdk_interface" ]
100  public_configs = [ ":dsoftbus_sdk_interface" ]
101  defines += TRANS_SDK_DEFINES
102
103  if (defined(ohos_lite)) {
104    cflags_cc = [ "-stdc=c++14" ]
105    if (board_toolchain_type != "iccarm") {
106      configs -= [ "//build/lite/config:language_cpp" ]
107      cflags = [ "-fPIC" ]
108      cflags_cc += [ "-fPIC" ]
109    } else {
110      cflags = [
111        "--diag_suppress",
112        "Pa153",
113      ]
114    }
115    ldflags = [ "-lstdc++" ]
116  } else {
117    sanitize = {
118      cfi = true
119      cfi_cross_dso = true
120      debug = false
121    }
122    branch_protector_ret = "pac_ret"
123
124    version_script = "libsoftbus_client_map"
125    cflags = [ "-fPIC" ]
126    cflags_cc = [ "-std=c++14" ]
127    if (is_standard_system) {
128      external_deps += [
129        "access_token:libtokenid_sdk",
130        "c_utils:utils",
131        "hicollie:libhicollie",
132        "hilog:libhilog",
133        "ipc:ipc_single",
134      ]
135    }
136    if (defined(global_parts_info) &&
137        defined(global_parts_info.hiviewdfx_hicollie)) {
138      external_deps += [ "hicollie:libhicollie" ]
139    }
140    innerapi_tags = [ "platformsdk_indirect" ]
141    part_name = "dsoftbus"
142    subsystem_name = "communication"
143  }
144}
145