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("//base/security/device_security_level/common/dslm.gni")
15import("//build/ohos.gni")
16
17config("utils_static_config") {
18  include_dirs = [ "include" ]
19}
20
21# utils static lib
22ohos_static_library("utils_static") {
23  sources = [
24    "src/utils_base64.c",
25    "src/utils_datetime.c",
26    "src/utils_hexstring.c",
27    "src/utils_json.c",
28    "src/utils_mem.c",
29    "src/utils_state_machine.c",
30    "src/utils_tlv.c",
31    "src/utils_work_queue.c",
32  ]
33
34  include_dirs = [ "include" ]
35
36  deps = []
37
38  configs = [ "../../common:common_configs" ]
39
40  public_configs = [
41    ":utils_static_config",
42    "../../common:common_lite_configs",
43  ]
44
45  if (defined(ohos_lite)) {
46    sources += [ "src/utils_timer.c" ]
47
48    include_dirs += [
49      "$dslm_common_lib_path/include",
50      "$dslm_common_lib_path/timer_task/include",
51    ]
52
53    if (ohos_kernel_type == "linux" || ohos_kernel_type == "liteos_a") {
54      deps += [
55        "$dslm_common_lib_path/timer_task:ace_kit_timer",
56        "$dslm_hilog_path/featured:hilog_shared",
57        "$dslm_lite_component_path/cJSON:cjson_shared",
58      ]
59    } else if (ohos_kernel_type == "liteos_m") {
60      deps += [
61        "$dslm_common_lib_path/timer_task:ace_kit_timer",
62        "$dslm_hilog_path/featured:hilog_static",
63        "$dslm_lite_component_path/cJSON:cjson_static",
64      ]
65    }
66  } else {
67    sanitize = {
68      integer_overflow = true
69      ubsan = true
70      boundary_sanitize = true
71      cfi = true
72      cfi_cross_dso = true
73      blocklist = "../../cfi_blocklist.txt"
74    }
75    branch_protector_ret = "pac_ret"
76
77    sources += [ "src/utils_timer.cpp" ]
78
79    deps += [ "//third_party/cJSON:cjson" ]
80
81    external_deps = [
82      "c_utils:utils",
83      "hilog:libhilog",
84    ]
85  }
86
87  part_name = "device_security_level"
88  subsystem_name = "security"
89}
90