1f1549183Sopenharmony_ci# Copyright (C) 2023 Huawei Device Co., Ltd.
2f1549183Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License");
3f1549183Sopenharmony_ci# you may not use this file except in compliance with the License.
4f1549183Sopenharmony_ci# You may obtain a copy of the License at
5f1549183Sopenharmony_ci#
6f1549183Sopenharmony_ci#     http://www.apache.org/licenses/LICENSE-2.0
7f1549183Sopenharmony_ci#
8f1549183Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software
9f1549183Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS,
10f1549183Sopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11f1549183Sopenharmony_ci# See the License for the specific language governing permissions and
12f1549183Sopenharmony_ci# limitations under the License.
13f1549183Sopenharmony_ci
14f1549183Sopenharmony_ciif (defined(ohos_lite)) {
15f1549183Sopenharmony_ci  import("//build/lite/config/component/lite_component.gni")
16f1549183Sopenharmony_ci  import("//foundation/communication/wifi/wifi/wifi_lite.gni")
17f1549183Sopenharmony_ci} else {
18f1549183Sopenharmony_ci  import("//build/ohos.gni")
19f1549183Sopenharmony_ci  import("//foundation/communication/wifi/wifi/wifi.gni")
20f1549183Sopenharmony_ci}
21f1549183Sopenharmony_ci
22f1549183Sopenharmony_cilocal_base_sources = [
23f1549183Sopenharmony_ci  "security_utils/src/wifi_openssl_utils.cpp",
24f1549183Sopenharmony_ci  "shared_util/wifi_watchdog_utils.cpp",
25f1549183Sopenharmony_ci  "state_machine/src/handler.cpp",
26f1549183Sopenharmony_ci  "state_machine/src/internal_message.cpp",
27f1549183Sopenharmony_ci  "state_machine/src/message_queue.cpp",
28f1549183Sopenharmony_ci  "state_machine/src/state.cpp",
29f1549183Sopenharmony_ci  "state_machine/src/state_machine.cpp",
30f1549183Sopenharmony_ci]
31f1549183Sopenharmony_ci
32f1549183Sopenharmony_cilocal_base_include_dirs = [
33f1549183Sopenharmony_ci  "$WIFI_ROOT_DIR/base/cRPC/include",
34f1549183Sopenharmony_ci  "$WIFI_ROOT_DIR/base/security_utils/include",
35f1549183Sopenharmony_ci  "$WIFI_ROOT_DIR/base/state_machine/include",
36f1549183Sopenharmony_ci  "$WIFI_ROOT_DIR/base/inner_api",
37f1549183Sopenharmony_ci  "$WIFI_ROOT_DIR/base/shared_util",
38f1549183Sopenharmony_ci  "$WIFI_ROOT_DIR/interfaces/inner_api",
39f1549183Sopenharmony_ci  "$WIFI_ROOT_DIR/frameworks/native/interfaces",
40f1549183Sopenharmony_ci  "$WIFI_ROOT_DIR/frameworks/native/c_adapter/inc",
41f1549183Sopenharmony_ci  "$WIFI_ROOT_DIR/services/wifi_standard/include",
42f1549183Sopenharmony_ci  "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_toolkit/include",
43f1549183Sopenharmony_ci  "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_toolkit/log",
44f1549183Sopenharmony_ci  "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_toolkit/config",
45f1549183Sopenharmony_ci  "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_toolkit/net_helper",
46f1549183Sopenharmony_ci  "$WIFI_ROOT_DIR/utils/inc",
47f1549183Sopenharmony_ci]
48f1549183Sopenharmony_ci
49f1549183Sopenharmony_ciif (defined(ohos_lite)) {
50f1549183Sopenharmony_ci  shared_library("wifi_base") {
51f1549183Sopenharmony_ci    sources = local_base_sources
52f1549183Sopenharmony_ci
53f1549183Sopenharmony_ci    include_dirs = local_base_include_dirs
54f1549183Sopenharmony_ci
55f1549183Sopenharmony_ci    deps = [ "$WIFI_ROOT_DIR/base/cRPC:crpc_client" ]
56f1549183Sopenharmony_ci
57f1549183Sopenharmony_ci    external_deps = [
58f1549183Sopenharmony_ci      "hilog_lite:hilog_shared",
59f1549183Sopenharmony_ci      "openssl:libcrypto_shared",
60f1549183Sopenharmony_ci      "openssl:libssl_shared",
61f1549183Sopenharmony_ci    ]
62f1549183Sopenharmony_ci
63f1549183Sopenharmony_ci    configs -= [ "//build/lite/config:language_cpp" ]
64f1549183Sopenharmony_ci
65f1549183Sopenharmony_ci    cflags = memory_optimization_cflags
66f1549183Sopenharmony_ci    cflags_cc = memory_optimization_cflags_cc
67f1549183Sopenharmony_ci    ldflags = memory_optimization_ldflags
68f1549183Sopenharmony_ci    cflags_cc += [
69f1549183Sopenharmony_ci      "-std=c++17",
70f1549183Sopenharmony_ci      "-fno-rtti",
71f1549183Sopenharmony_ci    ]
72f1549183Sopenharmony_ci
73f1549183Sopenharmony_ci    ldflags += [
74f1549183Sopenharmony_ci      "-fPIC",
75f1549183Sopenharmony_ci      "-Wl,-E",
76f1549183Sopenharmony_ci    ]
77f1549183Sopenharmony_ci
78f1549183Sopenharmony_ci    defines = [ "OHOS_ARCH_LITE" ]
79f1549183Sopenharmony_ci  }
80f1549183Sopenharmony_ci} else {
81f1549183Sopenharmony_ci  config("wifi_base_exported_header") {
82f1549183Sopenharmony_ci    visibility = [ ":*" ]
83f1549183Sopenharmony_ci    include_dirs = local_base_include_dirs
84f1549183Sopenharmony_ci  }
85f1549183Sopenharmony_ci
86f1549183Sopenharmony_ci  ohos_shared_library("wifi_base") {
87f1549183Sopenharmony_ci    branch_protector_ret = "pac_ret"
88f1549183Sopenharmony_ci
89f1549183Sopenharmony_ci    sanitize = {
90f1549183Sopenharmony_ci      cfi = true  # Enable/disable control flow integrity detection
91f1549183Sopenharmony_ci      boundary_sanitize = true  # Enable boundary san detection
92f1549183Sopenharmony_ci      cfi_cross_dso = true  # Cross-SO CFI Checks
93f1549183Sopenharmony_ci      integer_overflow = true  # Enable integer overflow detection
94f1549183Sopenharmony_ci      ubsan = true  # Enable some Ubsan options
95f1549183Sopenharmony_ci      debug = false
96f1549183Sopenharmony_ci    }
97f1549183Sopenharmony_ci
98f1549183Sopenharmony_ci    install_enable = true
99f1549183Sopenharmony_ci    sources = local_base_sources
100f1549183Sopenharmony_ci
101f1549183Sopenharmony_ci    sources += [
102f1549183Sopenharmony_ci      "utils/wifi_app_parser.cpp",
103f1549183Sopenharmony_ci      "utils/xml_parser.cpp",
104f1549183Sopenharmony_ci    ]
105f1549183Sopenharmony_ci    include_dirs = local_base_include_dirs
106f1549183Sopenharmony_ci    include_dirs += [ "$WIFI_ROOT_DIR/base/utils" ]
107f1549183Sopenharmony_ci
108f1549183Sopenharmony_ci    deps = [ "$WIFI_ROOT_DIR/utils:wifi_utils" ]
109f1549183Sopenharmony_ci    defines = []
110f1549183Sopenharmony_ci
111f1549183Sopenharmony_ci    external_deps = [
112f1549183Sopenharmony_ci      "c_utils:utils",
113f1549183Sopenharmony_ci      "hicollie:libhicollie",
114f1549183Sopenharmony_ci      "hilog:libhilog",
115f1549183Sopenharmony_ci      "jsoncpp:jsoncpp",
116f1549183Sopenharmony_ci      "libxml2:libxml2",
117f1549183Sopenharmony_ci      "openssl:libcrypto_shared",
118f1549183Sopenharmony_ci      "openssl:libssl_shared",
119f1549183Sopenharmony_ci    ]
120f1549183Sopenharmony_ci    if (wifi_ffrt_enable) {
121f1549183Sopenharmony_ci      external_deps += [ "ffrt:libffrt" ]
122f1549183Sopenharmony_ci      defines += [ "WIFI_FFRT_ENABLE" ]
123f1549183Sopenharmony_ci    }
124f1549183Sopenharmony_ci    cflags = memory_optimization_cflags
125f1549183Sopenharmony_ci    cflags_cc = memory_optimization_cflags_cc
126f1549183Sopenharmony_ci    ldflags = memory_optimization_ldflags
127f1549183Sopenharmony_ci    cflags_cc += [
128f1549183Sopenharmony_ci      "-std=c++17",
129f1549183Sopenharmony_ci      "-fno-rtti",
130f1549183Sopenharmony_ci    ]
131f1549183Sopenharmony_ci
132f1549183Sopenharmony_ci    ldflags += [
133f1549183Sopenharmony_ci      "-fPIC",
134f1549183Sopenharmony_ci      "-Wl,-E",
135f1549183Sopenharmony_ci    ]
136f1549183Sopenharmony_ci
137f1549183Sopenharmony_ci    public_configs = [ ":wifi_base_exported_header" ]
138f1549183Sopenharmony_ci
139f1549183Sopenharmony_ci    part_name = "wifi"
140f1549183Sopenharmony_ci    subsystem_name = "communication"
141f1549183Sopenharmony_ci    innerapi_tags = [ "platformsdk" ]
142f1549183Sopenharmony_ci  }
143f1549183Sopenharmony_ci}
144