1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
|
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const openssl = b.dependency("openssl", .{
.target = target,
.optimize = optimize,
});
const curl_c = b.dependency("curl", .{
.target = target,
.optimize = optimize,
});
const curl = b.addStaticLibrary(.{
.name = "curl",
.target = target,
.optimize = optimize,
});
curl.linkLibC();
curl.linkLibrary(openssl.artifact("ssl"));
curl.linkLibrary(openssl.artifact("crypto"));
curl.root_module.addCMacro("BUILDING_LIBCURL", "");
curl.root_module.addCMacro("CURL_STATICLIB", "1");
curl.root_module.addCMacro("USE_OPENSSL", "1");
curl.root_module.addCMacro("CURL_DISABLE_ALTSVC", "1");
curl.root_module.addCMacro("CURL_DISABLE_COOKIES", "1");
curl.root_module.addCMacro("CURL_DISABLE_BASIC_AUTH", "1");
curl.root_module.addCMacro("CURL_DISABLE_BEARER_AUTH", "1");
curl.root_module.addCMacro("CURL_DISABLE_DIGEST_AUTH", "1");
curl.root_module.addCMacro("CURL_DISABLE_KERBEROS_AUTH", "1");
curl.root_module.addCMacro("CURL_DISABLE_NEGOTIATE_AUTH", "1");
curl.root_module.addCMacro("CURL_DISABLE_AWS", "1");
curl.root_module.addCMacro("CURL_DISABLE_DICT", "1");
curl.root_module.addCMacro("CURL_DISABLE_DOH", "1");
curl.root_module.addCMacro("CURL_DISABLE_FILE", "1");
curl.root_module.addCMacro("CURL_DISABLE_FORM_API", "1");
curl.root_module.addCMacro("CURL_DISABLE_FTP", "1");
curl.root_module.addCMacro("CURL_DISABLE_GETOPTIONS", "1");
curl.root_module.addCMacro("CURL_DISABLE_GOPHER", "1");
// curl.root_module.addCMacro("CURL_DISABLE_HEADERS_API", "1");
// curl.root_module.addCMacro("CURL_DISABLE_HSTS", "1");
// curl.root_module.addCMacro("CURL_DISABLE_HTTP", "1");
curl.root_module.addCMacro("CURL_DISABLE_IMAP", "1");
curl.root_module.addCMacro("CURL_DISABLE_LDAP", "1");
curl.root_module.addCMacro("CURL_DISABLE_LDAPS", "1");
curl.root_module.addCMacro("CURL_DISABLE_LIBCURL_OPTION", "1");
// curl.root_module.addCMacro("CURL_DISABLE_MIME", "1");
// curl.root_module.addCMacro("CURL_DISABLE_BINDLOCAL", "1");
curl.root_module.addCMacro("CURL_DISABLE_MQTT", "1");
curl.root_module.addCMacro("CURL_DISABLE_NETRC", "1");
curl.root_module.addCMacro("CURL_DISABLE_NTLM", "1");
curl.root_module.addCMacro("CURL_DISABLE_PARSEDATE", "1");
curl.root_module.addCMacro("CURL_DISABLE_POP3", "1");
curl.root_module.addCMacro("CURL_DISABLE_PROGRESS_METER", "1");
curl.root_module.addCMacro("CURL_DISABLE_PROXY", "1");
curl.root_module.addCMacro("CURL_DISABLE_RTSP", "1");
curl.root_module.addCMacro("CURL_DISABLE_SMB", "1");
curl.root_module.addCMacro("CURL_DISABLE_SMTP", "1");
curl.root_module.addCMacro("CURL_DISABLE_SOCKETPAIR", "1");
curl.root_module.addCMacro("CURL_DISABLE_TELNET", "1");
curl.root_module.addCMacro("CURL_DISABLE_TFTP", "1");
curl.root_module.addCMacro("CURL_DISABLE_VERBOSE_STRINGS", "1");
// curl.root_module.addCMacro("CURL_DISABLE_OPENSSL_AUTO_LOAD_CONFIG", "1");
if (target.result.os.tag == .windows) {
curl.linkSystemLibrary("bcrypt");
} else {
curl.root_module.addCMacro("CURL_EXTERN_SYMBOL", "__attribute__ ((__visibility__ (\"default\"))");
const isDarwin = target.result.os.tag.isDarwin();
if (!isDarwin)
curl.root_module.addCMacro("ENABLE_IPV6", "1");
curl.root_module.addCMacro("HAVE_ALARM", "1");
curl.root_module.addCMacro("HAVE_ALLOCA_H", "1");
curl.root_module.addCMacro("HAVE_ARPA_INET_H", "1");
curl.root_module.addCMacro("HAVE_ARPA_TFTP_H", "1");
curl.root_module.addCMacro("HAVE_ASSERT_H", "1");
curl.root_module.addCMacro("HAVE_BASENAME", "1");
curl.root_module.addCMacro("HAVE_BOOL_T", "1");
curl.root_module.addCMacro("HAVE_BUILTIN_AVAILABLE", "1");
curl.root_module.addCMacro("HAVE_CLOCK_GETTIME_MONOTONIC", "1");
curl.root_module.addCMacro("HAVE_DLFCN_H", "1");
curl.root_module.addCMacro("HAVE_ERRNO_H", "1");
curl.root_module.addCMacro("HAVE_FCNTL", "1");
curl.root_module.addCMacro("HAVE_FCNTL_H", "1");
curl.root_module.addCMacro("HAVE_FCNTL_O_NONBLOCK", "1");
curl.root_module.addCMacro("HAVE_FREEADDRINFO", "1");
curl.root_module.addCMacro("HAVE_FTRUNCATE", "1");
curl.root_module.addCMacro("HAVE_GETADDRINFO", "1");
curl.root_module.addCMacro("HAVE_GETEUID", "1");
curl.root_module.addCMacro("HAVE_GETPPID", "1");
curl.root_module.addCMacro("HAVE_GETHOSTBYNAME", "1");
if (!isDarwin)
curl.root_module.addCMacro("HAVE_GETHOSTBYNAME_R", "1");
curl.root_module.addCMacro("HAVE_GETHOSTBYNAME_R_6", "1");
curl.root_module.addCMacro("HAVE_GETHOSTNAME", "1");
curl.root_module.addCMacro("HAVE_GETPPID", "1");
curl.root_module.addCMacro("HAVE_GETPROTOBYNAME", "1");
curl.root_module.addCMacro("HAVE_GETPEERNAME", "1");
curl.root_module.addCMacro("HAVE_GETSOCKNAME", "1");
curl.root_module.addCMacro("HAVE_IF_NAMETOINDEX", "1");
curl.root_module.addCMacro("HAVE_GETPWUID", "1");
curl.root_module.addCMacro("HAVE_GETPWUID_R", "1");
curl.root_module.addCMacro("HAVE_GETRLIMIT", "1");
curl.root_module.addCMacro("HAVE_GETTIMEOFDAY", "1");
curl.root_module.addCMacro("HAVE_GMTIME_R", "1");
curl.root_module.addCMacro("HAVE_IFADDRS_H", "1");
curl.root_module.addCMacro("HAVE_INET_ADDR", "1");
curl.root_module.addCMacro("HAVE_INET_PTON", "1");
curl.root_module.addCMacro("HAVE_SA_FAMILY_T", "1");
curl.root_module.addCMacro("HAVE_INTTYPES_H", "1");
curl.root_module.addCMacro("HAVE_IOCTL", "1");
curl.root_module.addCMacro("HAVE_IOCTL_FIONBIO", "1");
curl.root_module.addCMacro("HAVE_IOCTL_SIOCGIFADDR", "1");
curl.root_module.addCMacro("HAVE_LDAP_URL_PARSE", "1");
curl.root_module.addCMacro("HAVE_LIBGEN_H", "1");
curl.root_module.addCMacro("HAVE_IDN2_H", "1");
curl.root_module.addCMacro("HAVE_LL", "1");
curl.root_module.addCMacro("HAVE_LOCALE_H", "1");
curl.root_module.addCMacro("HAVE_LOCALTIME_R", "1");
curl.root_module.addCMacro("HAVE_LONGLONG", "1");
curl.root_module.addCMacro("HAVE_MALLOC_H", "1");
curl.root_module.addCMacro("HAVE_MEMORY_H", "1");
if (!isDarwin)
curl.root_module.addCMacro("HAVE_MSG_NOSIGNAL", "1");
curl.root_module.addCMacro("HAVE_NETDB_H", "1");
curl.root_module.addCMacro("HAVE_NETINET_IN_H", "1");
curl.root_module.addCMacro("HAVE_NETINET_TCP_H", "1");
if (target.result.os.tag == .linux)
curl.root_module.addCMacro("HAVE_LINUX_TCP_H", "1");
curl.root_module.addCMacro("HAVE_NET_IF_H", "1");
curl.root_module.addCMacro("HAVE_PIPE", "1");
curl.root_module.addCMacro("HAVE_POLL", "1");
curl.root_module.addCMacro("HAVE_POLL_FINE", "1");
curl.root_module.addCMacro("HAVE_POLL_H", "1");
curl.root_module.addCMacro("HAVE_POSIX_STRERROR_R", "1");
curl.root_module.addCMacro("HAVE_PTHREAD_H", "1");
curl.root_module.addCMacro("HAVE_PWD_H", "1");
curl.root_module.addCMacro("HAVE_RECV", "1");
curl.root_module.addCMacro("HAVE_SELECT", "1");
curl.root_module.addCMacro("HAVE_SEND", "1");
curl.root_module.addCMacro("HAVE_FSETXATTR", "1");
curl.root_module.addCMacro("HAVE_FSETXATTR_5", "1");
curl.root_module.addCMacro("HAVE_SETJMP_H", "1");
curl.root_module.addCMacro("HAVE_SETLOCALE", "1");
curl.root_module.addCMacro("HAVE_SETRLIMIT", "1");
curl.root_module.addCMacro("HAVE_SETSOCKOPT", "1");
curl.root_module.addCMacro("HAVE_SIGACTION", "1");
curl.root_module.addCMacro("HAVE_SIGINTERRUPT", "1");
curl.root_module.addCMacro("HAVE_SIGNAL", "1");
curl.root_module.addCMacro("HAVE_SIGNAL_H", "1");
curl.root_module.addCMacro("HAVE_SIGSETJMP", "1");
curl.root_module.addCMacro("HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID", "1");
curl.root_module.addCMacro("HAVE_SOCKET", "1");
curl.root_module.addCMacro("HAVE_STDBOOL_H", "1");
curl.root_module.addCMacro("HAVE_STDINT_H", "1");
curl.root_module.addCMacro("HAVE_STDIO_H", "1");
curl.root_module.addCMacro("HAVE_STDLIB_H", "1");
curl.root_module.addCMacro("HAVE_STRCASECMP", "1");
curl.root_module.addCMacro("HAVE_STRDUP", "1");
curl.root_module.addCMacro("HAVE_STRERROR_R", "1");
curl.root_module.addCMacro("HAVE_STRINGS_H", "1");
curl.root_module.addCMacro("HAVE_STRING_H", "1");
curl.root_module.addCMacro("HAVE_STRSTR", "1");
curl.root_module.addCMacro("HAVE_STRTOK_R", "1");
curl.root_module.addCMacro("HAVE_STRTOLL", "1");
curl.root_module.addCMacro("HAVE_STRUCT_SOCKADDR_STORAGE", "1");
curl.root_module.addCMacro("HAVE_STRUCT_TIMEVAL", "1");
curl.root_module.addCMacro("HAVE_SYS_IOCTL_H", "1");
curl.root_module.addCMacro("HAVE_SYS_PARAM_H", "1");
curl.root_module.addCMacro("HAVE_SYS_POLL_H", "1");
curl.root_module.addCMacro("HAVE_SYS_RESOURCE_H", "1");
curl.root_module.addCMacro("HAVE_SYS_SELECT_H", "1");
curl.root_module.addCMacro("HAVE_SYS_SOCKET_H", "1");
curl.root_module.addCMacro("HAVE_SYS_STAT_H", "1");
curl.root_module.addCMacro("HAVE_SYS_TIME_H", "1");
curl.root_module.addCMacro("HAVE_SYS_TYPES_H", "1");
curl.root_module.addCMacro("HAVE_SYS_UIO_H", "1");
curl.root_module.addCMacro("HAVE_SYS_UN_H", "1");
curl.root_module.addCMacro("HAVE_TERMIOS_H", "1");
curl.root_module.addCMacro("HAVE_TERMIO_H", "1");
curl.root_module.addCMacro("HAVE_TIME_H", "1");
curl.root_module.addCMacro("HAVE_UNAME", "1");
curl.root_module.addCMacro("HAVE_UNISTD_H", "1");
curl.root_module.addCMacro("HAVE_UTIME", "1");
curl.root_module.addCMacro("HAVE_UTIMES", "1");
curl.root_module.addCMacro("HAVE_UTIME_H", "1");
curl.root_module.addCMacro("HAVE_VARIADIC_MACROS_C99", "1");
curl.root_module.addCMacro("HAVE_VARIADIC_MACROS_GCC", "1");
curl.root_module.addCMacro("OS", "\"Linux\"");
curl.root_module.addCMacro("RANDOM_FILE", "\"/dev/urandom\"");
curl.root_module.addCMacro("RECV_TYPE_ARG1", "int");
curl.root_module.addCMacro("RECV_TYPE_ARG2", "void *");
curl.root_module.addCMacro("RECV_TYPE_ARG3", "size_t");
curl.root_module.addCMacro("RECV_TYPE_ARG4", "int");
curl.root_module.addCMacro("RECV_TYPE_RETV", "ssize_t");
curl.root_module.addCMacro("SEND_QUAL_ARG2", "const");
curl.root_module.addCMacro("SEND_TYPE_ARG1", "int");
curl.root_module.addCMacro("SEND_TYPE_ARG2", "void *");
curl.root_module.addCMacro("SEND_TYPE_ARG3", "size_t");
curl.root_module.addCMacro("SEND_TYPE_ARG4", "int");
curl.root_module.addCMacro("SEND_TYPE_RETV", "ssize_t");
curl.root_module.addCMacro("SIZEOF_INT", "4");
curl.root_module.addCMacro("SIZEOF_SHORT", "2");
curl.root_module.addCMacro("SIZEOF_LONG", "8");
curl.root_module.addCMacro("SIZEOF_OFF_T", "8");
curl.root_module.addCMacro("SIZEOF_CURL_OFF_T", "8");
curl.root_module.addCMacro("SIZEOF_SIZE_T", "8");
curl.root_module.addCMacro("SIZEOF_TIME_T", "8");
curl.root_module.addCMacro("STDC_HEADERS", "1");
curl.root_module.addCMacro("TIME_WITH_SYS_TIME", "1");
curl.root_module.addCMacro("USE_THREADS_POSIX", "1");
curl.root_module.addCMacro("USE_UNIX_SOCKETS", "");
curl.root_module.addCMacro("_FILE_OFFSET_BITS", "64");
}
curl.addIncludePath(curl_c.path("lib"));
curl.addIncludePath(curl_c.path("include"));
curl.addCSourceFiles(.{
.root = curl_c.path("lib"),
.files = &.{
"vauth/krb5_sspi.c",
"vauth/spnego_sspi.c",
"vauth/ntlm.c",
"vauth/gsasl.c",
"vauth/spnego_gssapi.c",
"vauth/ntlm_sspi.c",
"vauth/vauth.c",
"vauth/oauth2.c",
"vauth/cram.c",
"vauth/cleartext.c",
"vauth/krb5_gssapi.c",
"vauth/digest.c",
"vauth/digest_sspi.c",
"vquic/vquic.c",
"vquic/curl_ngtcp2.c",
// "vquic/curl_osslq.c",
// "vquic/vquic-tls.c",
"vquic/curl_quiche.c",
"vquic/curl_msh3.c",
"vssh/libssh.c",
"vssh/libssh2.c",
"vssh/wolfssh.c",
// "vtls/mbedtls.c",
"vtls/gtls.c",
"vtls/bearssl.c",
"vtls/hostcheck.c",
"vtls/rustls.c",
"vtls/schannel.c",
"vtls/sectransp.c",
"vtls/schannel_verify.c",
"vtls/vtls.c",
"vtls/cipher_suite.c",
"vtls/keylog.c",
"vtls/openssl.c",
"vtls/wolfssl.c",
"vtls/mbedtls_threadlock.c",
"vtls/x509asn1.c",
"strcase.c",
"easyoptions.c",
"dict.c",
"llist.c",
"mprintf.c",
"pingpong.c",
"socks_gssapi.c",
"psl.c",
"url.c",
"timeval.c",
"curl_get_line.c",
"hmac.c",
"md4.c",
"curl_range.c",
"idn.c",
"hostsyn.c",
"strtok.c",
"curl_threads.c",
"if2ip.c",
"c-hyper.c",
"cf-socket.c",
"http_negotiate.c",
"doh.c",
"curl_endian.c",
"formdata.c",
"easygetopt.c",
"cf-https-connect.c",
"timediff.c",
"dynbuf.c",
"rand.c",
"http2.c",
"request.c",
"dynhds.c",
"content_encoding.c",
"hostip.c",
"escape.c",
"version_win32.c",
"easy.c",
"rename.c",
"share.c",
"slist.c",
"inet_pton.c",
"tftp.c",
"mqtt.c",
"fopen.c",
"socks.c",
"parsedate.c",
"curl_trc.c",
"warnless.c",
"cf-haproxy.c",
"cfilters.c",
"curl_sha512_256.c",
"system_win32.c",
"transfer.c",
"curl_rtmp.c",
"nonblock.c",
"select.c",
"hostip4.c",
"http1.c",
"urlapi.c",
"openldap.c",
"getenv.c",
"hash.c",
"bufq.c",
"http_proxy.c",
"krb5.c",
"multi.c",
"strdup.c",
"mime.c",
"socks_sspi.c",
"smtp.c",
"http_aws_sigv4.c",
"curl_addrinfo.c",
"cf-h2-proxy.c",
"memdebug.c",
"progress.c",
"curl_ntlm_core.c",
"curl_path.c",
"hostasyn.c",
"pop3.c",
"noproxy.c",
"gopher.c",
"rtsp.c",
"curl_gethostname.c",
"curl_des.c",
"base64.c",
"splay.c",
"http.c",
"curl_sspi.c",
"http_chunks.c",
"telnet.c",
"amigaos.c",
"fileinfo.c",
"version.c",
"ldap.c",
"bufref.c",
"curl_sasl.c",
"netrc.c",
"socketpair.c",
"strerror.c",
"curl_multibyte.c",
"altsvc.c",
"conncache.c",
"curl_memrchr.c",
"dllmain.c",
"smb.c",
"sha256.c",
"connect.c",
"ws.c",
"ftp.c",
"strtoofft.c",
"md5.c",
"file.c",
"http_digest.c",
"asyn-thread.c",
"cf-h1-proxy.c",
"hsts.c",
"asyn-ares.c",
"imap.c",
"headers.c",
"macos.c",
"cookie.c",
"hostip6.c",
"sendf.c",
"ftplistparser.c",
"http_ntlm.c",
"setopt.c",
"getinfo.c",
"speedcheck.c",
"inet_ntop.c",
"cw-out.c",
"curl_gssapi.c",
"curl_fnmatch.c",
},
.flags = &.{
"-fno-sanitize=all",
"-std=gnu89",
"-Wno-unknown-warning-option",
"-Wswitch-default",
"-Wno-parentheses-equality",
"-Wno-language-extension-token",
"-Wno-extended-offsetof",
"-Wconditional-uninitialized",
"-Wincompatible-pointer-types-discards-qualifiers",
"-Wmissing-variable-declarations",
"-Wno-int-conversion",
},
});
curl.installHeadersDirectory(curl_c.path("include/curl"), "curl", .{});
b.installArtifact(curl);
}
|