1# Copyright (c) 2022-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
14if (defined(ohos_lite)) {
15  import("//build/lite/config/component/lite_component.gni")
16} else {
17  import("//build/ohos.gni")
18}
19
20import("//foundation/distributedhardware/device_manager/device_manager.gni")
21
22if (defined(ohos_lite)) {
23  if (ohos_kernel_type == "linux") {
24    executable("devicemanagerservice") {
25      include_dirs = [
26        "include",
27        "include/advertise",
28        "include/discovery",
29        "include/softbus",
30        "include/ipc/lite",
31        "include/permission/lite",
32        "include/pinholder",
33        "include/relationshipsyncmgr",
34        "${common_path}/include",
35        "${common_path}/include/ipc",
36        "${common_path}/include/ipc/lite",
37        "${common_path}/include/ipc/model",
38        "${common_path}/include/dfx",
39        "${common_path}/include/dfx/lite",
40        "${utils_path}/include",
41        "${utils_path}/include/appInfo/lite",
42        "${utils_path}/include/crypto",
43        "${utils_path}/include/fwkload/lite",
44        "${utils_path}/include/kvadapter",
45        "${utils_path}/include/timer/lite",
46        "${innerkits_path}/native_cpp/include",
47        "${innerkits_path}/native_cpp/include/ipc",
48        "${innerkits_path}/native_cpp/include/ipc/lite",
49        "//third_party/json/include",
50        "//third_party/bounds_checking_function/include",
51        "//base/hiviewdfx/hilog_lite/interfaces/native/kits/hilog",
52        "//base/hiviewdfx/hilog_lite/interfaces/native/kits/hilog_lite",
53        "${interfaces_path}/c/ipc/include",
54        "//foundation/distributedshedule/samgr_lite/interfaces/kits/samgr",
55        "//foundation/systemabilitymgr/samgr/interfaces/innerkits/samgr_proxy/include",
56        "${devicemanager_path}/radar/include",
57        "${softbuscache_parh}/include",
58      ]
59
60      sources = [
61        "${common_path}/src/dm_anonymous.cpp",
62        "src/advertise/advertise_manager.cpp",
63        "src/device_manager_service.cpp",
64        "src/device_manager_service_listener.cpp",
65        "src/discovery/discovery_filter.cpp",
66        "src/discovery/discovery_manager.cpp",
67        "src/ipc/lite/ipc_cmd_parser.cpp",
68        "src/ipc/lite/ipc_server_listener.cpp",
69        "src/ipc/lite/ipc_server_listenermgr.cpp",
70        "src/ipc/lite/ipc_server_main.cpp",
71        "src/ipc/lite/ipc_server_stub.cpp",
72        "src/permission/lite/permission_manager.cpp",
73        "src/pinholder/pin_holder.cpp",
74        "src/pinholder/pin_holder_session.cpp",
75        "src/relationshipsyncmgr/relationship_sync_mgr.cpp",
76        "src/softbus/mine_softbus_listener.cpp",
77        "src/softbus/softbus_listener.cpp",
78      ]
79
80      defines = [
81        "LITE_DEVICE",
82        "HI_LOG_ENABLE",
83        "DH_LOG_TAG=\"devicemanagerservice\"",
84        "LOG_DOMAIN=0xD004110",
85      ]
86
87      deps = [
88        "${devicemanager_path}/radar:devicemanagerradar",
89        "${softbuscache_parh}:dmdevicecache",
90        "${utils_path}:devicemanagerutils",
91        "//base/security/device_auth/services:deviceauth_sdk",
92        "//base/startup/init/interfaces/innerkits:libbegetutil",
93        "//commonlibrary/utils_lite:utils",
94        "//foundation/communication/dsoftbus:dsoftbus",
95        "//foundation/systemabilitymgr/safwk_lite:safwk_lite",
96        "//foundation/systemabilitymgr/samgr_lite/samgr:samgr",
97        "//third_party/bounds_checking_function:libsec_shared",
98        "//third_party/openssl:libcrypto_shared",
99      ]
100
101      cflags = [
102        "-Wall",
103        "-O2",
104        "-Wdate-time",
105        "-Wextra",
106        "-Wfloat-equal",
107        "-Wshadow",
108      ]
109
110      cflags_cc = cflags
111    }
112  }
113} else if (!support_jsapi) {
114  group("devicemanagerservice") {
115    deps = []
116  }
117} else {
118  config("devicemanagerservice_config") {
119    include_dirs = [
120      "include",
121      "include/advertise",
122      "include/devicenamemgr",
123      "include/discovery",
124      "include/ipc",
125      "include/ipc/standard",
126      "include/permission/standard",
127      "include/pinholder",
128      "include/publishcommonevent",
129      "include/relationshipsyncmgr",
130      "include/softbus",
131      "${common_path}/include",
132      "${common_path}/include/dfx",
133      "${common_path}/include/dfx/standard",
134      "${common_path}/include/ipc",
135      "${common_path}/include/ipc/model",
136      "${common_path}/include/ipc/standard",
137      "${devicemanager_path}/commondependency/include",
138      "${devicemanager_path}/radar/include",
139      "${innerkits_path}/native_cpp/include",
140      "${softbuscache_parh}/include",
141      "${utils_path}/include/appInfo/standard",
142      "${utils_path}/include/crypto",
143      "${utils_path}/include/kvadapter",
144      "${utils_path}/include/timer",
145    ]
146  }
147
148  ohos_shared_library("devicemanagerservice") {
149    branch_protector_ret = "pac_ret"
150
151    sanitize = {
152      boundary_sanitize = true
153      cfi = true
154      cfi_cross_dso = true
155      debug = false
156      integer_overflow = true
157      ubsan = true
158    }
159
160    sources = [
161      "${common_path}/src/dfx/standard/dm_hidumper.cpp",
162      "${common_path}/src/dm_anonymous.cpp",
163      "${common_path}/src/ipc/standard/ipc_cmd_register.cpp",
164      "src/advertise/advertise_manager.cpp",
165      "src/device_manager_service.cpp",
166      "src/device_manager_service_listener.cpp",
167      "src/devicenamemgr/account_boot_listener.cpp",
168      "src/devicenamemgr/local_device_name_mgr.cpp",
169      "src/devicenamemgr/settings_data_event_monitor.cpp",
170      "src/discovery/discovery_filter.cpp",
171      "src/discovery/discovery_manager.cpp",
172      "src/ipc/standard/ipc_cmd_parser.cpp",
173      "src/ipc/standard/ipc_server_client_proxy.cpp",
174      "src/ipc/standard/ipc_server_listener.cpp",
175      "src/ipc/standard/ipc_server_stub.cpp",
176      "src/permission/standard/permission_manager.cpp",
177      "src/pinholder/pin_holder.cpp",
178      "src/pinholder/pin_holder_session.cpp",
179      "src/publishcommonevent/dm_account_common_event.cpp",
180      "src/publishcommonevent/dm_data_share_common_event.cpp",
181      "src/publishcommonevent/dm_package_common_event.cpp",
182      "src/publishcommonevent/dm_screen_common_event.cpp",
183      "src/relationshipsyncmgr/relationship_sync_mgr.cpp",
184      "src/softbus/mine_softbus_listener.cpp",
185      "src/softbus/softbus_listener.cpp",
186    ]
187
188    public_configs = [ ":devicemanagerservice_config" ]
189
190    defines = [
191      "HI_LOG_ENABLE",
192      "DH_LOG_TAG=\"devicemanagerservice\"",
193      "LOG_DOMAIN=0xD004110",
194    ]
195
196    deps = [
197      "${devicemanager_path}/commondependency:devicemanagerdependency",
198      "${devicemanager_path}/radar:devicemanagerradar",
199      "${softbuscache_parh}:dmdevicecache",
200      "${utils_path}:devicemanagerutils",
201    ]
202
203    external_deps = [
204      "ability_base:want",
205      "access_token:libaccesstoken_sdk",
206      "access_token:libtokenid_sdk",
207      "bundle_framework:appexecfwk_base",
208      "cJSON:cjson",
209      "c_utils:utils",
210      "common_event_service:cesfwk_core",
211      "common_event_service:cesfwk_innerkits",
212      "data_share:datashare_common",
213      "data_share:datashare_consumer",
214      "device_info_manager:distributed_device_profile_common",
215      "device_info_manager:distributed_device_profile_sdk",
216      "dsoftbus:softbus_client",
217      "eventhandler:libeventhandler",
218      "ffrt:libffrt",
219      "hicollie:libhicollie",
220      "hilog:libhilog",
221      "init:libbeget_proxy",
222      "init:libbegetutil",
223      "ipc:ipc_core",
224      "ipc:ipc_single",
225      "openssl:libcrypto_shared",
226      "os_account:libaccountkits",
227      "os_account:os_account_innerkits",
228      "safwk:system_ability_fwk",
229      "samgr:samgr_proxy",
230    ]
231
232    if (support_bluetooth || support_wifi) {
233      sources += [
234        "src/publishcommonevent/dm_publish_common_event.cpp",
235        "src/softbus/softbus_publish.cpp",
236      ]
237    }
238
239    if (support_bluetooth) {
240      defines += [ "SUPPORT_BLUETOOTH" ]
241      external_deps += [ "bluetooth:btframework" ]
242    }
243
244    if (support_wifi) {
245      defines += [ "SUPPORT_WIFI" ]
246      external_deps += [ "wifi:wifi_sdk" ]
247    }
248
249    if (support_power_manager) {
250      defines += [ "SUPPORT_POWER_MANAGER" ]
251      external_deps += [ "power_manager:powermgr_client" ]
252    }
253
254    if (support_memmgr) {
255      defines += [ "SUPPORT_MEMMGR" ]
256      external_deps += [ "memmgr:memmgrclient" ]
257    }
258
259    public_external_deps = [ "json:nlohmann_json_static" ]
260
261    subsystem_name = "distributedhardware"
262
263    part_name = "device_manager"
264  }
265}
266