Skip to content

Commit 674679d

Browse files
committed
build: support 0.16.0-dev
the following methods are now applied on the module and not the compile step: - addCSourceFiles - linkLibrary - linkSystemLibrary And linkLibC doesn't exist anymore, so modify the .link_libc member variable directly
1 parent 43595de commit 674679d

File tree

3 files changed

+82
-73
lines changed

3 files changed

+82
-73
lines changed

.github/workflows/ci.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ jobs:
1616
os: [macos-latest, windows-latest]
1717
include:
1818
- zig-version: "0.14.1"
19-
check-format: true
2019
os: ubuntu-latest
21-
build-options: "-Dbuild-apps"
2220

2321
- zig-version: "master"
22+
check-format: true
23+
build-options: "-Dbuild-apps"
2424
os: ubuntu-latest
2525

2626
runs-on: ${{ matrix.os }}
2727
steps:
2828
- name: Checkout
29-
uses: actions/checkout@v4
29+
uses: actions/checkout@v6
3030

3131
- name: Setup Zig
3232
uses: mlugg/setup-zig@v2

build.zig

Lines changed: 63 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -59,40 +59,40 @@ pub fn build(b: *std.Build) !void {
5959
};
6060

6161
const crypto_srcroot = upstream.path("crypto");
62-
libressl_common.libcrypto.addCSourceFiles(.{
62+
libressl_common.libcrypto.root_module.addCSourceFiles(.{
6363
.root = crypto_srcroot,
6464
.files = libcrypto_sources,
6565
.flags = cflags,
6666
});
6767

6868
const ssl_srcroot = upstream.path("ssl");
69-
libressl_common.libssl.addCSourceFiles(.{
69+
libressl_common.libssl.root_module.addCSourceFiles(.{
7070
.root = ssl_srcroot,
7171
.files = libssl_sources,
7272
.flags = cflags,
7373
});
7474

7575
const tls_srcroot = upstream.path("tls");
76-
libressl_common.libtls.addCSourceFiles(.{
76+
libressl_common.libtls.root_module.addCSourceFiles(.{
7777
.root = tls_srcroot,
7878
.files = libtls_sources,
7979
.flags = cflags,
8080
});
8181

8282
const nc_srcroot = upstream.path("apps/nc");
83-
libressl_common.apps.nc.addCSourceFiles(.{
83+
libressl_common.apps.nc.root_module.addCSourceFiles(.{
8484
.root = nc_srcroot,
8585
.files = nc_app_sources,
8686
.flags = cflags,
8787
});
8888
const ocspcheck_srcroot = upstream.path("apps/ocspcheck");
89-
libressl_common.apps.ocspcheck.addCSourceFiles(.{
89+
libressl_common.apps.ocspcheck.root_module.addCSourceFiles(.{
9090
.root = ocspcheck_srcroot,
9191
.files = ocspcheck_app_sources,
9292
.flags = cflags,
9393
});
9494
const openssl_srcroot = upstream.path("apps/openssl");
95-
libressl_common.apps.openssl.addCSourceFiles(.{
95+
libressl_common.apps.openssl.root_module.addCSourceFiles(.{
9696
.root = openssl_srcroot,
9797
.files = openssl_app_sources,
9898
.flags = cflags,
@@ -102,7 +102,7 @@ pub fn build(b: *std.Build) !void {
102102
if (build_asm) {
103103
if (tinfo.ofmt == .elf) {
104104
if (tinfo.cpu.arch == .x86_64) {
105-
libressl_common.libcrypto.addCSourceFiles(.{
105+
libressl_common.libcrypto.root_module.addCSourceFiles(.{
106106
.root = crypto_srcroot,
107107
.files = libcrypto_elf_x86_64_asm,
108108
.flags = cflags,
@@ -124,12 +124,12 @@ pub fn build(b: *std.Build) !void {
124124
libressl_common.libcrypto.root_module.addCMacro("OPENSSL_CPUID_OBJ", "");
125125
libressl_common.libcrypto.root_module.addCMacro("HAVE_GNU_STACK", "");
126126
} else if (tinfo.cpu.arch == .arm) {
127-
libressl_common.libcrypto.addCSourceFiles(.{
127+
libressl_common.libcrypto.root_module.addCSourceFiles(.{
128128
.root = crypto_srcroot,
129129
.files = libcrypto_elf_armv4_asm,
130130
.flags = cflags,
131131
});
132-
libressl_common.libcrypto.addCSourceFiles(.{
132+
libressl_common.libcrypto.root_module.addCSourceFiles(.{
133133
.root = crypto_srcroot,
134134
.files = libcrypto_nonasm_or_armv4,
135135
.flags = cflags,
@@ -146,7 +146,7 @@ pub fn build(b: *std.Build) !void {
146146
build_asm = false;
147147
}
148148
} else if (tinfo.os.tag.isDarwin() and tinfo.cpu.arch == .x86_64) {
149-
libressl_common.libcrypto.addCSourceFiles(.{
149+
libressl_common.libcrypto.root_module.addCSourceFiles(.{
150150
.root = crypto_srcroot,
151151
.files = libcrypto_macos_x86_64_asm,
152152
.flags = cflags,
@@ -167,7 +167,7 @@ pub fn build(b: *std.Build) !void {
167167
libressl_common.libcrypto.root_module.addCMacro("WHIRLPOOL_ASM", "");
168168
libressl_common.libcrypto.root_module.addCMacro("OPENSSL_CPUID_OBJ", "");
169169
} else if (tinfo.os.tag == .windows and tinfo.abi == .gnu) {
170-
libressl_common.libcrypto.addCSourceFiles(.{
170+
libressl_common.libcrypto.root_module.addCSourceFiles(.{
171171
.root = crypto_srcroot,
172172
.files = libcrypto_mingw64_x86_64_asm,
173173
.flags = cflags,
@@ -189,12 +189,12 @@ pub fn build(b: *std.Build) !void {
189189
}
190190
}
191191
if (!build_asm) {
192-
libressl_common.libcrypto.addCSourceFiles(.{
192+
libressl_common.libcrypto.root_module.addCSourceFiles(.{
193193
.root = crypto_srcroot,
194194
.files = libcrypto_nonasm_or_armv4,
195195
.flags = cflags,
196196
});
197-
libressl_common.libcrypto.addCSourceFiles(.{
197+
libressl_common.libcrypto.root_module.addCSourceFiles(.{
198198
.root = crypto_srcroot,
199199
.files = libcrypto_nonasm,
200200
.flags = cflags,
@@ -211,18 +211,18 @@ pub fn build(b: *std.Build) !void {
211211

212212
switch (tinfo.os.tag) {
213213
.linux => {
214-
libressl_common.libcrypto.addCSourceFiles(.{
214+
libressl_common.libcrypto.root_module.addCSourceFiles(.{
215215
.root = crypto_srcroot,
216216
.files = libcrypto_unix_sources,
217217
.flags = cflags,
218218
});
219-
libressl_common.libcrypto.addCSourceFiles(.{
219+
libressl_common.libcrypto.root_module.addCSourceFiles(.{
220220
.root = crypto_srcroot,
221221
.files = libcrypto_linux_compat,
222222
.flags = cflags,
223223
});
224224

225-
libressl_common.apps.openssl.addCSourceFiles(.{
225+
libressl_common.apps.openssl.root_module.addCSourceFiles(.{
226226
.root = openssl_srcroot,
227227
.files = openssl_app_posix_sources,
228228
.flags = cflags,
@@ -252,13 +252,13 @@ pub fn build(b: *std.Build) !void {
252252
libressl_common.addCMacro("HAVE_NETINET_IP_H", "");
253253

254254
if (tinfo.abi.isGnu()) {
255-
libressl_common.libcrypto.addCSourceFiles(.{
255+
libressl_common.libcrypto.root_module.addCSourceFiles(.{
256256
.root = crypto_srcroot,
257257
.files = libcrypto_linux_glibc_compat,
258258
.flags = cflags,
259259
});
260260
} else if (tinfo.abi.isMusl()) {
261-
libressl_common.libcrypto.addCSourceFiles(.{
261+
libressl_common.libcrypto.root_module.addCSourceFiles(.{
262262
.root = crypto_srcroot,
263263
.files = libcrypto_linux_musl_compat,
264264
.flags = cflags,
@@ -277,23 +277,23 @@ pub fn build(b: *std.Build) !void {
277277
return error.Unsupported;
278278
}
279279

280-
libressl_common.libcrypto.addCSourceFiles(.{
280+
libressl_common.libcrypto.root_module.addCSourceFiles(.{
281281
.root = crypto_srcroot,
282282
.files = libcrypto_windows_sources,
283283
.flags = cflags,
284284
});
285-
libressl_common.libcrypto.addCSourceFiles(.{
285+
libressl_common.libcrypto.root_module.addCSourceFiles(.{
286286
.root = crypto_srcroot,
287287
.files = libcrypto_windows_compat,
288288
.flags = cflags,
289289
});
290-
libressl_common.libtls.addCSourceFiles(.{
290+
libressl_common.libtls.root_module.addCSourceFiles(.{
291291
.root = tls_srcroot,
292292
.files = libtls_windows_sources,
293293
.flags = cflags,
294294
});
295295

296-
libressl_common.apps.openssl.addCSourceFiles(.{
296+
libressl_common.apps.openssl.root_module.addCSourceFiles(.{
297297
.root = openssl_srcroot,
298298
.files = openssl_app_windows_sources,
299299
.flags = cflags,
@@ -333,17 +333,17 @@ pub fn build(b: *std.Build) !void {
333333
},
334334

335335
else => if (tinfo.os.tag.isDarwin()) {
336-
libressl_common.libcrypto.addCSourceFiles(.{
336+
libressl_common.libcrypto.root_module.addCSourceFiles(.{
337337
.root = crypto_srcroot,
338338
.files = libcrypto_unix_sources,
339339
.flags = cflags,
340340
});
341-
libressl_common.libcrypto.addCSourceFiles(.{
341+
libressl_common.libcrypto.root_module.addCSourceFiles(.{
342342
.root = crypto_srcroot,
343343
.files = libcrypto_macos_compat,
344344
.flags = cflags,
345345
});
346-
libressl_common.apps.openssl.addCSourceFiles(.{
346+
libressl_common.apps.openssl.root_module.addCSourceFiles(.{
347347
.root = openssl_srcroot,
348348
.files = openssl_app_posix_sources,
349349
.flags = cflags,
@@ -399,70 +399,70 @@ pub fn build(b: *std.Build) !void {
399399
);
400400

401401
for (libcrypto_include_paths) |path| {
402-
libressl_common.libcrypto.addIncludePath(upstream.path(path));
403-
libressl_common.apps.nc.addIncludePath(upstream.path(path));
404-
libressl_common.apps.ocspcheck.addIncludePath(upstream.path(path));
405-
libressl_common.apps.openssl.addIncludePath(upstream.path(path));
402+
libressl_common.libcrypto.root_module.addIncludePath(upstream.path(path));
403+
libressl_common.apps.nc.root_module.addIncludePath(upstream.path(path));
404+
libressl_common.apps.ocspcheck.root_module.addIncludePath(upstream.path(path));
405+
libressl_common.apps.openssl.root_module.addIncludePath(upstream.path(path));
406406
}
407407

408408
for (libssl_include_paths) |path| {
409-
libressl_common.libssl.addIncludePath(upstream.path(path));
410-
libressl_common.apps.nc.addIncludePath(upstream.path(path));
411-
libressl_common.apps.ocspcheck.addIncludePath(upstream.path(path));
412-
libressl_common.apps.openssl.addIncludePath(upstream.path(path));
409+
libressl_common.libssl.root_module.addIncludePath(upstream.path(path));
410+
libressl_common.apps.nc.root_module.addIncludePath(upstream.path(path));
411+
libressl_common.apps.ocspcheck.root_module.addIncludePath(upstream.path(path));
412+
libressl_common.apps.openssl.root_module.addIncludePath(upstream.path(path));
413413
}
414414

415415
for (libtls_include_paths) |path| {
416-
libressl_common.libtls.addIncludePath(upstream.path(path));
417-
libressl_common.apps.nc.addIncludePath(upstream.path(path));
416+
libressl_common.libtls.root_module.addIncludePath(upstream.path(path));
417+
libressl_common.apps.nc.root_module.addIncludePath(upstream.path(path));
418418
}
419419

420-
libressl_common.apps.nc.addIncludePath(upstream.path("apps/nc/compat"));
420+
libressl_common.apps.nc.root_module.addIncludePath(upstream.path("apps/nc/compat"));
421421

422422
switch (tinfo.cpu.arch) {
423423
.aarch64,
424424
.aarch64_be,
425425
=> {
426-
libressl_common.libcrypto.addIncludePath(
426+
libressl_common.libcrypto.root_module.addIncludePath(
427427
upstream.path(libcrypto_src_prefix ++ "bn/arch/aarch64"),
428428
);
429-
libressl_common.libcrypto.addIncludePath(
429+
libressl_common.libcrypto.root_module.addIncludePath(
430430
upstream.path(libcrypto_src_prefix ++ "arch/aarch64"),
431431
);
432-
libressl_common.libssl.addIncludePath(
432+
libressl_common.libssl.root_module.addIncludePath(
433433
upstream.path(libcrypto_src_prefix ++ "arch/aarch64"),
434434
);
435435
},
436436
.x86 => {
437-
libressl_common.libcrypto.addIncludePath(
437+
libressl_common.libcrypto.root_module.addIncludePath(
438438
upstream.path(libcrypto_src_prefix ++ "bn/arch/i386"),
439439
);
440-
libressl_common.libcrypto.addIncludePath(
440+
libressl_common.libcrypto.root_module.addIncludePath(
441441
upstream.path(libcrypto_src_prefix ++ "arch/i386"),
442442
);
443-
libressl_common.libssl.addIncludePath(
443+
libressl_common.libssl.root_module.addIncludePath(
444444
upstream.path(libcrypto_src_prefix ++ "arch/i386"),
445445
);
446446
},
447447
.riscv64 => {
448-
libressl_common.libcrypto.addIncludePath(
448+
libressl_common.libcrypto.root_module.addIncludePath(
449449
upstream.path(libcrypto_src_prefix ++ "bn/arch/riscv64"),
450450
);
451-
libressl_common.libcrypto.addIncludePath(
451+
libressl_common.libcrypto.root_module.addIncludePath(
452452
upstream.path(libcrypto_src_prefix ++ "arch/riscv64"),
453453
);
454-
libressl_common.libssl.addIncludePath(
454+
libressl_common.libssl.root_module.addIncludePath(
455455
upstream.path(libcrypto_src_prefix ++ "arch/riscv64"),
456456
);
457457
},
458458
.x86_64 => {
459-
libressl_common.libcrypto.addIncludePath(
459+
libressl_common.libcrypto.root_module.addIncludePath(
460460
upstream.path(libcrypto_src_prefix ++ "bn/arch/amd64"),
461461
);
462-
libressl_common.libcrypto.addIncludePath(
462+
libressl_common.libcrypto.root_module.addIncludePath(
463463
upstream.path(libcrypto_src_prefix ++ "arch/amd64"),
464464
);
465-
libressl_common.libssl.addIncludePath(
465+
libressl_common.libssl.root_module.addIncludePath(
466466
upstream.path(libcrypto_src_prefix ++ "arch/amd64"),
467467
);
468468
},
@@ -479,25 +479,25 @@ pub fn build(b: *std.Build) !void {
479479
libressl_common.libtls.step.dependOn(&copy_conf_header.step);
480480

481481
const conf_header_dir = copy_conf_header.getDirectory();
482-
libressl_common.libcrypto.addIncludePath(conf_header_dir);
483-
libressl_common.libssl.addIncludePath(conf_header_dir);
484-
libressl_common.libtls.addIncludePath(conf_header_dir);
482+
libressl_common.libcrypto.root_module.addIncludePath(conf_header_dir);
483+
libressl_common.libssl.root_module.addIncludePath(conf_header_dir);
484+
libressl_common.libtls.root_module.addIncludePath(conf_header_dir);
485485

486-
libressl_common.libssl.linkLibrary(libressl_common.libcrypto);
486+
libressl_common.libssl.root_module.linkLibrary(libressl_common.libcrypto);
487487

488488
// cmake builds libtls with libcrypto and libssl symbols jammed into it, but
489489
// this does not.
490-
libressl_common.libtls.linkLibrary(libressl_common.libcrypto);
491-
libressl_common.libtls.linkLibrary(libressl_common.libssl);
490+
libressl_common.libtls.root_module.linkLibrary(libressl_common.libcrypto);
491+
libressl_common.libtls.root_module.linkLibrary(libressl_common.libssl);
492492

493493
libressl_common.installLibraries(b);
494494

495495
// weird hack here
496496
libressl_common.apps.nc.root_module.addCMacro("DEFAULT_CA_FILE", b.pathJoin(&.{ b.install_prefix, "etc", "ssl", "cert.pem" }));
497497
libressl_common.apps.ocspcheck.root_module.addCMacro("DEFAULT_CA_FILE", b.pathJoin(&.{ b.install_prefix, "etc", "ssl", "cert.pem" }));
498-
libressl_common.apps.nc.linkLibrary(libressl_common.libtls);
499-
libressl_common.apps.ocspcheck.linkLibrary(libressl_common.libtls);
500-
libressl_common.apps.openssl.linkLibrary(libressl_common.libssl);
498+
libressl_common.apps.nc.root_module.linkLibrary(libressl_common.libtls);
499+
libressl_common.apps.ocspcheck.root_module.linkLibrary(libressl_common.libtls);
500+
libressl_common.apps.openssl.root_module.linkLibrary(libressl_common.libssl);
501501

502502
if (build_apps) {
503503
libressl_common.installApps(b, upstream);
@@ -515,15 +515,15 @@ const LibreSslCommon = struct {
515515
},
516516

517517
pub fn linkLibC(self: LibreSslCommon) void {
518-
self.libcrypto.linkLibC();
519-
self.libssl.linkLibC();
520-
self.libtls.linkLibC();
518+
self.libcrypto.root_module.link_libc = true;
519+
self.libssl.root_module.link_libc = true;
520+
self.libtls.root_module.link_libc = true;
521521
}
522522

523523
pub fn linkSystemLibrary(self: LibreSslCommon, library: []const u8) void {
524-
self.libcrypto.linkSystemLibrary(library);
525-
self.libssl.linkSystemLibrary(library);
526-
self.libtls.linkSystemLibrary(library);
524+
self.libcrypto.root_module.linkSystemLibrary(library, .{});
525+
self.libssl.root_module.linkSystemLibrary(library, .{});
526+
self.libtls.root_module.linkSystemLibrary(library, .{});
527527
}
528528

529529
pub fn addCMacroForLibs(self: LibreSslCommon, name: []const u8, value: []const u8) void {

readme.md

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ First, update your `build.zig.zon`:
2121
```sh
2222
# Initialize a `zig build` project if you haven't already
2323
zig init
24-
# replace <refname> with the version you want to use, e.g. 4.0.0
24+
# replace <refname> with the version you want to use, e.g. 4.0.0+4
2525
zig fetch --save git+https://github.com/allyourcodebase/libressl#<refname>
2626
```
2727

@@ -36,11 +36,20 @@ const libressl_dependency = b.dependency("libressl", .{
3636
your_exe.linkLibrary(libressl_dependency.artifact("tls")); // or "ssl", or "crypto"
3737
```
3838

39+
## Options
40+
41+
```
42+
-Denable-asm=[bool] Enable compiling assembly routines, if available (default: true)
43+
-Dopenssldir=[string] Set the default libressl configuration/certificate directory
44+
-Dbuild-apps=[bool] Build the CLI programs nc, ocspcheck, and openssl (default: false)
45+
```
46+
3947
## Zig Version Support Matrix
4048

41-
| Refname | LibreSSL Version | Zig `0.15.0-dev` | Zig `0.14.x` | Zig `0.13.x` | Zig `0.12.x` |
42-
|-----------|------------------|------------------|--------------|--------------|--------------|
43-
| `4.0.0+3` | `4.0.0` |||||
44-
| `4.0.0+2` | `4.0.0` |||||
45-
| `4.0.0+1` | `4.0.0` |||||
46-
| `3.9.2+1` | `3.9.2` |||||
49+
| Refname | LibreSSL Version | Zig `0.16.0-dev` | Zig `0.15.x` | Zig `0.14.x` | Zig `0.13.x` | Zig `0.12.x` |
50+
|-----------|------------------|------------------|--------------|--------------|--------------|--------------|
51+
| `4.0.0+4` | `4.0.0` ||||||
52+
| `4.0.0+3` | `4.0.0` ||||||
53+
| `4.0.0+2` | `4.0.0` ||||||
54+
| `4.0.0+1` | `4.0.0` ||||||
55+
| `3.9.2+1` | `3.9.2` ||||||

0 commit comments

Comments
 (0)