1# Copyright (c) 2023-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("networksecurity_napi_config") { 18 include_dirs = [ 19 "async_context/include", 20 "async_work/include", 21 "net_ssl_exec/include", 22 "net_ssl_module/include", 23 "$NETSTACK_DIR/frameworks/native/net_ssl/include", 24 "$NETSTACK_DIR/interfaces/innerkits/net_ssl/include", 25 "$NETSTACK_DIR/utils/common_utils/include", 26 ] 27 28 if (is_mingw || is_mac) { 29 cflags = [ 30 "-std=c++17", 31 "-stdlib=libc++", 32 ] 33 } 34 if (is_mingw) { 35 defines = [ "WINDOWS_PLATFORM" ] 36 } else if (is_mac) { 37 defines = [ "MAC_PLATFORM" ] 38 } 39} 40 41ohos_shared_library("networksecurity_napi") { 42 sanitize = { 43 cfi = true 44 cfi_cross_dso = true 45 debug = false 46 } 47 48 branch_protector_ret = "pac_ret" 49 50 sources = [ 51 "async_context/src/cert_context.cpp", 52 "async_context/src/cleartext_context.cpp", 53 "async_work/src/net_ssl_async_work.cpp", 54 "net_ssl_exec/src/net_ssl_exec.cpp", 55 "net_ssl_module/src/net_ssl_module.cpp", 56 ] 57 cflags = [ 58 "-fstack-protector-strong", 59 "-D_FORTIFY_SOURCE=2", 60 "-O2", 61 ] 62 cflags_cc = [ 63 "-fstack-protector-strong", 64 "-D_FORTIFY_SOURCE=2", 65 "-O2", 66 ] 67 68 configs = [ ":networksecurity_napi_config" ] 69 70 deps = [] 71 if (is_mingw || is_mac) { 72 sources += 73 [ "$NETSTACK_DIR/utils/common_utils/src/netstack_common_utils.cpp" ] 74 deps += [ 75 "$NETSTACK_DIR/utils/napi_utils:napi_utils_static", 76 ] 77 external_deps += [ 78 "napi:ace_napi", 79 ] 80 } else { 81 deps += [ 82 "$NETSTACK_DIR/interfaces/innerkits/net_ssl:net_ssl", 83 "$NETSTACK_DIR/utils:stack_utils_common", 84 "$NETSTACK_DIR/utils/napi_utils:napi_utils", 85 ] 86 external_deps = [ 87 "hilog:libhilog", 88 "napi:ace_napi", 89 "openssl:libcrypto_shared", 90 "openssl:libssl_shared", 91 "samgr:samgr_proxy", 92 ] 93 } 94 defines = [] 95 if (defined(global_parts_info) && 96 defined(global_parts_info.communication_netmanager_base) && 97 global_parts_info.communication_netmanager_base) { 98 external_deps += [ 99 "netmanager_base:net_conn_manager_if", 100 "netmanager_base:net_security_config_if", 101 ] 102 defines += [ "HAS_NETMANAGER_BASE=1" ] 103 } else { 104 defines += [ "HAS_NETMANAGER_BASE=0" ] 105 } 106 107 relative_install_dir = "module/net" 108 part_name = "netstack" 109 subsystem_name = "communication" 110} 111