• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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")
16import("attestsource.gni")
17
18if (enable_attest_mock_network && enable_attest_mock_device) {
19  sources_common += [ "${devattest_path}/test/unittest/src/attest_mock.c" ]
20}
21
22if (enable_attest_debug_memory_leak) {
23  sources_common += [ "utils/attest_utils_memleak.c" ]
24}
25
26if (enable_attest_debug_dfx) {
27  sources_common += [ "dfx/attest_dfx.c" ]
28}
29
30config("devattest_core_config") {
31  visibility = [ ":*" ]
32
33  include_dirs = include_core_dirs
34
35  defines = []
36  if (enable_attest_log_debug) {
37    defines += [ "__ATTEST_HILOG_LEVEL_DEBUG__" ]
38  }
39
40  if (enable_attest_mock_network) {
41    defines += [ "__ATTEST_MOCK_NETWORK_STUB__" ]
42  }
43
44  if (enable_attest_mock_device) {
45    defines += [ "__ATTEST_MOCK_DEVICE_STUB__" ]
46  }
47
48  if (enable_attest_debug_memory_leak) {
49    defines += [ "__ATTEST_DEBUG_MEMORY_LEAK__" ]
50  }
51
52  if (enable_attest_debug_dfx) {
53    defines += [ "__ATTEST_DEBUG_DFX__" ]
54  }
55  defines += [ "MBEDTLS_ALLOW_PRIVATE_ACCESS" ]
56}
57
58config("devattest_core_mini_config") {
59  visibility = [ ":*" ]
60
61  include_dirs = [ "${devattest_path}/common/mini" ]
62}
63
64config("devattest_core_small_config") {
65  visibility = [ ":*" ]
66
67  include_dirs = [ "${devattest_path}/common/small" ]
68}
69
70config("devattest_core_hi3861_config") {
71  visibility = [ ":*" ]
72
73  include_dirs = [
74    "//device/soc/hisilicon/hi3861v100/sdk_liteos/third_party/mbedtls/include",
75  ]
76}
77
78copy("network_config") {
79  sources = [ "network_config.json" ]
80  outputs = [ "$root_out_dir/data/device_attest/network_config.json" ]
81}
82
83if (ohos_kernel_type == "liteos_m") {
84  static_library("devattest_core") {
85    sources = sources_common
86    sources += sources_mock
87    sources += [
88      "mini/adapter/attest_adapter_network_config.c",
89      "mini/attest/attest_service_pcid.c",
90      "mini/utils/attest_utils_file_detail.c",
91    ]
92
93    public_configs = [
94      ":devattest_core_config",
95      ":devattest_core_mini_config",
96      ":devattest_core_hi3861_config",
97    ]
98
99    deps = [
100      "$ohos_product_adapter_dir/utils/token:hal_token_static",
101      "//base/startup/init/interfaces/innerkits:parameter",
102    ]
103    deps += [
104      "//build/lite/config/component/cJSON:cjson_static",
105      "//third_party/bounds_checking_function:libsec_static",
106      "//third_party/mbedtls:mbedtls_static",
107    ]
108  }
109} else if (ohos_kernel_type == "liteos_a" || ohos_kernel_type == "linux") {
110  shared_library("devattest_core") {
111    sources = sources_common
112    sources += sources_mock
113    sources += [
114      "small/adapter/attest_adapter_network_config.c",
115      "small/attest/attest_service_pcid.c",
116      "small/utils/attest_utils_file_detail.c",
117    ]
118
119    public_configs = [
120      ":devattest_core_config",
121      ":devattest_core_mini_config",
122    ]
123    cflags = [
124      "-ftrapv",
125      "-Wextra",
126      "-Wshadow",
127      "-Wformat=2",
128      "-Wfloat-equal",
129      "-Wdate-time",
130      "-fPIE",
131    ]
132
133    deps = [
134      "$ohos_product_adapter_dir/utils/token:haltoken_shared",
135      "//base/startup/init/interfaces/innerkits:parameter",
136    ]
137    deps += [
138      "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared",
139      "//build/lite/config/component/cJSON:cjson_shared",
140      "//third_party/mbedtls:mbedtls",
141    ]
142    deps += [ "//developtools/syscap_codec:syscap_interface_shared" ]
143    deps += [ ":network_config" ]
144  }
145}
146