1# 2# Copyright (c) 2020-2021 Huawei Device Co., Ltd. 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14# 15import("//build/ohos.gni") 16 17if (!defined(global_parts_info) || 18 defined(global_parts_info.account_os_account)) { 19 has_os_account_part = true 20} else { 21 has_os_account_part = false 22} 23 24hichian_sources = [ 25 "auth_info/auth_info.c", 26 "auth_info/exchange_auth_info_client.c", 27 "auth_info/remove_auth_info_client.c", 28 "hichain.c", 29 "huks_adapter/huks_adapter.c", 30 "json/commonutil.c", 31 "json/jsonutil.c", 32 "key_agreement/key_agreement.c", 33 "key_agreement/key_agreement_client.c", 34 "key_agreement/key_agreement_server.c", 35 "key_agreement/pake_client.c", 36 "key_agreement/pake_server.c", 37 "key_agreement/sec_clone_server.c", 38 "key_agreement/sts_client.c", 39 "key_agreement/sts_server.c", 40 "log/log.c", 41 "os_account_adapter/os_account_adapter.cpp", 42 "schedule/build_object.c", 43 "schedule/distribution.c", 44 "struct/add_auth_info_data.c", 45 "struct/auth_ack_request.c", 46 "struct/auth_ack_response.c", 47 "struct/auth_start_request.c", 48 "struct/auth_start_response.c", 49 "struct/exchange_auth_data.c", 50 "struct/exchange_request.c", 51 "struct/exchange_response.c", 52 "struct/inform_message.c", 53 "struct/key_agreement_version.c", 54 "struct/key_agreement_version.h", 55 "struct/pake_client_confirm.c", 56 "struct/pake_request.c", 57 "struct/pake_response.c", 58 "struct/pake_server_confirm.c", 59 "struct/parsedata.c", 60 "struct/rmv_auth_info_data.c", 61 "struct/rmv_auth_info_request.c", 62 "struct/rmv_auth_info_response.c", 63 "struct/sec_clone_data.c", 64] 65 66config("hichain_config") { 67 include_dirs = [ 68 "//third_party/bounds_checking_function/include", 69 "//base/security/device_auth/interfaces/inner_api/deviceauth_lite", 70 "//third_party/cJSON", 71 "../inc/base", 72 "../inc/huks_adapter", 73 "../inc/json", 74 "../inc/key_agreement", 75 "../inc/log", 76 "../inc/os_account_adapter", 77 "../inc/schedule", 78 "../inc/struct", 79 "../inc/auth_info", 80 ] 81 82 defines = [ 83 "_SCANTY_MEMORY_", 84 "_CUT_STS_CLIENT_", 85 "_CUT_REMOVE_", 86 "_CUT_ADD_", 87 "_CUT_LOG_", 88 ] 89 if (has_os_account_part) { 90 defines += [ "HAS_OS_ACCOUNT_PART" ] 91 } 92} 93 94config("hichain_standard_config") { 95 include_dirs = [ 96 "//base/security/device_auth/interfaces/inner_api/deviceauth_lite", 97 "../inc/base", 98 "../inc/huks_adapter", 99 "../inc/json", 100 "../inc/key_agreement", 101 "../inc/log", 102 "../inc/os_account_adapter", 103 "../inc/schedule", 104 "../inc/struct", 105 "../inc/auth_info", 106 ] 107 108 defines = [ 109 # "_SCANTY_MEMORY_", 110 # "_CUT_STS_CLIENT_", 111 "_CUT_REMOVE_", 112 # "_CUT_ADD_", 113 # "_CUT_LOG_", 114 ] 115 if (has_os_account_part) { 116 defines += [ "HAS_OS_ACCOUNT_PART" ] 117 } 118} 119 120if (os_level == "small" || os_level == "mini") { 121 if (ohos_kernel_type == "liteos_m") { 122 static_library("hichainsdk") { 123 sources = hichian_sources 124 public_configs = [ ":hichain_config" ] 125 deps = 126 [ "//base/security/huks/interfaces/inner_api/huks_lite:huks_3.0_sdk" ] 127 if (board_toolchain_type == "iccarm") { 128 cflags = [ 129 "--diag_suppress", 130 "Pe1097,Pe546,Pe188,Pe111", 131 ] 132 } 133 } 134 } else { 135 shared_library("hichainsdk") { 136 sources = hichian_sources 137 public_configs = [ ":hichain_config" ] 138 deps = [ 139 "//base/security/huks/interfaces/inner_api/huks_lite:huks_3.0_sdk", 140 "//build/lite/config/component/cJSON:cjson_shared", 141 "//third_party/bounds_checking_function:libsec_shared", 142 ] 143 cflags = [ 144 "-flto", 145 "-Wall", 146 "-fvisibility=hidden", 147 ] 148 } 149 } 150} else { 151 ohos_shared_library("hichainsdk") { 152 subsystem_name = "security" 153 part_name = "device_auth" 154 sources = hichian_sources 155 public_configs = [ ":hichain_standard_config" ] 156 external_deps = [ 157 "bounds_checking_function:libsec_shared", 158 "cJSON:cjson", 159 "c_utils:utils", 160 "huks:libhukssdk", 161 "ipc:ipc_core", 162 ] 163 if (has_os_account_part) { 164 external_deps += [ "os_account:os_account_innerkits" ] 165 } 166 cflags = [ 167 "-flto", 168 "-Wall", 169 "-fvisibility=hidden", 170 ] 171 } 172 ohos_static_library("hichainsdk_static") { 173 subsystem_name = "security" 174 part_name = "device_auth" 175 sources = hichian_sources 176 public_configs = [ ":hichain_standard_config" ] 177 external_deps = [ 178 "bounds_checking_function:libsec_shared", 179 "cJSON:cjson", 180 "c_utils:utils", 181 "huks:libhukssdk", 182 "ipc:ipc_core", 183 ] 184 if (has_os_account_part) { 185 external_deps += [ "os_account:os_account_innerkits" ] 186 } 187 cflags = [ 188 "-flto", 189 "-Wall", 190 "-fvisibility=hidden", 191 "--coverage", 192 ] 193 ldflags = [ "--coverage" ] 194 } 195} 196