1# Copyright (c) 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("//build/lite/config/component/lite_component.gni") 15import("//test/xts/device_attest_lite/build/devattestconfig.gni") 16 17sources_common = [ 18 "attest_entry.c", 19 "adapter/attest_adapter.c", 20 "adapter/attest_adapter_os.c", 21 "adapter/attest_adapter_oem.c", 22 "adapter/attest_adapter_mock.c", 23 "attest/attest_service.c", 24 "attest/attest_service_auth.c", 25 "attest/attest_service_active.c", 26 "attest/attest_service_challenge.c", 27 "attest/attest_service_reset.c", 28 "attest/attest_service_device.c", 29 "network/attest_channel.c", 30 "network/attest_coap.c", 31 "network/attest_network.c", 32 "network/attest_tls.c", 33 "security/attest_security.c", 34 "security/attest_security_token.c", 35 "security/attest_security_ticket.c", 36 "utils/attest_utils_file.c", 37 "utils/attest_utils_json.c", 38 "utils/attest_utils_log.c", 39 "utils/attest_utils_timer.c", 40 "utils/attest_utils_list.c", 41 "utils/attest_utils.c", 42] 43 44if (enable_attest_mock_network && enable_attest_mock_device) { 45 sources_common += [ "${devattest_path}/test/unittest/src/attest_mock.c" ] 46} 47 48if (enable_attest_debug_memory_leak) { 49 sources_common += [ "utils/attest_utils_memleak.c" ] 50} 51 52if (enable_attest_debug_dfx) { 53 sources_common += [ "dfx/attest_dfx.c" ] 54} 55 56config("devattest_core_config") { 57 visibility = [ ":*" ] 58 59 include_dirs = [ 60 "include", 61 "include/adapter", 62 "include/attest", 63 "include/dfx", 64 "include/security", 65 "include/network", 66 "include/utils", 67 "${devattest_path}/services/oem_adapter/include", 68 "//base/startup/init/interfaces/innerkits/include/syspara", 69 "//base/hiviewdfx/hilog_lite/interfaces/native/kits", 70 "//utils/native/lite/include", 71 "//third_party/cJSON", 72 "//third_party/bounds_checking_function/include", 73 "${devattest_path}/interfaces/innerkits", 74 ] 75 76 include_dirs += [ 77 "//base/startup/init/interfaces/hals", 78 "//base/startup/init/interfaces/innerkits/include/syspara", 79 "//developtools/syscap_codec/interfaces/inner_api", 80 ] 81 82 defines = [] 83 if (enable_attest_log_debug) { 84 defines += [ "ATTEST_HILOG_LEVEL = 0" ] 85 } else { 86 defines += [ "ATTEST_HILOG_LEVEL = 1" ] 87 } 88 89 if (enable_attest_mock_network) { 90 defines += [ "__ATTEST_MOCK_NETWORK_STUB__" ] 91 } 92 93 if (enable_attest_mock_device) { 94 defines += [ "__ATTEST_MOCK_DEVICE_STUB__" ] 95 } 96 97 if (enable_attest_debug_memory_leak) { 98 defines += [ "__ATTEST_DEBUG_MEMORY_LEAK__" ] 99 } 100 101 if (enable_attest_debug_dfx) { 102 defines += [ "__ATTEST_DEBUG_DFX__" ] 103 } 104 defines += [ "MBEDTLS_ALLOW_PRIVATE_ACCESS" ] 105} 106 107config("devattest_core_hi3861_config") { 108 visibility = [ ":*" ] 109 110 include_dirs = [ 111 "//device/soc/hisilicon/hi3861v100/sdk_liteos/third_party/mbedtls/include", 112 ] 113} 114 115copy("network_config") { 116 sources = [ "network_config.json" ] 117 outputs = [ "$root_out_dir/data/device_attest/network_config.json" ] 118} 119 120if (ohos_kernel_type == "liteos_m") { 121 static_library("devattest_core") { 122 sources = sources_common 123 124 public_configs = [ 125 ":devattest_core_config", 126 ":devattest_core_hi3861_config", 127 ] 128 129 cflags = [ 130 "-Wall", 131 "-Wextra", 132 "-Wshadow", 133 "-fstack-protector-all", 134 "-D_FORTIFY_SOURCE=2", 135 "-Wformat=2", 136 "-Wfloat-equal", 137 "-Wdate-time", 138 ] 139 140 deps = [ 141 "$ohos_product_adapter_dir/utils/token:hal_token_static", 142 "//base/startup/init/interfaces/innerkits:parameter", 143 ] 144 deps += [ 145 "//build/lite/config/component/cJSON:cjson_static", 146 "//third_party/bounds_checking_function:libsec_static", 147 "//third_party/mbedtls:mbedtls_static", 148 ] 149 } 150} else if (ohos_kernel_type == "liteos_a" || ohos_kernel_type == "linux") { 151 shared_library("devattest_core") { 152 sources = sources_common 153 154 public_configs = [ ":devattest_core_config" ] 155 cflags = [ 156 "-ftrapv", 157 "-Werror", 158 "-Wextra", 159 "-Wshadow", 160 "-fstack-protector-all", 161 "-Wformat=2", 162 "-Wfloat-equal", 163 "-Wdate-time", 164 "-fPIE", 165 ] 166 167 deps = [ 168 "$ohos_product_adapter_dir/utils/token:haltoken_shared", 169 "//base/startup/init/interfaces/innerkits:parameter", 170 ] 171 deps += [ 172 "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared", 173 "//build/lite/config/component/cJSON:cjson_shared", 174 "//third_party/mbedtls:mbedtls", 175 ] 176 deps += [ "//developtools/syscap_codec:syscap_interface_shared" ] 177 deps += [ ":network_config" ] 178 } 179} 180