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("//base/security/device_auth/deps_adapter/deviceauth_hals.gni") 15import("//build/ohos.gni") 16import("deviceauth.gni") 17 18config("deviceauth_config") { 19 include_dirs = [ "//base/security/device_auth/interfaces/inner_api" ] 20} 21include_dirs = inc_path + hals_inc_path 22if (os_level == "mini" || os_level == "small") { 23 static_library("deviceauth") { 24 public_configs = [ ":deviceauth_config" ] 25 include_dirs += [ 26 "//third_party/cJSON", 27 "//commonlibrary/utils_lite/include", 28 "//third_party/bounds_checking_function/include", 29 "//foundation/communication/dsoftbus/interfaces/kits/common", 30 "//foundation/communication/dsoftbus/interfaces/kits/transport", 31 "//foundation/communication/dsoftbus/interfaces/inner_kits/transport", 32 "${dev_frameworks_path}/inc/hiview_adapter", 33 ] 34 sources = deviceauth_files 35 defines = [ "HILOG_ENABLE" ] 36 defines += deviceauth_defines 37 38 sources += identity_manager_files 39 include_dirs += identity_manager_inc 40 41 deps = [ 42 "${deps_adapter_path}:${hal_module_name}", 43 "//build/lite/config/component/cJSON:cjson_shared", 44 "//commonlibrary/utils_lite:utils", 45 ] 46 if (device_auth_enable_soft_bus_channel) { 47 deps += [ "//foundation/communication/dsoftbus/sdk:softbus_client" ] 48 } 49 if (enable_extend_plugin) { 50 defines += [ "DEV_AUTH_PLUGIN_ENABLE" ] 51 if (os_level == "mini") { 52 sources += [ 53 "${dev_frameworks_path}/src/plugin_adapter/static_plugin_adapter.c", 54 ] 55 } else { 56 sources += [ 57 "${dev_frameworks_path}/src/plugin_adapter/dynamic_plugin_adapter.c", 58 "${dev_frameworks_path}/src/plugin_adapter/ext_part/account_lifecycle_plugin_proxy.c", 59 "${dev_frameworks_path}/src/plugin_adapter/ext_part/ext_part_proxy.c", 60 ] 61 } 62 } 63 if (board_toolchain_type == "iccarm" && os_level == "mini") { 64 cflags = [ 65 "--diag_suppress", 66 "Pe546,Pe223,Pe111,Pe188", 67 ] 68 } else { 69 cflags = build_flags 70 } 71 cflags += [ 72 "-DDEV_AUTH_WORK_THREAD_STACK_SIZE=${device_auth_hichain_thread_stack_size}", 73 "-DMAX_AUTH_SESSION_COUNT=${max_auth_session_count}", 74 ] 75 if (ohos_kernel_type == "linux" || ohos_kernel_type == "liteos_a") { 76 include_dirs += 77 [ "//base/hiviewdfx/hilog_lite/interfaces/native/innerkits/hilog" ] 78 deps += [ 79 "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared", 80 "//third_party/bounds_checking_function:libsec_shared", 81 ] 82 } else { 83 include_dirs += 84 [ "//base/hiviewdfx/hilog_lite/interfaces/native/kits/hilog_lite" ] 85 deps += [ "//base/hiviewdfx/hilog_lite/frameworks/mini:hilog_lite" ] 86 } 87 } 88 89 if (os_level == "mini") { 90 group("deviceauth_sdk") { 91 } 92 group("deviceauth_service") { 93 } 94 } 95 96 if (ohos_kernel_type == "linux" || ohos_kernel_type == "liteos_a") { 97 executable("deviceauth_service") { 98 include_dirs += [ 99 "//third_party/cJSON", 100 "//commonlibrary/utils_lite/include", 101 "//base/hiviewdfx/hilog_lite/interfaces/native/innerkits/hilog", 102 "//third_party/bounds_checking_function/include", 103 "${frameworks_path}/inc/lite", 104 "//foundation/systemabilitymgr/samgr_lite/interfaces/kits/samgr", 105 "${dev_frameworks_path}/inc/hiview_adapter", 106 ] 107 108 sources = deviceauth_ipc_files 109 sources += [ 110 "${frameworks_path}/src/ipc_service.c", 111 "${frameworks_path}/src/lite/ipc_service_init.c", 112 ] 113 114 defines = [ "HILOG_ENABLE" ] 115 if (ohos_kernel_type == "linux") { 116 defines += [ "__LINUX__" ] 117 } 118 ldflags = [ "-pthread" ] 119 120 deps = [ 121 ":deviceauth", 122 "${deps_adapter_path}:${hal_module_name}", 123 "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared", 124 "//build/lite/config/component/cJSON:cjson_shared", 125 "//commonlibrary/utils_lite:utils", 126 "//foundation/communication/ipc/interfaces/innerkits/c/ipc:ipc_single", 127 "//foundation/systemabilitymgr/samgr_lite/samgr:samgr", 128 "//third_party/bounds_checking_function:libsec_shared", 129 ] 130 } 131 132 shared_library("deviceauth_sdk") { 133 public_configs = [ ":deviceauth_config" ] 134 include_dirs += [ 135 "//third_party/cJSON", 136 "//commonlibrary/utils_lite/include", 137 "//base/hiviewdfx/hilog_lite/interfaces/native/innerkits/hilog", 138 "//third_party/bounds_checking_function/include", 139 "${frameworks_path}/inc/lite", 140 "//foundation/communication/ipc/interfaces/innerkits/c/ipc/include", 141 "//foundation/systemabilitymgr/samgr_lite/interfaces/kits/samgr", 142 "${dev_frameworks_path}/inc/hiview_adapter", 143 ] 144 145 sources = deviceauth_ipc_files 146 sources += [ "${frameworks_path}/src/ipc_sdk.c" ] 147 148 defines = [ "HILOG_ENABLE" ] 149 if (ohos_kernel_type == "linux") { 150 defines += [ "__LINUX__" ] 151 } 152 cflags = build_flags 153 cflags += [ "-fPIC" ] 154 155 deps = [ 156 "${deps_adapter_path}:${hal_module_name}", 157 "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared", 158 "//commonlibrary/utils_lite:utils", 159 "//foundation/communication/ipc/interfaces/innerkits/c/ipc:ipc_single", 160 "//foundation/systemabilitymgr/samgr_lite/samgr:samgr", 161 "//third_party/bounds_checking_function:libsec_shared", 162 ] 163 } 164 } 165} else { 166 ohos_static_library("deviceauth") { 167 subsystem_name = "security" 168 part_name = "device_auth" 169 include_dirs += [ 170 "${frameworks_path}/inc/standard", 171 "${dev_frameworks_path}/inc/hiview_adapter", 172 ] 173 174 if (support_os_account) { 175 include_dirs += [ "${dev_frameworks_path}/inc/account_subscriber" ] 176 include_dirs += [ "${dev_frameworks_path}/inc/sa_subscriber" ] 177 } 178 179 sources = deviceauth_files 180 if (support_os_account) { 181 sources += account_subscriber_files 182 sources += sa_subscriber_files 183 } 184 sources += hiview_adapter_files 185 defines = deviceauth_defines 186 defines += [ "HILOG_ENABLE" ] 187 defines += [ "DEV_AUTH_HIVIEW_ENABLE" ] 188 cflags = build_flags 189 cflags += [ 190 "-DDEV_AUTH_WORK_THREAD_STACK_SIZE=${device_auth_hichain_thread_stack_size}", 191 "-DMAX_AUTH_SESSION_COUNT=${max_auth_session_count}", 192 ] 193 if (target_cpu == "arm") { 194 cflags += [ "-DBINDER_IPC_32BIT" ] 195 } 196 if (enable_extend_plugin) { 197 defines += [ "DEV_AUTH_PLUGIN_ENABLE" ] 198 sources += [ 199 "${dev_frameworks_path}/src/plugin_adapter/dynamic_plugin_adapter.c", 200 "${dev_frameworks_path}/src/plugin_adapter/ext_part/account_lifecycle_plugin_proxy.c", 201 "${dev_frameworks_path}/src/plugin_adapter/ext_part/ext_part_proxy.c", 202 ] 203 } 204 205 sources += identity_manager_files 206 include_dirs += identity_manager_inc 207 208 branch_protector_ret = "pac_ret" 209 sanitize = { 210 cfi = true 211 cfi_cross_dso = true 212 integer_overflow = true 213 boundary_sanitize = true 214 ubsan = true 215 debug = false 216 } 217 218 deps = [ "${deps_adapter_path}:${hal_module_name}" ] 219 220 external_deps = [ 221 "bounds_checking_function:libsec_shared", 222 "cJSON:cjson", 223 "c_utils:utils", 224 "dsoftbus:softbus_client", 225 "hilog:libhilog", 226 "hisysevent:libhisysevent", 227 "hitrace:hitrace_meter", 228 ] 229 if (support_os_account) { 230 external_deps += [ 231 "ability_base:want", 232 "common_event_service:cesfwk_innerkits", 233 "ipc:ipc_single", 234 "json:nlohmann_json_static", 235 "os_account:os_account_innerkits", 236 "samgr:samgr_proxy", 237 ] 238 } 239 } 240 241 ohos_prebuilt_etc("auth_service.rc") { 242 source = "${frameworks_path}/src/standard/deviceauth_service.cfg" 243 relative_install_dir = "init" 244 subsystem_name = "security" 245 part_name = "device_auth" 246 } 247 248 group("etc") { 249 deps = [ ":auth_service.rc" ] 250 } 251 252 ohos_executable("deviceauth_service") { 253 subsystem_name = "security" 254 part_name = "device_auth" 255 install_enable = true 256 257 include_dirs += [ 258 "${frameworks_path}/inc/standard", 259 "${dev_frameworks_path}/inc/permission_adapter", 260 "${dev_frameworks_path}/inc/hiview_adapter", 261 ] 262 263 sources = deviceauth_ipc_files 264 sources += permission_adapter_files 265 sources += [ "${frameworks_path}/src/ipc_service.c" ] 266 267 defines = [ "HILOG_ENABLE" ] 268 defines += [ "DEV_AUTH_HIVIEW_ENABLE" ] 269 defines += [ "DEV_AUTH_SERVICE_BUILD" ] 270 cflags = build_flags 271 if (target_cpu == "arm") { 272 cflags += [ "-DBINDER_IPC_32BIT" ] 273 } 274 275 branch_protector_ret = "pac_ret" 276 sanitize = { 277 cfi = true 278 cfi_cross_dso = true 279 integer_overflow = true 280 boundary_sanitize = true 281 ubsan = true 282 debug = false 283 } 284 285 deps = [ 286 ":auth_service.rc", 287 ":deviceauth", 288 "${deps_adapter_path}:${hal_module_name}", 289 ] 290 291 external_deps = [ 292 "access_token:libaccesstoken_sdk", 293 "bounds_checking_function:libsec_shared", 294 "cJSON:cjson", 295 "c_utils:utils", 296 "hilog:libhilog", 297 "init:libbegetutil", 298 "ipc:ipc_single", 299 "samgr:samgr_proxy", 300 ] 301 } 302 303 ohos_shared_library("deviceauth_sdk") { 304 subsystem_name = "security" 305 part_name = "device_auth" 306 innerapi_tags = [ "platformsdk" ] 307 version_script = "device_auth.map" 308 public_configs = [ ":deviceauth_config" ] 309 310 include_dirs += [ 311 "${frameworks_path}/inc/standard", 312 "${dev_frameworks_path}/inc/permission_adapter", 313 "${dev_frameworks_path}/inc/hiview_adapter", 314 ] 315 316 sources = deviceauth_ipc_files 317 sources += permission_adapter_files 318 sources += [ "${frameworks_path}/src/ipc_sdk.c" ] 319 320 defines = [ 321 "__LINUX__", 322 "HILOG_ENABLE", 323 ] 324 cflags = build_flags 325 cflags += [ "-fPIC" ] 326 if (target_cpu == "arm") { 327 cflags += [ "-DBINDER_IPC_32BIT" ] 328 } 329 330 branch_protector_ret = "pac_ret" 331 sanitize = { 332 cfi = true 333 cfi_cross_dso = true 334 integer_overflow = true 335 boundary_sanitize = true 336 ubsan = true 337 debug = false 338 } 339 340 deps = [ "${deps_adapter_path}:${hal_module_name}" ] 341 342 external_deps = [ 343 "access_token:libaccesstoken_sdk", 344 "bounds_checking_function:libsec_shared", 345 "cJSON:cjson", 346 "c_utils:utils", 347 "hilog:libhilog", 348 "hisysevent:libhisysevent", 349 "hitrace:hitrace_meter", 350 "init:libbegetutil", 351 "ipc:ipc_single", 352 "samgr:samgr_proxy", 353 ] 354 } 355} 356