1# Copyright (c) 2022-2024 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/ohos.gni")
15import("//foundation/communication/netstack/netstack_config.gni")
16
17config("napi_utils_public_config") {
18  include_dirs = [
19    "include",
20    "$THIRD_PARTY_ROOT/node/src",
21    "$NETSTACK_DIR/utils/log/include",
22  ]
23  if (current_os != "ohos") {
24    cflags = [ "-std=c++17" ]
25  }
26}
27
28ohos_static_library("napi_utils") {
29  sanitize = {
30    cfi = true
31    cfi_cross_dso = true
32    debug = false
33  }
34
35  branch_protector_ret = "pac_ret"
36
37  sources = [
38    "src/base_context.cpp",
39    "src/event_listener.cpp",
40    "src/event_manager.cpp",
41    "src/module_template.cpp",
42    "src/napi_utils.cpp",
43    "src/secure_char.cpp",
44    "src/timing.cpp",
45  ]
46
47  part_name = "netstack"
48  subsystem_name = "communication"
49  public_configs = [ ":napi_utils_public_config" ]
50
51  public_deps = [ "$NETSTACK_DIR/utils:stack_utils_common" ]
52  external_deps = [
53    "cJSON:cjson",
54    "c_utils:utils",
55    "hilog:libhilog",
56    "napi:ace_napi",
57  ]
58
59  if (defined(global_parts_info) &&
60      defined(global_parts_info.communication_netmanager_base) &&
61      global_parts_info.communication_netmanager_base && is_ohos &&
62      is_standard_system && !is_arkui_x && product_name != "ohos-sdk") {
63    defines = [ "HAS_NETMANAGER_BASE=1" ]
64    external_deps += [ "ffrt:libffrt" ]
65  } else {
66    defines = [ "HAS_NETMANAGER_BASE=0" ]
67  }
68}
69
70ohos_static_library("napi_utils_static") {
71  sanitize = {
72    cfi = true
73    cfi_cross_dso = true
74    debug = false
75  }
76
77  branch_protector_ret = "pac_ret"
78
79  sources = [
80    "src/base_context.cpp",
81    "src/event_listener.cpp",
82    "src/event_manager.cpp",
83    "src/module_template.cpp",
84    "src/napi_utils.cpp",
85    "src/secure_char.cpp",
86    "src/timing.cpp",
87  ]
88
89  public_configs = [ ":napi_utils_public_config" ]
90
91  external_deps = [ "cJSON:cjson" ]
92
93  if (defined(global_parts_info) &&
94      defined(global_parts_info.communication_netmanager_base) &&
95      global_parts_info.communication_netmanager_base && is_ohos &&
96      is_standard_system && !is_arkui_x && product_name != "ohos-sdk") {
97    defines = [ "HAS_NETMANAGER_BASE=1" ]
98    external_deps += [ "ffrt:libffrt" ]
99  } else {
100    defines = [ "HAS_NETMANAGER_BASE=0" ]
101  }
102
103  if (current_os == "ohos") {
104    public_deps = [ "$NETSTACK_DIR/utils:stack_utils_common" ]
105    external_deps += [
106      "c_utils:utils",
107      "hilog:libhilog",
108      "napi:ace_napi",
109    ]
110  } else {
111    public_deps = [
112      "$ARKUI_ROOT/napi:ace_napi",
113      "$THIRD_PARTY_ROOT/bounds_checking_function:libsec_static",
114    ]
115  }
116}
117