1# Copyright (c) 2022-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 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/hichain", 30 "include/notify", 31 "include/softbus", 32 "include/ipc/lite", 33 "include/permission/lite", 34 "include/pinholder", 35 "${common_path}/include", 36 "${common_path}/include/ipc", 37 "${common_path}/include/ipc/lite", 38 "${common_path}/include/ipc/model", 39 "${common_path}/include/dfx", 40 "${common_path}/include/dfx/lite", 41 "${utils_path}/include", 42 "${utils_path}/include/appInfo/lite", 43 "${utils_path}/include/crypto", 44 "${utils_path}/include/fwkload/lite", 45 "${utils_path}/include/kvadapter", 46 "${utils_path}/include/timer/lite", 47 "${json_path}/include", 48 "${innerkits_path}/native_cpp/include", 49 "${innerkits_path}/native_cpp/include/ipc", 50 "${innerkits_path}/native_cpp/include/ipc/lite", 51 "//third_party/bounds_checking_function/include", 52 "//base/hiviewdfx/hilog_lite/interfaces/native/kits/hilog", 53 "//base/hiviewdfx/hilog_lite/interfaces/native/kits/hilog_lite", 54 "${interfaces_path}/c/ipc/include", 55 "//foundation/communication/dsoftbus/interfaces/kits/bus_center", 56 "//foundation/communication/dsoftbus/interfaces/inner_kits/transport", 57 "//foundation/communication/dsoftbus/interfaces/kits/common", 58 "//foundation/communication/dsoftbus/interfaces/kits/transport", 59 "//foundation/distributedshedule/samgr_lite/interfaces/kits/samgr", 60 "//foundation/systemabilitymgr/samgr/interfaces/innerkits/samgr_proxy/include", 61 "${devicemanager_path}/radar/include", 62 "${softbuscache_parh}/include", 63 ] 64 65 sources = [ 66 "${common_path}/src/dm_anonymous.cpp", 67 "src/advertise/advertise_manager.cpp", 68 "src/device_manager_service.cpp", 69 "src/device_manager_service_listener.cpp", 70 "src/discovery/discovery_filter.cpp", 71 "src/discovery/discovery_manager.cpp", 72 "src/ipc/lite/ipc_cmd_parser.cpp", 73 "src/ipc/lite/ipc_server_listener.cpp", 74 "src/ipc/lite/ipc_server_listenermgr.cpp", 75 "src/ipc/lite/ipc_server_main.cpp", 76 "src/ipc/lite/ipc_server_stub.cpp", 77 "src/notify/device_manager_service_notify.cpp", 78 "src/permission/lite/permission_manager.cpp", 79 "src/pinholder/pin_holder.cpp", 80 "src/pinholder/pin_holder_session.cpp", 81 "src/softbus/mine_softbus_listener.cpp", 82 "src/softbus/softbus_listener.cpp", 83 ] 84 85 defines = [ 86 "LITE_DEVICE", 87 "HI_LOG_ENABLE", 88 "DH_LOG_TAG=\"devicemanagerservice\"", 89 "LOG_DOMAIN=0xD004110", 90 ] 91 92 deps = [ 93 "${devicemanager_path}/radar:devicemanagerradar", 94 "${innerkits_path}/native_cpp:devicemanagersdk", 95 "${json_path}:devicemanagerjson", 96 "${softbuscache_parh}:dmdevicecache", 97 "${utils_path}:devicemanagerutils", 98 "//base/security/device_auth/services:deviceauth_sdk", 99 "//base/startup/init/interfaces/innerkits:libbegetutil", 100 "//commonlibrary/utils_lite:utils", 101 "//foundation/communication/dsoftbus:dsoftbus", 102 "//foundation/systemabilitymgr/safwk_lite:safwk_lite", 103 "//foundation/systemabilitymgr/samgr_lite/samgr:samgr", 104 ] 105 106 external_deps = [ 107 "bounds_checking_function:libsec_shared", 108 "json:nlohmann_json_static", 109 "openssl:libcrypto_shared", 110 ] 111 112 cflags = [ 113 "-Wall", 114 "-O2", 115 "-Wdate-time", 116 "-Wextra", 117 "-Wfloat-equal", 118 "-Wshadow", 119 ] 120 121 cflags_cc = cflags 122 } 123 } 124} else if (!support_jsapi) { 125 group("devicemanagerservice") { 126 deps = [] 127 } 128} else { 129 config("devicemanagerservice_config") { 130 include_dirs = [ 131 "include", 132 "include/advertise", 133 "include/devicenamemgr", 134 "include/discovery", 135 "include/hichain", 136 "include/ipc", 137 "include/ipc/standard", 138 "include/notify", 139 "include/permission/standard", 140 "include/pinholder", 141 "include/publishcommonevent", 142 "include/relationshipsyncmgr", 143 "include/softbus", 144 "${common_path}/include", 145 "${common_path}/include/dfx", 146 "${common_path}/include/dfx/standard", 147 "${common_path}/include/ipc", 148 "${common_path}/include/ipc/model", 149 "${common_path}/include/ipc/standard", 150 "${devicemanager_path}/commondependency/include", 151 "${devicemanager_path}/radar/include", 152 "${innerkits_path}/native_cpp/include", 153 "${softbuscache_parh}/include", 154 "${utils_path}/include/appInfo/standard", 155 "${utils_path}/include/crypto", 156 "${utils_path}/include/kvadapter", 157 "${utils_path}/include/timer", 158 "${json_path}/include", 159 ] 160 } 161 config("cflags_config") { 162 cflags = [ 163 "-Werror", 164 "-fPIC", 165 "-fstack-protector-strong", 166 "-ffunction-sections", 167 "-fdata-sections", 168 "-fvisibility=hidden", 169 "-Oz", 170 "-flto", 171 ] 172 ldflags = [ "-flto" ] 173 } 174 ohos_shared_library("devicemanagerservice") { 175 branch_protector_ret = "pac_ret" 176 177 sanitize = { 178 boundary_sanitize = true 179 cfi = true 180 cfi_cross_dso = true 181 debug = false 182 integer_overflow = true 183 ubsan = true 184 } 185 186 cflags = [ 187 "-Werror", 188 "-fPIC", 189 "-fstack-protector-strong", 190 ] 191 192 ldflags = [ 193 "-Wl,-z,relro", 194 "-Wl,-z,now", 195 ] 196 197 configs = [ ":cflags_config" ] 198 199 sources = [ 200 "${common_path}/src/dfx/standard/dm_hidumper.cpp", 201 "${common_path}/src/dm_anonymous.cpp", 202 "${common_path}/src/ipc/standard/ipc_cmd_register.cpp", 203 "${common_path}/src/ipc/standard/ipc_model_codec.cpp", 204 "src/advertise/advertise_manager.cpp", 205 "src/device_manager_service.cpp", 206 "src/device_manager_service_listener.cpp", 207 "src/devicenamemgr/device_name_change_monitor.cpp", 208 "src/devicenamemgr/device_name_manager.cpp", 209 "src/discovery/discovery_filter.cpp", 210 "src/discovery/discovery_manager.cpp", 211 "src/hichain/hichain_listener.cpp", 212 "src/ipc/standard/ipc_cmd_parser.cpp", 213 "src/ipc/standard/ipc_server_client_proxy.cpp", 214 "src/ipc/standard/ipc_server_listener.cpp", 215 "src/ipc/standard/ipc_server_stub.cpp", 216 "src/notify/device_manager_service_notify.cpp", 217 "src/permission/standard/permission_manager.cpp", 218 "src/pinholder/pin_holder.cpp", 219 "src/pinholder/pin_holder_session.cpp", 220 "src/publishcommonevent/dm_account_common_event.cpp", 221 "src/publishcommonevent/dm_datashare_common_event.cpp", 222 "src/publishcommonevent/dm_package_common_event.cpp", 223 "src/publishcommonevent/dm_screen_common_event.cpp", 224 "src/relationshipsyncmgr/dm_comm_tool.cpp", 225 "src/relationshipsyncmgr/dm_transport.cpp", 226 "src/relationshipsyncmgr/dm_transport_msg.cpp", 227 "src/relationshipsyncmgr/relationship_sync_mgr.cpp", 228 "src/softbus/mine_softbus_listener.cpp", 229 "src/softbus/softbus_listener.cpp", 230 ] 231 232 public_configs = [ ":devicemanagerservice_config" ] 233 234 defines = [ 235 "HI_LOG_ENABLE", 236 "DH_LOG_TAG=\"devicemanagerservice\"", 237 "LOG_DOMAIN=0xD004110", 238 ] 239 240 deps = [ 241 "${devicemanager_path}/commondependency:devicemanagerdependency", 242 "${devicemanager_path}/radar:devicemanagerradar", 243 "${innerkits_path}/native_cpp:devicemanagersdk", 244 "${json_path}:devicemanagerjson", 245 "${softbuscache_parh}:dmdevicecache", 246 "${utils_path}:devicemanagerutils", 247 ] 248 249 external_deps = [ 250 "ability_base:want", 251 "access_token:libaccesstoken_sdk", 252 "access_token:libtokenid_sdk", 253 "bundle_framework:appexecfwk_base", 254 "cJSON:cjson", 255 "common_event_service:cesfwk_innerkits", 256 "data_share:datashare_common", 257 "data_share:datashare_consumer", 258 "device_auth:deviceauth_sdk", 259 "device_info_manager:distributed_device_profile_common", 260 "device_info_manager:distributed_device_profile_sdk", 261 "dsoftbus:softbus_client", 262 "eventhandler:libeventhandler", 263 "ffrt:libffrt", 264 "hicollie:libhicollie", 265 "hilog:libhilog", 266 "init:libbeget_proxy", 267 "init:libbegetutil", 268 "ipc:ipc_core", 269 "ipc:ipc_single", 270 "json:nlohmann_json_static", 271 "openssl:libcrypto_shared", 272 "os_account:libaccountkits", 273 "os_account:os_account_innerkits", 274 "safwk:system_ability_fwk", 275 "samgr:samgr_proxy", 276 ] 277 278 if ((support_bluetooth || support_wifi) && 279 device_manager_feature_product == "default") { 280 sources += [ 281 "src/publishcommonevent/dm_publish_common_event.cpp", 282 "src/softbus/softbus_publish.cpp", 283 ] 284 } 285 286 if (support_bluetooth && device_manager_feature_product == "default") { 287 defines += [ "SUPPORT_BLUETOOTH" ] 288 external_deps += [ "bluetooth:btframework" ] 289 } 290 291 if (support_wifi && device_manager_feature_product == "default") { 292 defines += [ "SUPPORT_WIFI" ] 293 external_deps += [ "wifi:wifi_sdk" ] 294 } 295 296 if (support_power_manager) { 297 defines += [ "SUPPORT_POWER_MANAGER" ] 298 external_deps += [ "power_manager:powermgr_client" ] 299 } 300 301 if (support_memmgr) { 302 defines += [ "SUPPORT_MEMMGR" ] 303 external_deps += [ "memmgr:memmgrclient" ] 304 } 305 306 if (device_manager_common) { 307 defines += [ "DEVICE_MANAGER_COMMON_FLAG" ] 308 } 309 310 if (device_manager_feature_product == "default") { 311 defines += [ "SUPPORT_WISEDEVICE" ] 312 } 313 314 subsystem_name = "distributedhardware" 315 316 part_name = "device_manager" 317 } 318 319 ohos_shared_library("devicemanagerservicetest") { 320 branch_protector_ret = "pac_ret" 321 322 sanitize = { 323 boundary_sanitize = true 324 cfi = true 325 cfi_cross_dso = true 326 debug = false 327 integer_overflow = true 328 ubsan = true 329 } 330 331 cflags = [ 332 "-Werror", 333 "-fPIC", 334 "-fstack-protector-strong", 335 ] 336 337 ldflags = [ 338 "-Wl,-z,relro", 339 "-Wl,-z,now", 340 ] 341 342 sources = [ 343 "${common_path}/src/dfx/standard/dm_hidumper.cpp", 344 "${common_path}/src/dm_anonymous.cpp", 345 "${common_path}/src/ipc/standard/ipc_cmd_register.cpp", 346 "${common_path}/src/ipc/standard/ipc_model_codec.cpp", 347 "src/advertise/advertise_manager.cpp", 348 "src/device_manager_service.cpp", 349 "src/device_manager_service_listener.cpp", 350 "src/devicenamemgr/device_name_change_monitor.cpp", 351 "src/devicenamemgr/device_name_manager.cpp", 352 "src/discovery/discovery_filter.cpp", 353 "src/discovery/discovery_manager.cpp", 354 "src/hichain/hichain_listener.cpp", 355 "src/ipc/standard/ipc_cmd_parser.cpp", 356 "src/ipc/standard/ipc_server_client_proxy.cpp", 357 "src/ipc/standard/ipc_server_listener.cpp", 358 "src/ipc/standard/ipc_server_stub.cpp", 359 "src/notify/device_manager_service_notify.cpp", 360 "src/permission/standard/permission_manager.cpp", 361 "src/pinholder/pin_holder.cpp", 362 "src/pinholder/pin_holder_session.cpp", 363 "src/publishcommonevent/dm_account_common_event.cpp", 364 "src/publishcommonevent/dm_datashare_common_event.cpp", 365 "src/publishcommonevent/dm_package_common_event.cpp", 366 "src/publishcommonevent/dm_screen_common_event.cpp", 367 "src/relationshipsyncmgr/dm_comm_tool.cpp", 368 "src/relationshipsyncmgr/dm_transport.cpp", 369 "src/relationshipsyncmgr/dm_transport_msg.cpp", 370 "src/relationshipsyncmgr/relationship_sync_mgr.cpp", 371 "src/softbus/mine_softbus_listener.cpp", 372 "src/softbus/softbus_listener.cpp", 373 ] 374 375 public_configs = [ ":devicemanagerservice_config" ] 376 377 defines = [ 378 "HI_LOG_ENABLE", 379 "DH_LOG_TAG=\"devicemanagerservice\"", 380 "LOG_DOMAIN=0xD004110", 381 ] 382 383 deps = [ 384 "${devicemanager_path}/commondependency:devicemanagerdependency", 385 "${devicemanager_path}/radar:devicemanagerradar", 386 "${innerkits_path}/native_cpp:devicemanagersdk", 387 "${json_path}:devicemanagerjson", 388 "${softbuscache_parh}:dmdevicecache", 389 "${utils_path}:devicemanagerutils", 390 ] 391 392 external_deps = [ 393 "ability_base:want", 394 "access_token:libaccesstoken_sdk", 395 "access_token:libtokenid_sdk", 396 "cJSON:cjson", 397 "c_utils:utils", 398 "common_event_service:cesfwk_innerkits", 399 "data_share:datashare_common", 400 "data_share:datashare_consumer", 401 "device_auth:deviceauth_sdk", 402 "device_info_manager:distributed_device_profile_common", 403 "device_info_manager:distributed_device_profile_sdk", 404 "dsoftbus:softbus_client", 405 "eventhandler:libeventhandler", 406 "ffrt:libffrt", 407 "hicollie:libhicollie", 408 "hilog:libhilog", 409 "init:libbeget_proxy", 410 "init:libbegetutil", 411 "ipc:ipc_core", 412 "ipc:ipc_single", 413 "json:nlohmann_json_static", 414 "openssl:libcrypto_shared", 415 "os_account:libaccountkits", 416 "os_account:os_account_innerkits", 417 "safwk:system_ability_fwk", 418 "samgr:samgr_proxy", 419 ] 420 421 if ((support_bluetooth || support_wifi) && 422 device_manager_feature_product == "default") { 423 sources += [ 424 "src/publishcommonevent/dm_publish_common_event.cpp", 425 "src/softbus/softbus_publish.cpp", 426 ] 427 } 428 429 if (support_bluetooth && device_manager_feature_product == "default") { 430 defines += [ "SUPPORT_BLUETOOTH" ] 431 external_deps += [ "bluetooth:btframework" ] 432 } 433 434 if (support_wifi && device_manager_feature_product == "default") { 435 defines += [ "SUPPORT_WIFI" ] 436 external_deps += [ "wifi:wifi_sdk" ] 437 } 438 439 if (device_manager_feature_product == "default") { 440 defines += [ "SUPPORT_WISEDEVICE" ] 441 } 442 443 if (support_power_manager) { 444 defines += [ "SUPPORT_POWER_MANAGER" ] 445 external_deps += [ "power_manager:powermgr_client" ] 446 } 447 448 if (support_memmgr) { 449 defines += [ "SUPPORT_MEMMGR" ] 450 external_deps += [ "memmgr:memmgrclient" ] 451 } 452 453 if (device_manager_common) { 454 defines += [ "DEVICE_MANAGER_COMMON_FLAG" ] 455 } 456 457 subsystem_name = "distributedhardware" 458 459 part_name = "device_manager" 460 } 461} 462