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 = [ "./" ]
20}
21
22if (os_level == "standard") {
23  ohos_static_library("libhuks_utils_file_operator_static") {
24    subsystem_name = "security"
25    part_name = "huks"
26    public_configs = [ ":huks_config" ]
27    include_dirs = [
28      "//base/security/huks/frameworks/huks_standard/main/common/include",
29      "//base/security/huks/interfaces/inner_api/huks_standard/main/include",
30    ]
31
32    sources = []
33
34    deps = [ "//base/security/huks/frameworks/huks_standard/main/os_dependency:libhuks_mem_standard_static" ]
35
36    complete_static_lib = true
37
38    branch_protector_ret = "pac_ret"
39
40    sanitize = {
41      integer_overflow = true
42      cfi = true
43      debug = false
44      cfi_cross_dso = true
45      boundary_sanitize = true
46      ubsan = true
47    }
48    sources += [ "hks_file_operator.c" ]
49
50    configs = [
51      "//base/security/huks/frameworks/config/build:l2_standard_common_config",
52    ]
53
54    external_deps = [
55      "c_utils:utils",
56      "hilog:libhilog",
57    ]
58  }
59} else {
60  ohos_static_library("libhuks_utils_file_operator_static") {
61    public_configs = [ ":huks_config" ]
62    configs = [
63      "//base/security/huks/frameworks/config/build:l1_small_common_config",
64    ]
65
66    include_dirs = [
67      "//base/security/huks/frameworks/huks_standard/main/common/include",
68      "//base/security/huks/interfaces/inner_api/huks_standard/main/include",
69    ]
70
71    sources = []
72    cflags = []
73
74    if (huks_use_lite_storage == true) {
75      cflags += [ "-D_STORAGE_LITE_" ]
76    } else {
77      if (ohos_kernel_type == "liteos_a") {
78        cflags += [ "-D_BSD_SOURCE" ]
79      } else {
80        cflags += [ "-D_DEFAULT_SOURCE" ]
81      }
82    }
83
84    deps = [ "//base/security/huks/frameworks/huks_standard/main/os_dependency:libhuks_os_dependency_small_static" ]
85
86    complete_static_lib = true
87
88    external_deps = [ "hilog_lite:hilog_shared" ]
89    sources += [ "hks_file_operator_lite.c" ]
90  }
91}
92