1// Copyright (C) 2021 The Android Open Source Project 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15package { 16 default_applicable_licenses: ["Android-Apache-2.0"], 17} 18 19soong_config_module_type { 20 name: "wifi_cc_defaults", 21 module_type: "cc_defaults", 22 config_namespace: "wifi", 23 bool_variables: [ 24 "multiple_vendor_hals", // WIFI_MULTIPLE_VENDOR_HALS 25 "google_wifi_config_lib", // $(wildcard vendor/google/libraries/GoogleWifiConfigLib) 26 ], 27 value_variables: [ 28 "driver_module_path", // WIFI_DRIVER_MODULE_PATH 29 "driver_module_arg", // WIFI_DRIVER_MODULE_ARG 30 "driver_module_name", // WIFI_DRIVER_MODULE_NAME 31 "driver_fw_path_sta", // WIFI_DRIVER_FW_PATH_STA 32 "driver_fw_path_ap", // WIFI_DRIVER_FW_PATH_AP 33 "driver_fw_path_p2p", // WIFI_DRIVER_FW_PATH_P2P 34 "driver_fw_path_param", // WIFI_DRIVER_FW_PATH_PARAM 35 "driver_state_ctrl_param", // WIFI_DRIVER_STATE_CTRL_PARAM 36 "driver_state_on", // WIFI_DRIVER_STATE_ON 37 "driver_state_off", // WIFI_DRIVER_STATE_OFF 38 ], 39 variables: [ 40 "board_wlan_device", // BOARD_WLAN_DEVICE 41 ], 42 properties: [ 43 "cflags", 44 "defaults", 45 "shared_libs", 46 "whole_static_libs", 47 ], 48} 49 50soong_config_string_variable { 51 name: "board_wlan_device", 52 values: [ 53 "bcmdhd", 54 "synadhd", 55 "qcwcn", 56 "mrvl", 57 "nxp", 58 "MediaTek", 59 "realtek", 60 "emulator", 61 "rtl", 62 "slsi", 63 "wlan0", 64 ], 65} 66 67wifi_cc_defaults { 68 name: "libwifi_hal_cflags_defaults", 69 cflags: [ 70 "-Wall", 71 "-Werror", 72 "-Wextra", 73 "-Winit-self", 74 "-Wno-unused-function", 75 "-Wno-unused-parameter", 76 "-Wshadow", 77 "-Wunused-variable", 78 "-Wwrite-strings", 79 ], 80 soong_config_variables: { 81 driver_module_path: { 82 cflags: ["-DWIFI_DRIVER_MODULE_PATH=%s"], 83 }, 84 driver_module_arg: { 85 cflags: ["-DWIFI_DRIVER_MODULE_ARG=%s"], 86 }, 87 driver_module_name: { 88 cflags: ["-DWIFI_DRIVER_MODULE_NAME=%s"], 89 }, 90 driver_fw_path_sta: { 91 cflags: ["-DWIFI_DRIVER_FW_PATH_STA=%s"], 92 }, 93 driver_fw_path_ap: { 94 cflags: ["-DWIFI_DRIVER_FW_PATH_AP=%s"], 95 }, 96 driver_fw_path_p2p: { 97 cflags: ["-DWIFI_DRIVER_FW_PATH_P2P=%s"], 98 }, 99 // Some devices use a different path (e.g. devices with broadcom WiFi parts). 100 driver_fw_path_param: { 101 cflags: ["-DWIFI_DRIVER_FW_PATH_PARAM=%s"], 102 conditions_default: { 103 cflags: ["-DWIFI_DRIVER_FW_PATH_PARAM=\"/sys/module/wlan/parameters/fwpath\""], 104 }, 105 }, 106 driver_state_ctrl_param: { 107 cflags: ["-DWIFI_DRIVER_STATE_CTRL_PARAM=%s"], 108 }, 109 driver_state_on: { 110 cflags: ["-DWIFI_DRIVER_STATE_ON=%s"], 111 }, 112 driver_state_off: { 113 cflags: ["-DWIFI_DRIVER_STATE_OFF=%s"], 114 }, 115 multiple_vendor_hals: { 116 cflags: ["-DWIFI_MULTIPLE_VENDOR_HALS"], 117 } 118 }, 119} 120 121// Common code shared between the HALs. 122cc_library_static { 123 name: "libwifi-hal-common", 124 vendor: true, 125 defaults: ["libwifi_hal_cflags_defaults"], 126 srcs: ["wifi_hal_common.cpp"], 127 shared_libs: ["libbase"], 128 header_libs: ["libcutils_headers"], 129 local_include_dirs: ["include"], 130} 131 132// A fallback "vendor" HAL library. 133// Don't link this, link libwifi-hal. 134cc_library_static { 135 name: "libwifi-hal-fallback", 136 vendor: true, 137 defaults: ["libwifi_hal_cflags_defaults"], 138 srcs: ["wifi_hal_fallback.cpp"], 139 header_libs: ["libhardware_legacy_headers"] 140} 141 142wifi_cc_defaults { 143 name: "google_wifi_config_lib_defaults", 144 soong_config_variables: { 145 google_wifi_config_lib: { 146 shared_libs: ["google_wifi_firmware_config_version_c_wrapper"], 147 }, 148 }, 149} 150 151wifi_cc_defaults { 152 name: "libwifi_hal_vendor_impl_defaults", 153 soong_config_variables: { 154 board_wlan_device: { 155 bcmdhd: { 156 whole_static_libs: ["libwifi-hal-bcm"], 157 }, 158 synadhd: { 159 whole_static_libs: ["libwifi-hal-syna"], 160 }, 161 qcwcn: { 162 whole_static_libs: ["libwifi-hal-qcom"], 163 }, 164 mrvl: { 165 // this is commented because none of the nexus devices 166 // that sport Marvell's wifi have support for HAL 167 // whole_static_libs: ["libwifi-hal-mrvl"], 168 }, 169 mediaTek: { 170 whole_static_libs: ["libwifi-hal-mt66xx"], 171 }, 172 realtek: { 173 whole_static_libs: ["libwifi-hal-rtk"], 174 }, 175 emulator: { 176 whole_static_libs: ["//device/generic/goldfish:libwifi-hal-emu"], 177 }, 178 slsi: { 179 whole_static_libs: ["libwifi-hal-slsi"], 180 }, 181 conditions_default: { 182 whole_static_libs: ["libwifi-hal-fallback"], 183 }, 184 }, 185 }, 186} 187 188wifi_cc_defaults { 189 name: "libwifi_hal_vendor_deps_defaults", 190 soong_config_variables: { 191 board_wlan_device: { 192 bcmdhd: { 193 shared_libs: ["libcrypto"], 194 defaults: ["google_wifi_config_lib_defaults"], 195 }, 196 synadhd: { 197 shared_libs: ["libcrypto"], 198 defaults: ["google_wifi_config_lib_defaults"], 199 }, 200 qcwcn: { 201 shared_libs: ["libcld80211", "libcrypto"], 202 }, 203 }, 204 }, 205} 206 207cc_library_shared { 208 name: "libwifi-hal", 209 proprietary: true, 210 compile_multilib: "first", 211 defaults: [ 212 "libwifi_hal_cflags_defaults", 213 "libwifi_hal_vendor_deps_defaults", // shared_libs used by libwifi-hal-<vendor> 214 "libwifi_hal_vendor_impl_defaults", 215 ], 216 local_include_dirs: ["include"], 217 export_include_dirs: ["include"], 218 header_libs: ["libhardware_legacy_headers"], 219 export_header_lib_headers: ["libhardware_legacy_headers"], 220 shared_libs: [ 221 "libbase", 222 "libcutils", 223 "liblog", 224 "libnl", 225 "libutils", 226 ], 227 srcs: [ 228 "driver_tool.cpp", 229 "hal_tool.cpp", 230 ], 231 whole_static_libs: ["libwifi-hal-common"], 232 // b/242259479 remove this 233 sanitize: { 234 cfi: true, 235 integer_overflow: true, 236 }, 237} 238 239// Expose make-built libwifi-hal-<vendor> via wifi_cc_prebuilt_library_static. 240 241// Licenses for imported libwifi-hal-<vendor> libraries 242 243license { 244 name: "libwifi_hal_apache20_license", 245 visibility: [":__subpackages__"], 246 license_kinds: [ 247 "SPDX-license-identifier-Apache-2.0", 248 ], 249} 250 251license { 252 name: "libwifi_hal_bsd_license", 253 visibility: [":__subpackages__"], 254 license_kinds: [ 255 "SPDX-license-identifier-BSD", 256 ], 257} 258 259// Additional soong_config_module_types to enable/disable according to BOARD_WLAN_DEVICE 260// If libwifi-hal-<vendor> libs are migrated to soong modules, these are not necessary. 261 262soong_config_module_type { 263 name: "wifi_cc_prebuilt_library_static", 264 module_type: "cc_prebuilt_library_static", 265 config_namespace: "wifi", 266 variables: [ 267 "board_wlan_device", // BOARD_WLAN_DEVICE 268 ], 269 properties: [ 270 "enabled", 271 ], 272} 273 274soong_config_module_type { 275 name: "wifi_cc_prebuilt_library_shared", 276 module_type: "cc_prebuilt_library_shared", 277 config_namespace: "wifi", 278 variables: [ 279 "board_wlan_device", // BOARD_WLAN_DEVICE 280 ], 281 properties: [ 282 "enabled", 283 ], 284} 285 286soong_config_module_type { 287 name: "wifi_makefile_goal", 288 module_type: "makefile_goal", 289 config_namespace: "wifi", 290 variables: [ 291 "board_wlan_device", // BOARD_WLAN_DEVICE 292 ], 293 properties: [ 294 "enabled", 295 ], 296} 297 298// libwifi-hal-syna 299 300wifi_cc_prebuilt_library_static { 301 name: "libwifi-hal-syna", 302 proprietary: true, 303 srcs: [":make-libwifi-hal-syna"], 304 compile_multilib: "first", 305 installable: false, 306 licenses: ["libwifi_hal_apache20_license"], 307 enabled: false, 308 soong_config_variables: { 309 board_wlan_device: { 310 synadhd: { 311 enabled: true, 312 }, 313 }, 314 }, 315} 316 317wifi_makefile_goal { 318 name: "make-libwifi-hal-syna", 319 product_out_path: "obj/STATIC_LIBRARIES/libwifi-hal-syna_intermediates/libwifi-hal-syna.a", 320 enabled: false, 321 soong_config_variables: { 322 board_wlan_device: { 323 synadhd: { 324 enabled: true, 325 }, 326 }, 327 }, 328} 329 330// libwifi-hal-qcom 331 332wifi_cc_prebuilt_library_static { 333 name: "libwifi-hal-qcom", 334 proprietary: true, 335 srcs: [":make-libwifi-hal-qcom"], 336 compile_multilib: "first", 337 installable: false, 338 licenses: ["libwifi_hal_apache20_license", "libwifi_hal_bsd_license"], 339 enabled: false, 340 soong_config_variables: { 341 board_wlan_device: { 342 qcwcn: { 343 enabled: true, 344 }, 345 }, 346 }, 347} 348 349wifi_makefile_goal { 350 name: "make-libwifi-hal-qcom", 351 product_out_path: "obj/STATIC_LIBRARIES/libwifi-hal-qcom_intermediates/libwifi-hal-qcom.a", 352 enabled: false, 353 soong_config_variables: { 354 board_wlan_device: { 355 qcwcn: { 356 enabled: true, 357 }, 358 }, 359 }, 360} 361 362// libcld80211 363 364wifi_cc_prebuilt_library_shared { 365 name: "libcld80211", 366 vendor: true, 367 srcs: [":make-libcld80211"], 368 compile_multilib: "first", 369 installable: false, 370 licenses: ["libwifi_hal_bsd_license"], 371 enabled: false, 372 soong_config_variables: { 373 board_wlan_device: { 374 qcwcn: { 375 enabled: true, 376 }, 377 }, 378 }, 379} 380 381wifi_makefile_goal { 382 name: "make-libcld80211", 383 product_out_path: "obj/SHARED_LIBRARIES/libcld80211_intermediates/LINKED/libcld80211.so", 384 enabled: false, 385 soong_config_variables: { 386 board_wlan_device: { 387 qcwcn: { 388 enabled: true, 389 }, 390 }, 391 }, 392} 393 394// libwifi-hal-mt66xx 395 396wifi_cc_prebuilt_library_static { 397 name: "libwifi-hal-mt66xx", 398 proprietary: true, 399 srcs: [":make-libwifi-hal-mt66xx"], 400 compile_multilib: "first", 401 installable: false, 402 licenses: ["libwifi_hal_apache20_license"], 403 enabled: false, 404 soong_config_variables: { 405 board_wlan_device: { 406 mediaTek: { 407 enabled: true, 408 }, 409 }, 410 }, 411} 412 413wifi_makefile_goal { 414 name: "make-libwifi-hal-mt66xx", 415 product_out_path: "obj/STATIC_LIBRARIES/libwifi-hal-mt66xx_intermediates/libwifi-hal-mt66xx.a", 416 enabled: false, 417 soong_config_variables: { 418 board_wlan_device: { 419 mediaTek: { 420 enabled: true, 421 }, 422 }, 423 }, 424} 425