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}
90
91config("hichain_standard_config") {
92  include_dirs = [
93    "//base/security/device_auth/interfaces/inner_api/deviceauth_lite",
94    "../inc/base",
95    "../inc/huks_adapter",
96    "../inc/json",
97    "../inc/key_agreement",
98    "../inc/log",
99    "../inc/os_account_adapter",
100    "../inc/schedule",
101    "../inc/struct",
102    "../inc/auth_info",
103  ]
104
105  defines = [
106    #    "_SCANTY_MEMORY_",
107    #    "_CUT_STS_CLIENT_",
108    "_CUT_REMOVE_",
109    #    "_CUT_ADD_",
110    #    "_CUT_LOG_",
111  ]
112  if (has_os_account_part) {
113    defines += [ "HAS_OS_ACCOUNT_PART" ]
114  }
115}
116
117if (os_level == "standard") {
118  ohos_shared_library("hichainsdk") {
119    subsystem_name = "security"
120    part_name = "device_auth"
121    sources = hichian_sources
122    public_configs = [ ":hichain_standard_config" ]
123    external_deps = [
124      "bounds_checking_function:libsec_shared",
125      "cJSON:cjson",
126      "huks:libhukssdk",
127    ]
128    if (has_os_account_part) {
129      external_deps += [ "os_account:os_account_innerkits" ]
130    }
131    cflags = [
132      "-flto",
133      "-Wall",
134      "-fvisibility=hidden",
135    ]
136  }
137  ohos_static_library("hichainsdk_static") {
138    subsystem_name = "security"
139    part_name = "device_auth"
140    sources = hichian_sources
141    public_configs = [ ":hichain_standard_config" ]
142    external_deps = [
143      "bounds_checking_function:libsec_shared",
144      "cJSON:cjson",
145      "huks:libhukssdk",
146    ]
147    if (has_os_account_part) {
148      external_deps += [ "os_account:os_account_innerkits" ]
149    }
150    cflags = [
151      "-flto",
152      "-Wall",
153      "-fvisibility=hidden",
154      "--coverage",
155    ]
156    ldflags = [ "--coverage" ]
157  }
158} else {
159  if (ohos_kernel_type == "liteos_m") {
160    static_library("hichainsdk") {
161      sources = hichian_sources
162      public_configs = [ ":hichain_config" ]
163      deps =
164          [ "//base/security/huks/interfaces/inner_api/huks_lite:huks_3.0_sdk" ]
165      if (board_toolchain_type == "iccarm") {
166        cflags = [
167          "--diag_suppress",
168          "Pe1097,Pe546,Pe188,Pe111",
169        ]
170      }
171    }
172  } else {
173    shared_library("hichainsdk") {
174      sources = hichian_sources
175      public_configs = [ ":hichain_config" ]
176      deps = [
177        "//base/security/huks/interfaces/inner_api/huks_lite:huks_3.0_sdk",
178        "//build/lite/config/component/cJSON:cjson_shared",
179        "//third_party/bounds_checking_function:libsec_shared",
180      ]
181      cflags = [
182        "-flto",
183        "-Wall",
184        "-fvisibility=hidden",
185      ]
186    }
187  }
188}
189