Skip to content

Commit 5f9fdaa

Browse files
committed
initial commit
0 parents  commit 5f9fdaa

File tree

7 files changed

+1665
-0
lines changed

7 files changed

+1665
-0
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.zig text eol=lf
2+
*.zon text eol=lf

.github/workflows/ci.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
workflow_dispatch:
11+
12+
jobs:
13+
build:
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
zig-version: [0.14.0]
18+
os: [ubuntu-latest, macos-latest, windows-latest]
19+
runs-on: ${{ matrix.os }}
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
24+
- name: Setup Zig
25+
uses: mlugg/setup-zig@v1
26+
with:
27+
version: ${{ matrix.zig-version }}
28+
29+
- name: Check Formatting
30+
run: zig fmt --ast-check --check .
31+
32+
- name: Build (Windows)
33+
if: matrix.os == 'windows-latest'
34+
run: zig build -Dlibpsl=false -Dlibssh2=false -Dlibidn2=false -Dnghttp2=false --summary all
35+
36+
- name: Build (MacOS)
37+
if: matrix.os == 'macos-latest'
38+
run: zig build -Duse-openssl=false -Dlibpsl=false -Dlibssh2=false -Dlibidn2=false -Dnghttp2=false --summary all
39+
40+
- name: Build (Linux)
41+
if: matrix.os == 'ubuntu-latest'
42+
run: zig build -Dlibpsl=false -Dlibssh2=false -Dlibidn2=false -Dnghttp2=false -Ddisable-ldap --summary all

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.zig-cache
2+
zig-cache
3+
zig-out

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (Expat)
2+
3+
Copyright (c) contributors
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
[![CI](https://github.com/allyourcodebase/curl/actions/workflows/ci.yaml/badge.svg)](https://github.com/allyourcodebase/curl/actions)
2+
3+
# curl
4+
5+
This is [curl](https://github.com/curl/curl), packaged for [Zig](https://ziglang.org/).
6+
7+
## Installation
8+
9+
> [!WARNING]
10+
>
11+
> Curl depends on https://github.com/allyourcodebase/openssl which currently doesn't work on macOS. Consider using a different openssl implementation.
12+
13+
### Standalone library (libcurl) and command-line tool (curl)
14+
15+
```bash
16+
git clone https://github.com/allyourcodebase/curl
17+
cd curl
18+
zig build -Doptimize=ReleaseFast
19+
```
20+
21+
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.
22+
23+
#### Avoid system dependencies
24+
25+
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:
26+
27+
```bash
28+
# Windows
29+
zig build -Doptimize=ReleaseFast -Dlibpsl=false -Dlibssh2=false -Dlibidn2=false -Dnghttp2=false
30+
# Posix
31+
zig build -Doptimize=ReleaseFast -Dlibpsl=false -Dlibssh2=false -Dlibidn2=false -Dnghttp2=false -Ddisable-ldap
32+
```
33+
34+
### Zig Build System
35+
36+
First, update your `build.zig.zon`:
37+
38+
```
39+
# Initialize a `zig build` project if you haven't already
40+
zig init
41+
zig fetch --save git+https://github.com/allyourcodebase/curl.git
42+
```
43+
44+
You can then import curl in your `build.zig` with:
45+
46+
```zig
47+
const curl_dependency = b.dependency("curl", .{
48+
.target = target,
49+
.optimize = optimize,
50+
});
51+
52+
// A custom `artifact` function is provided because the build system
53+
// provides no way to differentiate between the library (libcurl) and
54+
// the command-line tool (curl) since they are both named "curl" in
55+
// the build system.
56+
// See https://github.com/ziglang/zig/issues/20377
57+
const curlExe = @import("curl").artifact(curl_dependency, .exe);
58+
const libCurl = @import("curl").artifact(curl_dependency, .lib);
59+
60+
your_exe.root_module.linkLibrary(libCurl);
61+
```
62+
63+
#### Avoid system dependencies
64+
65+
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`:
66+
67+
```zig
68+
const curl_dependency = b.dependency("curl", .{
69+
.target = target,
70+
.optimize = optimize,
71+
.libpsl = false,
72+
.libssh2 = false,
73+
.libidn2 = false,
74+
.nghttp2 = false,
75+
.disable-ldap = true,
76+
});
77+
```

0 commit comments

Comments
 (0)