@@ -200,16 +200,56 @@ pub fn create(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.bui
200200 lib .root_module .addCMacro ("USE_THREADS_POSIX" , "1" );
201201 lib .root_module .addCMacro ("USE_UNIX_SOCKETS" , "1" );
202202 lib .root_module .addCMacro ("_FILE_OFFSET_BITS" , "64" );
203+
204+ const system_name = getCurlOS (target ) orelse blk : {
205+ const arch = @tagName (target .result .cpu .arch );
206+ const os = @tagName (target .result .os .tag );
207+ break :blk std .fmt .allocPrint (b .allocator , "{s}-pc-{s}" , .{ arch , os }) catch unreachable ;
208+ };
209+ const curl_os = std .fmt .allocPrint (b .allocator , "\" {s}\" " , .{system_name }) catch unreachable ;
210+ lib .root_module .addCMacro ("CURL_OS" , curl_os );
211+
203212 return lib ;
204213}
205214
215+ // define CURL_OS based on target platform
216+ // current unsupported platform : Itanium, RiscOS, OS/400
217+ fn getCurlOS (target : std.Build.ResolvedTarget ) ? []const u8 {
218+ switch (target .result .os .tag ) {
219+ .windows = > {
220+ switch (target .result .cpu .arch ) {
221+ .x86 = > return "i386-pc-win32" ,
222+ .x86_64 = > return "x86_64-pc-win32" ,
223+ .thumb = > return "thumbv7a-pc-win32" ,
224+ .aarch64 = > return "aarch64-pc-win32" ,
225+ else = > return "unknown-pc-win32" ,
226+ }
227+ },
228+ .linux = > {
229+ switch (target .result .cpu .arch ) {
230+ .x86_64 = > return "x86_64-pc-linux-gnu" ,
231+ .aarch64 = > return "aarch64-pc-linux-gnu" ,
232+ else = > return "Linux" ,
233+ }
234+ },
235+ .macos = > return "mac" ,
236+ .freebsd = > return "freebsd" ,
237+ else = > {
238+ return null ;
239+ },
240+ }
241+ }
242+
206243const srcs = &.{
244+ "lib/cw-pause.c" ,
245+ "lib/curlx/winapi.c" ,
246+ "lib/curlx/strerr.c" ,
207247 "lib/cookie.c" ,
208248 "lib/http_chunks.c" ,
209249 "lib/escape.c" ,
210- "lib/version_win32.c" ,
250+ "lib/curlx/ version_win32.c" ,
211251 "lib/url.c" ,
212- "lib/base64.c" ,
252+ "lib/curlx/ base64.c" ,
213253 "lib/mqtt.c" ,
214254 "lib/setopt.c" ,
215255 "lib/telnet.c" ,
@@ -229,57 +269,63 @@ const srcs = &.{
229269 "lib/bufref.c" ,
230270 "lib/slist.c" ,
231271 "lib/curl_trc.c" ,
272+ "lib/ratelimit.c" ,
273+ "lib/strequal.c" ,
232274 "lib/vtls/rustls.c" ,
233275 "lib/vtls/mbedtls.c" ,
234276 "lib/vtls/wolfssl.c" ,
235277 "lib/vtls/schannel.c" ,
236278 "lib/vtls/gtls.c" ,
237- "lib/vtls/sectransp.c" ,
238279 "lib/vtls/vtls.c" ,
239- "lib/vtls/mbedtls_threadlock.c" ,
240280 "lib/vtls/schannel_verify.c" ,
241281 "lib/vtls/hostcheck.c" ,
242- "lib/vtls/bearssl.c" ,
243282 "lib/vtls/openssl.c" ,
244283 "lib/vtls/x509asn1.c" ,
245284 "lib/vtls/keylog.c" ,
285+ "lib/vtls/vtls_scache.c" ,
286+ "lib/cshutdn.c" ,
287+ "lib/multi_ev.c" ,
288+ "lib/curlx/wait.c" ,
289+ "lib/uint-spbset.c" ,
290+ "lib/uint-bset.c" ,
246291 "lib/file.c" ,
247292 "lib/socks_gssapi.c" ,
248293 "lib/select.c" ,
249294 "lib/socketpair.c" ,
250295 "lib/curl_memrchr.c" ,
251296 "lib/cfilters.c" ,
252- "lib/strtok.c" ,
297+ "lib/cf-ip-happy.c" ,
298+ "lib/multi_ntfy.c" ,
299+ "lib/uint-table.c" ,
300+ "lib/curlx/strparse.c" ,
253301 "lib/version.c" ,
254- "lib/fopen.c" ,
302+ "lib/curlx/fopen.c" ,
303+ "lib/curl_fopen.c" ,
255304 "lib/http_aws_sigv4.c" ,
256305 "lib/mprintf.c" ,
257- "lib/curl_path.c" ,
258306 "lib/parsedate.c" ,
259- "lib/rename.c" ,
260307 "lib/ftplistparser.c" ,
261308 "lib/content_encoding.c" ,
262309 "lib/mime.c" ,
263310 "lib/rand.c" ,
264- "lib/curl_des.c" ,
265311 "lib/curl_ntlm_core.c" ,
266312 "lib/pop3.c" ,
267313 "lib/curl_sspi.c" ,
268314 "lib/smb.c" ,
269315 "lib/conncache.c" ,
270- "lib/inet_pton.c" ,
316+ "lib/curlx/ inet_pton.c" ,
271317 "lib/if2ip.c" ,
272318 "lib/openldap.c" ,
273319 "lib/http_digest.c" ,
274320 "lib/cf-h1-proxy.c" ,
275- "lib/asyn-thread.c" ,
321+ "lib/asyn-ares.c" ,
322+ "lib/asyn-thrdd.c" ,
276323 "lib/strerror.c" ,
277324 "lib/ftp.c" ,
278325 "lib/strdup.c" ,
326+ "lib/curlx/strcopy.c" ,
279327 "lib/memdebug.c" ,
280- "lib/speedcheck.c" ,
281328 "lib/vquic/curl_ngtcp2.c" ,
282- "lib/vquic/curl_msh3.c" ,
283329 "lib/vquic/vquic.c" ,
284330 "lib/vquic/curl_quiche.c" ,
285331 "lib/getinfo.c" ,
@@ -303,41 +349,37 @@ const srcs = &.{
303349 "lib/hostip4.c" ,
304350 "lib/curl_rtmp.c" ,
305351 "lib/amigaos.c" ,
306- "lib/share.c" ,
307- "lib/warnless.c" ,
308- "lib/hostsyn.c" ,
352+ "lib/curl_share.c" ,
353+ "lib/curlx/warnless.c" ,
309354 "lib/md5.c" ,
310- "lib/strtoofft.c" ,
311355 "lib/altsvc.c" ,
312356 "lib/formdata.c" ,
313- "lib/dynbuf.c" ,
357+ "lib/curlx/ dynbuf.c" ,
314358 "lib/curl_addrinfo.c" ,
315- "lib/hostasyn.c" ,
316359 "lib/doh.c" ,
317360 "lib/request.c" ,
318361 "lib/cw-out.c" ,
319362 "lib/curl_sha512_256.c" ,
320363 "lib/vtls/cipher_suite.c" ,
321364 "lib/easygetopt.c" ,
322365 "lib/ldap.c" ,
323- "lib/nonblock.c" ,
366+ "lib/curlx/ nonblock.c" ,
324367 "lib/idn.c" ,
325368 "lib/pingpong.c" ,
326369 "lib/imap.c" ,
327370 "lib/vssh/libssh.c" ,
328- "lib/vssh/wolfssh.c" ,
329371 "lib/vssh/libssh2.c" ,
372+ "lib/vssh/vssh.c" ,
330373 "lib/splay.c" ,
331- "lib/krb5.c" ,
332374 "lib/progress.c" ,
333375 "lib/cf-haproxy.c" ,
334376 "lib/easyoptions.c" ,
335377 "lib/curl_range.c" ,
336378 "lib/curl_endian.c" ,
337379 "lib/http_proxy.c" ,
338- "lib/inet_ntop.c" ,
339- "lib/timeval.c" ,
340- "lib/asyn-ares .c" ,
380+ "lib/curlx/ inet_ntop.c" ,
381+ "lib/curlx/ timeval.c" ,
382+ "lib/asyn-base .c" ,
341383 "lib/rtsp.c" ,
342384 "lib/sha256.c" ,
343385 "lib/curl_threads.c" ,
@@ -355,19 +397,18 @@ const srcs = &.{
355397 "lib/psl.c" ,
356398 "lib/ws.c" ,
357399 "lib/hostip6.c" ,
358- "lib/curl_multibyte .c" ,
400+ "lib/curlx/multibyte .c" ,
359401 "lib/netrc.c" ,
360402 "lib/llist.c" ,
361403 "lib/urlapi.c" ,
362404 "lib/strcase.c" ,
363405 "lib/sendf.c" ,
364- "lib/timediff.c" ,
406+ "lib/curlx/ timediff.c" ,
365407 "lib/http.c" ,
366408 "lib/cf-h2-proxy.c" ,
367409 "lib/socks.c" ,
368410 "lib/http_negotiate.c" ,
369411 "lib/transfer.c" ,
370- "lib/c-hyper.c" ,
371412 "lib/hmac.c" ,
372413 "lib/fileinfo.c" ,
373414};
0 commit comments