# Copyright (c) 2022-2026 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
if (defined(ohos_lite)) {
import("//build/lite/config/component/lite_component.gni")
} else {
import("//build/ohos.gni")
}
import("//foundation/distributedhardware/device_manager/device_manager.gni")
if (defined(ohos_lite)) {
if (ohos_kernel_type == "linux") {
shared_library("devicemanagerutils") {
include_dirs = [
"include",
"include/appInfo/lite",
"include/crypto",
"include/jsonstr_handle",
"include/timer/lite",
"${common_path}/include",
"${common_path}/include/dfx",
"${common_path}/include/dfx/lite",
"${common_path}/include/ipc",
"${common_path}/include/ipc/lite",
"${common_path}/include/ipc/model",
"${innerkits_path}/native_cpp/include",
"${interfaces_path}/c/ipc/include",
"${json_path}/include",
"//third_party/bounds_checking_function/include",
]
sources = [
"${common_path}/src/dfx/lite/dm_hidumper.cpp",
"${common_path}/src/dfx/lite/dm_hisysevent.cpp",
"${common_path}/src/dfx/lite/dm_hitrace.cpp",
"${common_path}/src/dm_anonymous.cpp",
"${common_path}/src/dm_error_message.cpp",
"${common_path}/src/ipc/lite/ipc_cmd_register.cpp",
"src/appInfo/lite/app_manager.cpp",
"src/crypto/dm_crypto.cpp",
"src/dm_random.cpp",
"src/jsonstr_handle/dm_jsonstr_handle.cpp",
"src/timer/lite/dm_timer.cpp",
]
defines = [
"LITE_DEVICE",
"hI_LOG_ENABLE",
"DH_LOG_TAG=\"dmutils\"",
"lOG_DOMAIN=0xD004110",
]
deps = [
"${json_path}:devicemanagerjson",
"//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared",
]
external_deps = [
"bounds_checking_function:libsec_shared",
"openssl:libcrypto_shared",
]
}
}
} else {
config("devicemanagerutils_config") {
include_dirs = [
"include",
"include/appInfo/standard",
"include/crypto",
"include/jsonstr_handle",
"include/kvadapter",
"include/timer",
"${innerkits_path}/native_cpp/include",
"${common_path}/include",
"${json_path}/include",
]
}
config("cflags_config") {
cflags = [
"-Werror",
"-fPIC",
"-fstack-protector-strong",
"-ffunction-sections",
"-fdata-sections",
"-fvisibility=hidden",
"-Oz",
"-flto",
]
ldflags = [ "-flto" ]
}
ohos_shared_library("devicemanagerutils") {
if (!device_manager_capability) {
install_enable = false
} else {
branch_protector_ret = "pac_ret"
sanitize = {
boundary_sanitize = true
cfi = true
cfi_cross_dso = true
debug = false
integer_overflow = true
ubsan = true
}
cflags = [
"-fPIC",
"-fstack-protector-strong",
"-Werror",
]
ldflags = [
"-Wl,-z,relro",
"-Wl,-z,now",
]
configs = [ ":cflags_config" ]
sources = [
"${common_path}/src/dm_anonymous.cpp",
"src/appInfo/standard/app_manager.cpp",
"src/crypto/dm_crypto.cpp",
"src/dm_random.cpp",
"src/jsonstr_handle/dm_jsonstr_handle.cpp",
"src/kvadapter/dm_kv_info.cpp",
"src/kvadapter/kv_adapter.cpp",
"src/kvadapter/kv_adapter_manager.cpp",
"src/timer/dm_timer.cpp",
]
public_configs = [ ":devicemanagerutils_config" ]
defines = [
"HI_LOG_ENABLE",
"DH_LOG_TAG=\"dmutils\"",
"LOG_DOMAIN=0xD004110",
]
deps = [ "${json_path}:devicemanagerjson" ]
external_deps = [
"access_token:libaccesstoken_sdk",
"access_token:libtokenid_sdk",
"bundle_framework:appexecfwk_base",
"bundle_framework:appexecfwk_core",
"cJSON:cjson",
"c_utils:utils",
"eventhandler:libeventhandler",
"ffrt:libffrt",
"hilog:libhilog",
"ipc:ipc_core",
"ipc:ipc_single",
"kv_store:distributeddata_inner",
"openssl:libcrypto_shared",
"os_account:os_account_innerkits",
"samgr:samgr_proxy",
"init:libbegetutil",
]
subsystem_name = "distributedhardware"
part_name = "device_manager"
}
}
ohos_shared_library("devicemanagerutilstest") {
if (!device_manager_capability) {
install_enable = false
} else {
branch_protector_ret = "pac_ret"
sanitize = {
boundary_sanitize = true
cfi = true
cfi_cross_dso = true
debug = false
integer_overflow = true
ubsan = true
}
cflags = [
"-fPIC",
"-fstack-protector-strong",
"-Werror",
]
ldflags = [
"-Wl,-z,relro",
"-Wl,-z,now",
]
sources = [
"${common_path}/src/dm_anonymous.cpp",
"src/appInfo/standard/app_manager.cpp",
"src/crypto/dm_crypto.cpp",
"src/dm_random.cpp",
"src/kvadapter/dm_kv_info.cpp",
"src/kvadapter/kv_adapter.cpp",
"src/kvadapter/kv_adapter_manager.cpp",
"src/timer/dm_timer.cpp",
]
public_configs = [ ":devicemanagerutils_config" ]
defines = [
"HI_LOG_ENABLE",
"DH_LOG_TAG=\"dmutils\"",
"LOG_DOMAIN=0xD004110",
]
deps = [ "${json_path}:devicemanagerjson" ]
external_deps = [
"access_token:libaccesstoken_sdk",
"access_token:libtokenid_sdk",
"bundle_framework:appexecfwk_base",
"bundle_framework:appexecfwk_core",
"cJSON:cjson",
"c_utils:utils",
"eventhandler:libeventhandler",
"ffrt:libffrt",
"hilog:libhilog",
"ipc:ipc_core",
"ipc:ipc_single",
"kv_store:distributeddata_inner",
"openssl:libcrypto_shared",
"os_account:os_account_innerkits",
"samgr:samgr_proxy",
"init:libbegetutil",
]
subsystem_name = "distributedhardware"
part_name = "device_manager"
}
}
}