1# Copyright (C) 2021-2022 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/innerkits" ] 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 sources += hiview_adapter_mock_files 36 deps = [ 37 "${deps_adapter_path}:${hal_module_name}", 38 "//build/lite/config/component/cJSON:cjson_shared", 39 "//commonlibrary/utils_lite:utils", 40 ] 41 if (enable_soft_bus_channel) { 42 deps += [ "//foundation/communication/dsoftbus/sdk:softbus_client" ] 43 } 44 defines = [ "HILOG_ENABLE" ] 45 defines += deviceauth_defines 46 defines += [ "DISABLE_HIVIEW" ] 47 if (board_toolchain_type == "iccarm" && os_level == "mini") { 48 cflags = [ 49 "--diag_suppress", 50 "Pe546,Pe223,Pe111,Pe188", 51 ] 52 } else { 53 cflags = build_flags 54 } 55 cflags += [ 56 "-DHICHAIN_THREAD_STACK_SIZE=${deviceauth_hichain_thread_stack_size}", 57 ] 58 if (ohos_kernel_type == "linux" || ohos_kernel_type == "liteos_a") { 59 include_dirs += 60 [ "//base/hiviewdfx/hilog_lite/interfaces/native/innerkits/hilog" ] 61 deps += [ 62 "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared", 63 "//third_party/bounds_checking_function:libsec_shared", 64 ] 65 } else { 66 include_dirs += 67 [ "//base/hiviewdfx/hilog_lite/interfaces/native/kits/hilog_lite" ] 68 deps += [ "//base/hiviewdfx/hilog_lite/frameworks/mini:hilog_lite" ] 69 } 70 } 71 72 if (os_level == "mini") { 73 group("deviceauth_sdk") { 74 } 75 group("deviceauth_service") { 76 } 77 } 78 79 if (ohos_kernel_type == "linux" || ohos_kernel_type == "liteos_a") { 80 executable("deviceauth_service") { 81 include_dirs += [ 82 "//third_party/cJSON", 83 "//commonlibrary/utils_lite/include", 84 "//base/hiviewdfx/hilog_lite/interfaces/native/innerkits/hilog", 85 "//third_party/bounds_checking_function/include", 86 "${frameworks_path}/inc/lite", 87 "//foundation/systemabilitymgr/samgr_lite/interfaces/kits/samgr", 88 "${dev_frameworks_path}/inc/hiview_adapter", 89 ] 90 91 sources = deviceauth_ipc_files 92 sources += hiview_adapter_mock_files 93 sources += [ 94 "${frameworks_path}/src/ipc_service.c", 95 "${frameworks_path}/src/lite/ipc_service_init.c", 96 ] 97 98 defines = [ "HILOG_ENABLE" ] 99 if (ohos_kernel_type == "linux") { 100 defines += [ "__LINUX__" ] 101 } 102 ldflags = [ "-pthread" ] 103 104 deps = [ 105 ":deviceauth", 106 "${deps_adapter_path}:${hal_module_name}", 107 "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared", 108 "//build/lite/config/component/cJSON:cjson_shared", 109 "//commonlibrary/utils_lite:utils", 110 "//foundation/communication/ipc/interfaces/innerkits/c/ipc:ipc_single", 111 "//foundation/systemabilitymgr/samgr_lite/samgr:samgr", 112 "//third_party/bounds_checking_function:libsec_shared", 113 ] 114 } 115 116 shared_library("deviceauth_sdk") { 117 public_configs = [ ":deviceauth_config" ] 118 include_dirs += [ 119 "//third_party/cJSON", 120 "//commonlibrary/utils_lite/include", 121 "//base/hiviewdfx/hilog_lite/interfaces/native/innerkits/hilog", 122 "//third_party/bounds_checking_function/include", 123 "${frameworks_path}/inc/lite", 124 "//foundation/communication/ipc/interfaces/innerkits/c/ipc/include", 125 "//foundation/systemabilitymgr/samgr_lite/interfaces/kits/samgr", 126 "${dev_frameworks_path}/inc/hiview_adapter", 127 ] 128 129 sources = deviceauth_ipc_files 130 sources += [ "${frameworks_path}/src/ipc_sdk.c" ] 131 132 defines = [ "HILOG_ENABLE" ] 133 if (ohos_kernel_type == "linux") { 134 defines += [ "__LINUX__" ] 135 } 136 cflags = build_flags 137 cflags += [ "-fPIC" ] 138 139 deps = [ 140 "${deps_adapter_path}:${hal_module_name}", 141 "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared", 142 "//commonlibrary/utils_lite:utils", 143 "//foundation/communication/ipc/interfaces/innerkits/c/ipc:ipc_single", 144 "//foundation/systemabilitymgr/samgr_lite/samgr:samgr", 145 "//third_party/bounds_checking_function:libsec_shared", 146 ] 147 } 148 } 149} else { 150 ohos_static_library("deviceauth") { 151 subsystem_name = "security" 152 part_name = "device_auth" 153 include_dirs += [ 154 "//third_party/cJSON", 155 "${frameworks_path}/inc/standard", 156 "${dev_frameworks_path}/inc/hiview_adapter", 157 ] 158 159 sources = deviceauth_files 160 sources += hiview_adapter_files 161 cflags = [ "-DHILOG_ENABLE" ] 162 defines = deviceauth_defines 163 cflags += build_flags 164 if (target_cpu == "arm") { 165 cflags += [ "-DBINDER_IPC_32BIT" ] 166 } 167 if (support_jsapi) { 168 defines += [ "SUPPORT_OS_ACCOUNT" ] 169 } 170 171 deps = [ 172 "${deps_adapter_path}:${hal_module_name}", 173 "//third_party/cJSON:cjson", 174 ] 175 176 external_deps = [ 177 "c_utils:utils", 178 "dsoftbus:softbus_client", 179 "hisysevent_native:libhisysevent", 180 "hitrace_native:hitrace_meter", 181 "hiviewdfx_hilog_native:libhilog", 182 ] 183 if (support_jsapi) { 184 external_deps += [ "os_account:os_account_innerkits" ] 185 } 186 } 187 188 ohos_prebuilt_etc("auth_service.rc") { 189 source = "${frameworks_path}/src/standard/deviceauth_service.cfg" 190 relative_install_dir = "init" 191 subsystem_name = "security" 192 part_name = "device_auth" 193 } 194 195 group("etc") { 196 deps = [ ":auth_service.rc" ] 197 } 198 199 ohos_executable("deviceauth_service") { 200 subsystem_name = "security" 201 part_name = "device_auth" 202 install_enable = true 203 204 include_dirs += [ 205 "//third_party/cJSON", 206 "${frameworks_path}/inc/standard", 207 "${dev_frameworks_path}/inc/permission_adapter", 208 "${dev_frameworks_path}/inc/hiview_adapter", 209 ] 210 211 sources = deviceauth_ipc_files 212 sources += permission_adapter_files 213 sources += [ "${frameworks_path}/src/ipc_service.c" ] 214 215 cflags = [ "-DHILOG_ENABLE" ] 216 if (target_cpu == "arm") { 217 cflags += [ "-DBINDER_IPC_32BIT" ] 218 } 219 220 deps = [ 221 ":auth_service.rc", 222 ":deviceauth", 223 "${deps_adapter_path}:${hal_module_name}", 224 "//third_party/cJSON:cjson", 225 ] 226 227 external_deps = [ 228 "access_token:libaccesstoken_sdk", 229 "c_utils:utils", 230 "hisysevent_native:libhisysevent", 231 "hitrace_native:hitrace_meter", 232 "hiviewdfx_hilog_native:libhilog", 233 "init:libbegetutil", 234 "ipc:ipc_core", 235 "samgr:samgr_proxy", 236 ] 237 } 238 239 ohos_shared_library("deviceauth_sdk") { 240 subsystem_name = "security" 241 part_name = "device_auth" 242 public_configs = [ ":deviceauth_config" ] 243 244 include_dirs += [ 245 "//third_party/cJSON", 246 "${frameworks_path}/inc/standard", 247 "${dev_frameworks_path}/inc/permission_adapter", 248 "${dev_frameworks_path}/inc/hiview_adapter", 249 ] 250 251 sources = deviceauth_ipc_files 252 sources += permission_adapter_files 253 sources += hiview_adapter_files 254 sources += [ "${frameworks_path}/src/ipc_sdk.c" ] 255 256 defines = [ 257 "__LINUX__", 258 "HILOG_ENABLE", 259 ] 260 cflags = [ "-fPIC" ] 261 cflags += build_flags 262 if (target_cpu == "arm") { 263 cflags += [ "-DBINDER_IPC_32BIT" ] 264 } 265 266 deps = [ 267 "${deps_adapter_path}:${hal_module_name}", 268 "//third_party/cJSON:cjson", 269 ] 270 271 external_deps = [ 272 "access_token:libaccesstoken_sdk", 273 "c_utils:utils", 274 "hisysevent_native:libhisysevent", 275 "hitrace_native:hitrace_meter", 276 "hiviewdfx_hilog_native:libhilog", 277 "init:libbegetutil", 278 "ipc:ipc_core", 279 "samgr:samgr_proxy", 280 ] 281 } 282} 283