# Copyright (c) 2022 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import("//build/lite/config/component/lite_component.gni") import("//test/xts/device_attest_lite/build/devattestconfig.gni") sources_common = [ "attest_entry.c", "adapter/attest_adapter.c", "adapter/attest_adapter_os.c", "adapter/attest_adapter_oem.c", "adapter/attest_adapter_mock.c", "attest/attest_service.c", "attest/attest_service_auth.c", "attest/attest_service_active.c", "attest/attest_service_challenge.c", "attest/attest_service_reset.c", "attest/attest_service_device.c", "network/attest_channel.c", "network/attest_coap.c", "network/attest_network.c", "network/attest_tls.c", "security/attest_security.c", "security/attest_security_token.c", "security/attest_security_ticket.c", "utils/attest_utils_file.c", "utils/attest_utils_json.c", "utils/attest_utils_log.c", "utils/attest_utils_timer.c", "utils/attest_utils_list.c", "utils/attest_utils.c", ] if (enable_attest_mock_network && enable_attest_mock_device) { sources_common += [ "${devattest_path}/test/unittest/src/attest_mock.c" ] } if (enable_attest_debug_memory_leak) { sources_common += [ "utils/attest_utils_memleak.c" ] } if (enable_attest_debug_dfx) { sources_common += [ "dfx/attest_dfx.c" ] } config("devattest_core_config") { visibility = [ ":*" ] include_dirs = [ "include", "include/adapter", "include/attest", "include/dfx", "include/security", "include/network", "include/utils", "${devattest_path}/services/oem_adapter/include", "//base/startup/init/interfaces/innerkits/include/syspara", "//base/hiviewdfx/hilog_lite/interfaces/native/kits", "//utils/native/lite/include", "//third_party/cJSON", "//third_party/bounds_checking_function/include", "${devattest_path}/interfaces/innerkits", ] include_dirs += [ "//base/startup/init/interfaces/hals", "//base/startup/init/interfaces/innerkits/include/syspara", "//developtools/syscap_codec/interfaces/inner_api", ] defines = [] if (enable_attest_log_debug) { defines += [ "ATTEST_HILOG_LEVEL = 0" ] } else { defines += [ "ATTEST_HILOG_LEVEL = 1" ] } if (enable_attest_mock_network) { defines += [ "__ATTEST_MOCK_NETWORK_STUB__" ] } if (enable_attest_mock_device) { defines += [ "__ATTEST_MOCK_DEVICE_STUB__" ] } if (enable_attest_debug_memory_leak) { defines += [ "__ATTEST_DEBUG_MEMORY_LEAK__" ] } if (enable_attest_debug_dfx) { defines += [ "__ATTEST_DEBUG_DFX__" ] } defines += [ "MBEDTLS_ALLOW_PRIVATE_ACCESS" ] } config("devattest_core_hi3861_config") { visibility = [ ":*" ] include_dirs = [ "//device/soc/hisilicon/hi3861v100/sdk_liteos/third_party/mbedtls/include", ] } copy("network_config") { sources = [ "network_config.json" ] outputs = [ "$root_out_dir/data/device_attest/network_config.json" ] } if (ohos_kernel_type == "liteos_m") { static_library("devattest_core") { sources = sources_common public_configs = [ ":devattest_core_config", ":devattest_core_hi3861_config", ] cflags = [ "-Wall", "-Wextra", "-Wshadow", "-fstack-protector-all", "-D_FORTIFY_SOURCE=2", "-Wformat=2", "-Wfloat-equal", "-Wdate-time", ] deps = [ "$ohos_product_adapter_dir/utils/token:hal_token_static", "//base/startup/init/interfaces/innerkits:parameter", ] deps += [ "//build/lite/config/component/cJSON:cjson_static", "//third_party/bounds_checking_function:libsec_static", "//third_party/mbedtls:mbedtls_static", ] } } else if (ohos_kernel_type == "liteos_a" || ohos_kernel_type == "linux") { shared_library("devattest_core") { sources = sources_common public_configs = [ ":devattest_core_config" ] cflags = [ "-ftrapv", "-Werror", "-Wextra", "-Wshadow", "-fstack-protector-all", "-Wformat=2", "-Wfloat-equal", "-Wdate-time", "-fPIE", ] deps = [ "$ohos_product_adapter_dir/utils/token:haltoken_shared", "//base/startup/init/interfaces/innerkits:parameter", ] deps += [ "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared", "//build/lite/config/component/cJSON:cjson_shared", "//third_party/mbedtls:mbedtls", ] deps += [ "//developtools/syscap_codec:syscap_interface_shared" ] deps += [ ":network_config" ] } }