1# Copyright (C) 2022-2023 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("//base/security/huks/build/config.gni")
15import("//base/security/huks/huks.gni")
16import("//build/ohos.gni")
17
18config("huks_config") {
19  include_dirs = [ "include" ]
20}
21
22if (os_level == "standard") {
23  ohos_static_library("libhuks_utils_client_service_adapter_static") {
24    branch_protector_ret = "pac_ret"
25
26    sanitize = {
27      integer_overflow = true
28      cfi = true
29      debug = false
30      cfi_cross_dso = true
31      boundary_sanitize = true
32      ubsan = true
33    }
34    subsystem_name = "security"
35    part_name = "huks"
36    public_configs = [ ":huks_config" ]
37    include_dirs =
38        [ "../../frameworks/huks_standard/main/crypto_engine/openssl/include" ]
39    defines = [
40      "_HARDWARE_ROOT_KEY_",
41      "_HUKS_LOG_ENABLE_",
42      "OPENSSL_SUPPRESS_DEPRECATED",
43    ]
44    sources = [
45      "hks_client_service_adapter.c",
46      "hks_client_service_adapter_common.c",
47    ]
48    configs = [
49      "//base/security/huks/frameworks/config/build:l2_standard_common_config",
50    ]
51    cflags = [
52      "-Wall",
53      "-Werror",
54    ]
55    deps = [
56      "//base/security/huks/frameworks/huks_standard/main/common:libhuks_common_standard_static",
57      "//base/security/huks/frameworks/huks_standard/main/os_dependency:libhuks_mem_standard_static",
58    ]
59    external_deps = [
60      "c_utils:utils",
61      "hilog:libhilog",
62      "openssl:libcrypto_shared",
63    ]
64    complete_static_lib = true
65  }
66} else {
67  ohos_static_library("libhuks_utils_client_service_adapter_static") {
68    public_configs = [ ":huks_config" ]
69    defines = [ "OPENSSL_SUPPRESS_DEPRECATED" ]
70    include_dirs =
71        [ "../../frameworks/huks_standard/main/crypto_engine/include/" ]
72    configs = [
73      "//base/security/huks/frameworks/config/build:l1_small_common_config",
74    ]
75
76    sources = [
77      "hks_client_service_adapter_common.c",
78      "hks_client_service_adapter_lite.c",
79    ]
80
81    deps = [
82      "//base/security/huks/frameworks/huks_standard/main/common:libhuks_common_small_static",
83      "//base/security/huks/frameworks/huks_standard/main/crypto_engine:libhuks_crypto_engine_small_static",
84      "//base/security/huks/frameworks/huks_standard/main/os_dependency:libhuks_os_dependency_small_static",
85    ]
86
87    external_deps = [ "hilog_lite:hilog_shared" ]
88    if (huks_dependency_mbedtls_path != "") {
89      deps += [ huks_dependency_mbedtls_path ]
90    } else {
91      deps += [ "//third_party/mbedtls" ]
92    }
93    if (huks_dependency_openssl_path != "") {
94      deps += [ huks_dependency_openssl_path ]
95    } else {
96      deps += [ "//third_party/openssl/ohos_lite:openssl_shared" ]
97    }
98    complete_static_lib = true
99  }
100}
101