Skip to content

Latest commit

 

History

History
77 lines (57 loc) · 2.47 KB

README.md

File metadata and controls

77 lines (57 loc) · 2.47 KB

CI

curl

This is curl, packaged for Zig.

Installation

Warning

Curl depends on https://github.com/allyourcodebase/openssl which currently doesn't work on macOS. Consider using a different ssl implementation.

Standalone library (libcurl) and command-line tool (curl)

git clone https://github.com/allyourcodebase/curl
cd curl
zig build -Doptimize=ReleaseFast

The library and CLI tool can be found in the newly created ./zig-out directory. The zig build run build step may be used to directly run curl.

Avoid system dependencies

By default, curl requires some system dependencies that have not been ported to the zig build system yet. These dependencies may be either manually installed on the host system or disabled with the following build command:

# Windows
zig build -Doptimize=ReleaseFast -Dlibpsl=false -Dlibssh2=false -Dlibidn2=false -Dnghttp2=false
# Posix
zig build -Doptimize=ReleaseFast -Dlibpsl=false -Dlibssh2=false -Dlibidn2=false -Dnghttp2=false -Ddisable-ldap

Zig Build System

First, update your build.zig.zon:

# Initialize a `zig build` project if you haven't already
zig init
zig fetch --save git+https://github.com/allyourcodebase/curl.git

You can then import curl in your build.zig with:

const curl_dependency = b.dependency("curl", .{
    .target = target,
    .optimize = optimize,
});

// A custom `artifact` function is provided because the build system
// provides no way to differentiate between the library (libcurl) and
// the command-line tool (curl) since they are both named "curl" in
// the build system.
// See https://github.com/ziglang/zig/issues/20377
const curlExe = @import("curl").artifact(curl_dependency, .exe);
const libCurl = @import("curl").artifact(curl_dependency, .lib);

your_exe.root_module.linkLibrary(libCurl);

Avoid system dependencies

By default, curl requires some system dependencies that have not been ported to the zig build system yet. These dependencies may be either manually installed on the host system or disabled with the following change to the build.zig:

const curl_dependency = b.dependency("curl", .{
    .target = target,
    .optimize = optimize,
    .libpsl = false,
    .libssh2 = false,
    .libidn2 = false,
    .nghttp2 = false,
    .@"disable-ldap" = true,
});