Imported Upstream version 1.21.0
[platform/upstream/grpc.git] / third_party / cares / cares.BUILD
1 config_setting(
2     name = "darwin",
3     values = {"cpu": "darwin"},
4 )
5
6 config_setting(
7     name = "darwin_x86_64",
8     values = {"cpu": "darwin_x86_64"},
9 )
10
11 config_setting(
12     name = "windows",
13     values = {"cpu": "x64_windows"},
14 )
15
16 # Android is not officially supported through C++.
17 # This just helps with the build for now.
18 config_setting(
19     name = "android",
20     values = {
21         "crosstool_top": "//external:android/crosstool",
22     },
23 )
24
25 # iOS is not officially supported through C++.
26 # This just helps with the build for now.
27 config_setting(
28     name = "ios_x86_64",
29     values = {"cpu": "ios_x86_64"},
30 )
31
32 config_setting(
33     name = "ios_armv7",
34     values = {"cpu": "ios_armv7"},
35 )
36
37 config_setting(
38     name = "ios_armv7s",
39     values = {"cpu": "ios_armv7s"},
40 )
41
42 config_setting(
43     name = "ios_arm64",
44     values = {"cpu": "ios_arm64"},
45 )
46
47 genrule(
48     name = "ares_build_h",
49     srcs = ["@com_github_grpc_grpc//third_party/cares:ares_build.h"],
50     outs = ["ares_build.h"],
51     cmd = "cat $< > $@",
52 )
53
54 genrule(
55     name = "ares_config_h",
56     srcs = select({
57         ":ios_x86_64": ["@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h"],
58         ":ios_armv7": ["@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h"],
59         ":ios_armv7s": ["@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h"],
60         ":ios_arm64": ["@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h"],
61         ":darwin": ["@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h"],
62         ":darwin_x86_64": ["@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h"],
63         ":windows": ["@com_github_grpc_grpc//third_party/cares:config_windows/ares_config.h"],
64         ":android": ["@com_github_grpc_grpc//third_party/cares:config_android/ares_config.h"],
65         "//conditions:default": ["@com_github_grpc_grpc//third_party/cares:config_linux/ares_config.h"],
66     }),
67     outs = ["ares_config.h"],
68     cmd = "cat $< > $@",
69 )
70
71 cc_library(
72     name = "ares",
73     srcs = [
74         "ares__close_sockets.c",
75         "ares__get_hostent.c",
76         "ares__read_line.c",
77         "ares__timeval.c",
78         "ares_cancel.c",
79         "ares_create_query.c",
80         "ares_data.c",
81         "ares_destroy.c",
82         "ares_expand_name.c",
83         "ares_expand_string.c",
84         "ares_fds.c",
85         "ares_free_hostent.c",
86         "ares_free_string.c",
87         "ares_getenv.c",
88         "ares_gethostbyaddr.c",
89         "ares_gethostbyname.c",
90         "ares_getnameinfo.c",
91         "ares_getopt.c",
92         "ares_getsock.c",
93         "ares_init.c",
94         "ares_library_init.c",
95         "ares_llist.c",
96         "ares_mkquery.c",
97         "ares_nowarn.c",
98         "ares_options.c",
99         "ares_parse_a_reply.c",
100         "ares_parse_aaaa_reply.c",
101         "ares_parse_mx_reply.c",
102         "ares_parse_naptr_reply.c",
103         "ares_parse_ns_reply.c",
104         "ares_parse_ptr_reply.c",
105         "ares_parse_soa_reply.c",
106         "ares_parse_srv_reply.c",
107         "ares_parse_txt_reply.c",
108         "ares_platform.c",
109         "ares_process.c",
110         "ares_query.c",
111         "ares_search.c",
112         "ares_send.c",
113         "ares_strcasecmp.c",
114         "ares_strdup.c",
115         "ares_strsplit.c",
116         "ares_strerror.c",
117         "ares_timeout.c",
118         "ares_version.c",
119         "ares_writev.c",
120         "bitncmp.c",
121         "inet_net_pton.c",
122         "inet_ntop.c",
123         "windows_port.c",
124     ],
125     hdrs = [
126         "ares.h",
127         "ares_build.h",
128         "ares_config.h",
129         "ares_data.h",
130         "ares_dns.h",
131         "ares_getenv.h",
132         "ares_getopt.h",
133         "ares_inet_net_pton.h",
134         "ares_iphlpapi.h",
135         "ares_ipv6.h",
136         "ares_library_init.h",
137         "ares_llist.h",
138         "ares_nowarn.h",
139         "ares_platform.h",
140         "ares_private.h",
141         "ares_rules.h",
142         "ares_setup.h",
143         "ares_strcasecmp.h",
144         "ares_strdup.h",
145         "ares_strsplit.h",
146         "ares_version.h",
147         "ares_writev.h",
148         "bitncmp.h",
149         "config-win32.h",
150         "nameser.h",
151         "setup_once.h",
152     ],
153     copts = [
154         "-D_GNU_SOURCE",
155         "-D_HAS_EXCEPTIONS=0",
156         "-DHAVE_CONFIG_H",
157     ] + select({
158         ":windows": [
159             "-DNOMINMAX",
160             "-D_CRT_SECURE_NO_DEPRECATE",
161             "-D_CRT_NONSTDC_NO_DEPRECATE",
162             "-D_WIN32_WINNT=0x0600",
163         ],
164         "//conditions:default": [],
165     }),
166     defines = ["CARES_STATICLIB"],
167     includes = ["."],
168     linkopts = select({
169         ":windows": ["-defaultlib:ws2_32.lib"],
170         "//conditions:default": [],
171     }),
172     linkstatic = 1,
173     visibility = [
174         "//visibility:public",
175     ],
176     alwayslink = 1,
177 )