1load("@bazel_skylib//rules:copy_file.bzl", "copy_file") 2 3config_setting( 4 name = "darwin", 5 values = {"cpu": "darwin"}, 6) 7 8config_setting( 9 name = "darwin_x86_64", 10 values = {"cpu": "darwin_x86_64"}, 11) 12 13config_setting( 14 name = "darwin_arm64", 15 values = {"cpu": "darwin_arm64"}, 16) 17 18config_setting( 19 name = "darwin_arm64e", 20 values = {"cpu": "darwin_arm64e"}, 21) 22 23config_setting( 24 name = "windows", 25 values = {"cpu": "x64_windows"}, 26) 27 28# Android is not officially supported through C++. 29# This just helps with the build for now. 30config_setting( 31 name = "android", 32 values = {"crosstool_top": "//external:android/crosstool"}, 33 # TODO: Use constraint_values to detect android after Bazel 7.0 platforms migration is finished 34 # constraint_values = [ "@platforms//os:android" ], 35) 36 37# iOS is not officially supported through C++. 38# This just helps with the build for now. 39config_setting( 40 name = "ios_x86_64", 41 values = {"cpu": "ios_x86_64"}, 42) 43 44config_setting( 45 name = "ios_armv7", 46 values = {"cpu": "ios_armv7"}, 47) 48 49config_setting( 50 name = "ios_armv7s", 51 values = {"cpu": "ios_armv7s"}, 52) 53 54config_setting( 55 name = "ios_arm64", 56 values = {"cpu": "ios_arm64"}, 57) 58 59config_setting( 60 name = "ios_sim_arm64", 61 values = {"cpu": "ios_sim_arm64"}, 62) 63 64# The following architectures are found in 65# https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/rules/apple/ApplePlatform.java 66config_setting( 67 name = "tvos_x86_64", 68 values = {"cpu": "tvos_x86_64"}, 69) 70 71config_setting( 72 name = "tvos_arm64", 73 values = {"cpu": "tvos_arm64"} 74) 75 76config_setting( 77 name = "watchos_i386", 78 values = {"cpu": "watchos_i386"}, 79) 80 81config_setting( 82 name = "watchos_x86_64", 83 values = {"cpu": "watchos_x86_64"} 84) 85 86config_setting( 87 name = "watchos_armv7k", 88 values = {"cpu": "watchos_armv7k"}, 89) 90 91config_setting( 92 name = "watchos_arm64_32", 93 values = {"cpu": "watchos_arm64_32"} 94) 95 96config_setting( 97 name = "openbsd", 98 values = {"cpu": "openbsd"}, 99) 100 101copy_file( 102 name = "ares_build_h", 103 src = "@com_github_grpc_grpc//third_party/cares:ares_build.h", 104 out = "ares_build.h", 105) 106 107copy_file( 108 name = "ares_config_h", 109 src = select({ 110 ":ios_x86_64": "@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h", 111 ":ios_armv7": "@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h", 112 ":ios_armv7s": "@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h", 113 ":ios_arm64": "@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h", 114 ":ios_sim_arm64": "@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h", 115 ":tvos_x86_64": "@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h", 116 ":tvos_arm64": "@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h", 117 ":watchos_i386": "@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h", 118 ":watchos_x86_64": "@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h", 119 ":watchos_armv7k": "@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h", 120 ":watchos_arm64_32": "@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h", 121 ":darwin": "@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h", 122 ":darwin_x86_64": "@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h", 123 ":darwin_arm64": "@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h", 124 ":darwin_arm64e": "@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h", 125 ":windows": "@com_github_grpc_grpc//third_party/cares:config_windows/ares_config.h", 126 ":android": "@com_github_grpc_grpc//third_party/cares:config_android/ares_config.h", 127 ":openbsd": "@com_github_grpc_grpc//third_party/cares:config_openbsd/ares_config.h", 128 "//conditions:default": "@com_github_grpc_grpc//third_party/cares:config_linux/ares_config.h", 129 }), 130 out = "ares_config.h", 131) 132 133cc_library( 134 name = "ares", 135 srcs = [ 136 "src/lib/ares__read_line.c", 137 "src/lib/ares__get_hostent.c", 138 "src/lib/ares__close_sockets.c", 139 "src/lib/ares__timeval.c", 140 "src/lib/ares_gethostbyaddr.c", 141 "src/lib/ares_getenv.c", 142 "src/lib/ares_free_string.c", 143 "src/lib/ares_free_hostent.c", 144 "src/lib/ares_fds.c", 145 "src/lib/ares_expand_string.c", 146 "src/lib/ares_create_query.c", 147 "src/lib/ares_cancel.c", 148 "src/lib/ares_android.c", 149 "src/lib/ares_parse_txt_reply.c", 150 "src/lib/ares_parse_srv_reply.c", 151 "src/lib/ares_parse_soa_reply.c", 152 "src/lib/ares_parse_ptr_reply.c", 153 "src/lib/ares_parse_ns_reply.c", 154 "src/lib/ares_parse_naptr_reply.c", 155 "src/lib/ares_parse_mx_reply.c", 156 "src/lib/ares_parse_caa_reply.c", 157 "src/lib/ares_options.c", 158 "src/lib/ares_nowarn.c", 159 "src/lib/ares_mkquery.c", 160 "src/lib/ares_llist.c", 161 "src/lib/ares_getsock.c", 162 "src/lib/ares_getnameinfo.c", 163 "src/lib/bitncmp.c", 164 "src/lib/ares_writev.c", 165 "src/lib/ares_version.c", 166 "src/lib/ares_timeout.c", 167 "src/lib/ares_strerror.c", 168 "src/lib/ares_strcasecmp.c", 169 "src/lib/ares_search.c", 170 "src/lib/ares_platform.c", 171 "src/lib/windows_port.c", 172 "src/lib/inet_ntop.c", 173 "src/lib/ares__sortaddrinfo.c", 174 "src/lib/ares__readaddrinfo.c", 175 "src/lib/ares_parse_uri_reply.c", 176 "src/lib/ares__parse_into_addrinfo.c", 177 "src/lib/ares_parse_a_reply.c", 178 "src/lib/ares_parse_aaaa_reply.c", 179 "src/lib/ares_library_init.c", 180 "src/lib/ares_init.c", 181 "src/lib/ares_gethostbyname.c", 182 "src/lib/ares_getaddrinfo.c", 183 "src/lib/ares_freeaddrinfo.c", 184 "src/lib/ares_expand_name.c", 185 "src/lib/ares_destroy.c", 186 "src/lib/ares_data.c", 187 "src/lib/ares__addrinfo_localhost.c", 188 "src/lib/ares__addrinfo2hostent.c", 189 "src/lib/inet_net_pton.c", 190 "src/lib/ares_strsplit.c", 191 "src/lib/ares_strdup.c", 192 "src/lib/ares_send.c", 193 "src/lib/ares_rand.c", 194 "src/lib/ares_query.c", 195 "src/lib/ares_process.c", 196 ], 197 hdrs = [ 198 "ares_build.h", 199 "ares_config.h", 200 "include/ares_version.h", 201 "include/ares.h", 202 "include/ares_rules.h", 203 "include/ares_dns.h", 204 "include/ares_nameser.h", 205 "src/tools/ares_getopt.h", 206 "src/lib/ares_strsplit.h", 207 "src/lib/ares_android.h", 208 "src/lib/ares_private.h", 209 "src/lib/ares_llist.h", 210 "src/lib/ares_platform.h", 211 "src/lib/ares_ipv6.h", 212 "src/lib/config-dos.h", 213 "src/lib/bitncmp.h", 214 "src/lib/ares_strcasecmp.h", 215 "src/lib/setup_once.h", 216 "src/lib/ares_inet_net_pton.h", 217 "src/lib/ares_data.h", 218 "src/lib/ares_getenv.h", 219 "src/lib/config-win32.h", 220 "src/lib/ares_strdup.h", 221 "src/lib/ares_iphlpapi.h", 222 "src/lib/ares_setup.h", 223 "src/lib/ares_writev.h", 224 "src/lib/ares_nowarn.h", 225 ], 226 copts = [ 227 "-D_GNU_SOURCE", 228 "-D_HAS_EXCEPTIONS=0", 229 "-DHAVE_CONFIG_H", 230 ] + select({ 231 ":windows": [ 232 "-DNOMINMAX", 233 "-D_CRT_SECURE_NO_DEPRECATE", 234 "-D_CRT_NONSTDC_NO_DEPRECATE", 235 "-D_WIN32_WINNT=0x0600", 236 ], 237 "//conditions:default": [], 238 }), 239 defines = ["CARES_STATICLIB"], 240 includes = ["include", "."], 241 linkopts = select({ 242 ":windows": ["-defaultlib:ws2_32.lib"], 243 "//conditions:default": [], 244 }), 245 linkstatic = 1, 246 visibility = [ 247 "//visibility:public", 248 ], 249 alwayslink = 1, 250) 251