# Copyright (C) 2025 The Android Open Source Project # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """wpa_supplicant_8 bazel build rule.""" load("@rules_cc//cc:defs.bzl", "cc_library") # Common source files for the hostapd library, derived from the CMake file. HOSTAPD_SRCS = [ "hostapd/main.c", "hostapd/config_file.c", "hostapd/eap_register.c", "src/l2_packet/l2_packet_none.c", "src/drivers/drivers.c", "src/drivers/driver_common.c", "src/drivers/driver_virtio_wifi.c", "src/utils/common.c", "src/utils/wpa_debug.c", "src/utils/wpabuf.c", "src/utils/ip_addr.c", "src/utils/radiotap.c", "src/utils/uuid.c", "src/utils/base64.c", "src/utils/json.c", "src/common/ieee802_11_common.c", "src/common/ctrl_iface_common.c", "src/common/sae.c", "src/common/wpa_common.c", "src/common/hw_features_common.c", "src/common/gas.c", "src/common/dpp.c", "src/eapol_auth/eapol_auth_dump.c", "src/eapol_auth/eapol_auth_sm.c", "src/eap_server/eap_server_md5.c", "src/eap_server/eap_server_tls.c", "src/eap_server/eap_server_peap.c", "src/eap_common/eap_peap_common.c", "src/eap_server/eap_server_ttls.c", "src/eap_server/eap_server_mschapv2.c", "src/eap_server/eap_server_gtc.c", "src/eap_server/eap_server_sim.c", "src/eap_server/eap_server_aka.c", "src/eap_common/eap_sim_common.c", "src/eap_server/eap_server_pwd.c", "src/eap_common/eap_pwd_common.c", "src/ap/wps_hostapd.c", "src/eap_server/eap_server_wsc.c", "src/eap_common/eap_wsc_common.c", "src/wps/wps.c", "src/wps/wps_common.c", "src/wps/wps_attr_parse.c", "src/wps/wps_attr_build.c", "src/wps/wps_attr_process.c", "src/wps/wps_dev_attr.c", "src/wps/wps_enrollee.c", "src/wps/wps_registrar.c", "src/wps/ndef.c", "src/ap/dpp_hostapd.c", "src/ap/gas_query_ap.c", "src/eap_server/eap_server.c", "src/eap_common/eap_common.c", "src/eap_server/eap_server_methods.c", "src/eap_server/eap_server_identity.c", "src/eap_common/chap.c", "src/eap_server/eap_server_tls_common.c", "src/crypto/ms_funcs.c", "src/crypto/tls_none.c", "src/crypto/crypto_openssl.c", "src/crypto/fips_prf_openssl.c", "src/crypto/aes-ccm.c", "src/crypto/aes-internal.c", "src/crypto/aes-wrap.c", "src/crypto/aes-siv.c", "src/crypto/aes-ctr.c", "src/crypto/aes-omac1.c", "src/crypto/sha1-prf.c", "src/crypto/sha1-tlsprf.c", "src/crypto/sha256-prf.c", "src/crypto/sha256-tlsprf.c", "src/crypto/sha256-kdf.c", "src/crypto/sha384-kdf.c", "src/crypto/sha512-kdf.c", "src/crypto/sha384-prf.c", "src/crypto/sha512-prf.c", "src/crypto/dh_groups.c", "src/ap/hostapd.c", "src/ap/wnm_ap.c", "src/ap/wpa_auth_glue.c", "src/ap/drv_callbacks.c", "src/ap/ap_drv_ops.c", "src/ap/utils.c", "src/ap/authsrv.c", "src/ap/ieee802_1x.c", "src/ap/ap_config.c", "src/ap/eap_user_db.c", "src/ap/ieee802_11_auth.c", "src/ap/sta_info.c", "src/ap/wpa_auth.c", "src/ap/tkip_countermeasures.c", "src/ap/ap_mlme.c", "src/ap/ctrl_iface_ap.c", "src/ap/wpa_auth_ie.c", "src/ap/preauth_auth.c", "src/ap/pmksa_cache_auth.c", "src/ap/ieee802_11_shared.c", "src/ap/bss_load.c", "src/ap/neighbor_db.c", "src/ap/rrm.c", "src/ap/eth_p_oui.c", "src/ap/wpa_auth_ft.c", "src/ap/wmm.c", "src/ap/ap_list.c", "src/ap/ieee802_11.c", "src/ap/hw_features.c", "src/ap/dfs.c", "src/ap/ieee802_11_ht.c", "src/ap/ieee802_11_vht.c", "src/ap/hs20.c", "src/ap/gas_serv.c", "src/ap/acs.c", "src/ap/beacon.c", ] cc_library( name = "hostapd_c_lib", srcs = HOSTAPD_SRCS + select({ "@bazel_tools//src/conditions:windows": [ "src/utils/eloop_win.c", "src/utils/os_win32.c", ], "//conditions:default": [ "src/utils/eloop.c", "src/utils/os_unix.c", ], }), hdrs = glob([ "src/**/*.h", "hostapd/**/*.h", ]), # Public includes correspond to PUBLIC in CMake, private ones go in `includes`. includes = [ "src", "hostapd", "src/utils", ], # Defines are taken directly from the CMake PRIVATE list. defines = [ "WPA_IGNORE_CONFIG_ERRORS", 'VERSION_STR_POSTFIX=\\"-EMU\\"', "HOSTAPD", "HOSTAPD_DUMP_STATE", "CONFIG_NO_RADIUS", "CONFIG_NO_ACCOUNTING", "CONFIG_NO_VLAN", "CONFIG_NO_CTRL_IFACE", "CONFIG_NO_RANDOM_POOL", "CONFIG_SUITEB", "CONFIG_SUITEB192", "CONFIG_ETH_P_OUI", "CONFIG_SAE", "CONFIG_WNM", "CONFIG_WNM_AP", "CONFIG_IEEE80211N", "CONFIG_WPS", "CONFIG_WPS_NFC", "CONFIG_WPS_OOB", "CONFIG_DPP", "PKCS12_FUNCS", 'TLS_DEFAULT_CIPHERS="DEFAULT:!EXP:!LOW"', "CONFIG_SHA256", "CONFIG_SHA384", "CONFIG_SHA512", "CONFIG_ECC", "CONFIG_IPV6", "CONFIG_JSON", "NEED_AP_MLME", "CONFIG_HS20", "CONFIG_INTERWORKING", "CONFIG_ACS", "CONFIG_OPENSSL_INTERNAL_AES_WRAP", "CONFIG_DRIVER_VIRTIO_WIFI", ] + select({ "@bazel_tools//src/conditions:windows": ["CONFIG_NATIVE_WINDOWS"], "//conditions:default": [], }), # Compiler options are conditional, similar to the CMake if() block. copts = select({ # The CMake logic excludes Windows and Linux AArch64. # This is a simplification; for more complex logic, use custom config_settings. "@bazel_tools//src/conditions:windows": [], "//conditions:default": [ "-Wall", "-Werror", "-Wno-unused-but-set-variable", "-Wno-unused-parameter", "-Wno-unused-variable", "-Wno-macro-redefined", "-Wno-error=maybe-uninitialized", "-Wno-deprecated-declarations", # <-- ADD THIS LINE ], }), deps = [ "@boringssl//:crypto", "@qemu//:qemu_headers", ], visibility = ["//visibility:public"], )