1# Copyright (c) 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("//build/ohos.gni")
15import("../../../dsoftbus.gni")
16
17ohos_static_library("wifi_direct") {
18  defines += [ "__STDC_FORMAT_MACROS" ]
19  if (is_asan) {
20    defines += [ "ASAN_BUILD" ]
21  }
22
23  wifi_direct_path = "$dsoftbus_root_path/core/connection/wifi_direct_cpp"
24  wifi_direct_connection_src = []
25
26  wifi_direct_connection_inc = [
27    "$dsoftbus_root_path/adapter/common/net/wifi/include",
28    "$dsoftbus_root_path/core/authentication/include",
29    "$dsoftbus_root_path/core/authentication/interface",
30    "$dsoftbus_root_path/core/common/dfx/hisysevent_adapter/include",
31    "$dsoftbus_root_path/core/common/dfx/interface/include",
32    "$dsoftbus_root_path/core/adapter/authentication/include",
33    "$dsoftbus_root_path/core/bus_center/lnn/lane_hub/heartbeat/include",
34    "$dsoftbus_root_path/core/adapter/bus_center/include",
35    "$dsoftbus_root_path/core/bus_center/utils/include/",
36    "$dsoftbus_root_path/core/bus_center/lnn/net_builder/include",
37    "$dsoftbus_root_path/core/bus_center/lnn/net_ledger/common/include",
38    "$dsoftbus_root_path/core/bus_center/interface",
39    "$dsoftbus_root_path/core/bus_center/lnn/net_ledger/distributed_ledger/include",
40    "$dsoftbus_root_path/core/connection/interface",
41    "$dsoftbus_root_path/core/common/include",
42    "$dsoftbus_root_path/core/discovery/manager/include",
43    "$dsoftbus_root_path/core/discovery/interface",
44    "$dsoftbus_root_path/adapter/common/include",
45    "$dsoftbus_root_path/interfaces/inner_kits/lnn",
46    "$dsoftbus_root_path/interfaces/kits/common",
47    "$dsoftbus_root_path/interfaces/kits/discovery",
48    "$dsoftbus_root_path/interfaces/kits/bus_center",
49    "$dsoftbus_root_path/core/transmission/trans_channel/proxy/include",
50    "$dsoftbus_root_path/core/bus_center/lnn/lane_hub/lane_manager/include",
51    "$dsoftbus_root_path/core/connection/wifi_direct_cpp",
52  ]
53
54  if (!defined(ohos_lite)) {
55    wifi_direct_connection_inc +=
56        [ "$dsoftbus_root_path/adapter/common/include/OS_adapter_define/linux" ]
57  }
58
59  wifi_direct_connection_external_deps = []
60
61  if (dsoftbus_feature_conn_p2p == true &&
62      softbus_communication_wifi_feature == true) {
63    sanitize = {
64      cfi = true
65      cfi_cross_dso = true
66      debug = false
67    }
68    branch_protector_ret = "pac_ret"
69    wifi_direct_connection_src += [
70      "$wifi_direct_path/adapter/p2p_adapter.cpp",
71      "$wifi_direct_path/channel/auth_negotiate_channel.cpp",
72      "$wifi_direct_path/channel/proxy_negotiate_channel.cpp",
73      "$wifi_direct_path/channel/dummy_negotiate_channel.cpp",
74      "$wifi_direct_path/command/connect_command.cpp",
75      "$wifi_direct_path/command/command_factory.cpp",
76      "$wifi_direct_path/command/disconnect_command.cpp",
77      "$wifi_direct_path/command/force_disconnect_command.cpp",
78      "$wifi_direct_path/command/negotiate_command.cpp",
79      "$wifi_direct_path/command/processor_selector_factory.cpp",
80      "$wifi_direct_path/command/simple_processor_selector.cpp",
81      "$wifi_direct_path/data/inner_link.cpp",
82      "$wifi_direct_path/data/interface_info.cpp",
83      "$wifi_direct_path/data/interface_manager.cpp",
84      "$wifi_direct_path/data/ipv4_info.cpp",
85      "$wifi_direct_path/data/link_info.cpp",
86      "$wifi_direct_path/data/link_manager.cpp",
87      "$wifi_direct_path/data/negotiate_message.cpp",
88      "$wifi_direct_path/data/wifi_config_info.cpp",
89      "$wifi_direct_path/event/wifi_direct_event_dispatcher.cpp",
90      "$wifi_direct_path/entity/p2p_available_state.cpp",
91      "$wifi_direct_path/entity/p2p_connect_state.cpp",
92      "$wifi_direct_path/entity/p2p_create_group_state.cpp",
93      "$wifi_direct_path/entity/p2p_destroy_group_state.cpp",
94      "$wifi_direct_path/entity/p2p_entity.cpp",
95      "$wifi_direct_path/entity/p2p_entity_state.cpp",
96      "$wifi_direct_path/entity/p2p_unavailable_state.cpp",
97      "$wifi_direct_path/entity/p2p_broadcast_receiver.cpp",
98      "$wifi_direct_path/processor/p2p_v1_processor.cpp",
99      "$wifi_direct_path/processor/null_processor.cpp",
100      "$wifi_direct_path/protocol/json_protocol.cpp",
101      "$wifi_direct_path/protocol/tlv_protocol.cpp",
102      "$wifi_direct_path/utils/wifi_direct_anonymous.cpp",
103      "$wifi_direct_path/utils/duration_statistic.cpp",
104      "$wifi_direct_path/utils/wifi_direct_trace.cpp",
105      "$wifi_direct_path/utils/wifi_direct_utils.cpp",
106      "$wifi_direct_path/wifi_direct_executor.cpp",
107      "$wifi_direct_path/wifi_direct_initiator.cpp",
108      "$wifi_direct_path/wifi_direct_ip_manager.cpp",
109      "$wifi_direct_path/wifi_direct_manager.cpp",
110      "$wifi_direct_path/wifi_direct_role_option.cpp",
111      "$wifi_direct_path/wifi_direct_scheduler.cpp",
112      "$wifi_direct_path/utils/wifi_direct_dfx.cpp",
113    ]
114
115    if (dsoftbus_feature_ex_kits == true) {
116      import(
117          "../../../dsoftbus_enhance/core/connection/wifi_direct_cpp/wifi_direct.gni")
118
119      wifi_direct_connection_inc += wifi_direct_connection_enhance_inc
120      wifi_direct_connection_src += wifi_direct_connection_enhance_src
121      wifi_direct_connection_external_deps +=
122          wifi_direct_connection_enhance_external_deps
123    }
124
125    wifi_direct_connection_external_deps += [
126      "bounds_checking_function:libsec_shared",
127      "cJSON:cjson",
128      "c_utils:utils",
129      "hilog:libhilog",
130      "hitrace:libhitracechain",
131      "init:libbegetutil",
132      "json:nlohmann_json_static",
133      "netmanager_base:net_conn_manager_if",
134      "wifi:wifi_sdk",
135    ]
136
137    remove_configs = [
138      "//build/config/compiler:no_rtti",
139      "//build/config/compiler:no_exceptions",
140    ]
141
142    configs = [
143      "//build/config/compiler:rtti",
144      "//build/config/compiler:exceptions",
145    ]
146  } else {
147    wifi_direct_connection_src +=
148        [ "$wifi_direct_path/wifi_direct_manager_virtual.c" ]
149  }
150
151  include_dirs = wifi_direct_connection_inc
152  sources = wifi_direct_connection_src
153  external_deps = wifi_direct_connection_external_deps
154
155  part_name = "dsoftbus"
156  subsystem_name = "communication"
157}
158