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 shared_library("devicemanagerutils") { 25 include_dirs = [ 26 "include", 27 "include/appInfo/lite", 28 "include/crypto", 29 "include/fwkload/lite", 30 "include/jsonstr_handle", 31 "include/timer/lite", 32 "${common_path}/include", 33 "${common_path}/include/dfx", 34 "${common_path}/include/dfx/lite", 35 "${common_path}/include/ipc", 36 "${common_path}/include/ipc/lite", 37 "${common_path}/include/ipc/model", 38 "${innerkits_path}/native_cpp/include", 39 "${interfaces_path}/c/ipc/include", 40 "${json_path}/include", 41 "//third_party/bounds_checking_function/include", 42 ] 43 44 sources = [ 45 "${common_path}/src/dfx/lite/dm_hidumper.cpp", 46 "${common_path}/src/dfx/lite/dm_hisysevent.cpp", 47 "${common_path}/src/dfx/lite/dm_hitrace.cpp", 48 "${common_path}/src/dm_anonymous.cpp", 49 "${common_path}/src/dm_error_message.cpp", 50 "${common_path}/src/ipc/lite/ipc_cmd_register.cpp", 51 "src/appInfo/lite/app_manager.cpp", 52 "src/crypto/dm_crypto.cpp", 53 "src/dm_random.cpp", 54 "src/fwkload/lite/dm_distributed_hardware_load.cpp", 55 "src/jsonstr_handle/dm_jsonstr_handle.cpp", 56 "src/timer/lite/dm_timer.cpp", 57 ] 58 59 defines = [ 60 "LITE_DEVICE", 61 "hI_LOG_ENABLE", 62 "DH_LOG_TAG=\"devicemanagerutils\"", 63 "lOG_DOMAIN=0xD004110", 64 ] 65 66 deps = [ 67 "${json_path}:devicemanagerjson", 68 "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared", 69 ] 70 external_deps = [ 71 "bounds_checking_function:libsec_shared", 72 "openssl:libcrypto_shared", 73 ] 74 } 75 } 76} else { 77 config("devicemanagerutils_config") { 78 include_dirs = [ 79 "include", 80 "include/appInfo/standard", 81 "include/crypto", 82 "include/fwkload/standard", 83 "include/jsonstr_handle", 84 "include/kvadapter", 85 "include/timer", 86 "${innerkits_path}/native_cpp/include", 87 "${common_path}/include", 88 "${json_path}/include", 89 ] 90 } 91 config("cflags_config") { 92 cflags = [ 93 "-Werror", 94 "-fPIC", 95 "-fstack-protector-strong", 96 "-ffunction-sections", 97 "-fdata-sections", 98 "-fvisibility=hidden", 99 "-Oz", 100 "-flto", 101 ] 102 ldflags = [ "-flto" ] 103 } 104 ohos_shared_library("devicemanagerutils") { 105 branch_protector_ret = "pac_ret" 106 107 sanitize = { 108 boundary_sanitize = true 109 cfi = true 110 cfi_cross_dso = true 111 debug = false 112 integer_overflow = true 113 ubsan = true 114 } 115 116 cflags = [ 117 "-fPIC", 118 "-fstack-protector-strong", 119 "-Werror", 120 ] 121 122 ldflags = [ 123 "-Wl,-z,relro", 124 "-Wl,-z,now", 125 ] 126 127 configs = [ ":cflags_config" ] 128 129 sources = [ 130 "${common_path}/src/dm_anonymous.cpp", 131 "src/appInfo/standard/app_manager.cpp", 132 "src/crypto/dm_crypto.cpp", 133 "src/dm_random.cpp", 134 "src/jsonstr_handle/dm_jsonstr_handle.cpp", 135 "src/kvadapter/dm_kv_info.cpp", 136 "src/kvadapter/kv_adapter.cpp", 137 "src/kvadapter/kv_adapter_manager.cpp", 138 "src/timer/dm_timer.cpp", 139 ] 140 141 if (support_jsapi) { 142 sources += [ "src/fwkload/standard/dm_distributed_hardware_load.cpp" ] 143 } 144 145 public_configs = [ ":devicemanagerutils_config" ] 146 147 defines = [ 148 "HI_LOG_ENABLE", 149 "DH_LOG_TAG=\"devicemanagerutils\"", 150 "LOG_DOMAIN=0xD004110", 151 ] 152 153 deps = [ "${json_path}:devicemanagerjson" ] 154 155 external_deps = [ 156 "access_token:libaccesstoken_sdk", 157 "access_token:libtokenid_sdk", 158 "bundle_framework:appexecfwk_base", 159 "bundle_framework:appexecfwk_core", 160 "cJSON:cjson", 161 "c_utils:utils", 162 "eventhandler:libeventhandler", 163 "ffrt:libffrt", 164 "hilog:libhilog", 165 "ipc:ipc_core", 166 "ipc:ipc_single", 167 "openssl:libcrypto_shared", 168 "os_account:os_account_innerkits", 169 "samgr:samgr_proxy", 170 ] 171 172 public_external_deps = [ 173 "bundle_framework:appexecfwk_core", 174 "kv_store:distributeddata_inner", 175 ] 176 177 if (support_jsapi) { 178 external_deps += [ "bundle_framework:appexecfwk_core" ] 179 } 180 181 subsystem_name = "distributedhardware" 182 183 part_name = "device_manager" 184 } 185 186 ohos_shared_library("devicemanagerutilstest") { 187 branch_protector_ret = "pac_ret" 188 189 sanitize = { 190 boundary_sanitize = true 191 cfi = true 192 cfi_cross_dso = true 193 debug = false 194 integer_overflow = true 195 ubsan = true 196 } 197 198 cflags = [ 199 "-fPIC", 200 "-fstack-protector-strong", 201 "-Werror", 202 ] 203 204 ldflags = [ 205 "-Wl,-z,relro", 206 "-Wl,-z,now", 207 ] 208 209 sources = [ 210 "${common_path}/src/dm_anonymous.cpp", 211 "src/appInfo/standard/app_manager.cpp", 212 "src/crypto/dm_crypto.cpp", 213 "src/dm_random.cpp", 214 "src/kvadapter/dm_kv_info.cpp", 215 "src/kvadapter/kv_adapter.cpp", 216 "src/kvadapter/kv_adapter_manager.cpp", 217 "src/timer/dm_timer.cpp", 218 ] 219 220 if (support_jsapi) { 221 sources += [ "src/fwkload/standard/dm_distributed_hardware_load.cpp" ] 222 } 223 224 public_configs = [ ":devicemanagerutils_config" ] 225 226 defines = [ 227 "HI_LOG_ENABLE", 228 "DH_LOG_TAG=\"devicemanagerutils\"", 229 "LOG_DOMAIN=0xD004110", 230 ] 231 232 deps = [ "${json_path}:devicemanagerjson" ] 233 234 external_deps = [ 235 "access_token:libaccesstoken_sdk", 236 "access_token:libtokenid_sdk", 237 "bundle_framework:appexecfwk_base", 238 "bundle_framework:appexecfwk_core", 239 "cJSON:cjson", 240 "c_utils:utils", 241 "eventhandler:libeventhandler", 242 "ffrt:libffrt", 243 "hilog:libhilog", 244 "ipc:ipc_core", 245 "ipc:ipc_single", 246 "openssl:libcrypto_shared", 247 "os_account:os_account_innerkits", 248 "samgr:samgr_proxy", 249 ] 250 251 public_external_deps = [ 252 "bundle_framework:appexecfwk_core", 253 "kv_store:distributeddata_inner", 254 ] 255 256 if (support_jsapi) { 257 external_deps += [ "bundle_framework:appexecfwk_core" ] 258 } 259 260 subsystem_name = "distributedhardware" 261 262 part_name = "device_manager" 263 } 264} 265