Skip to content

Commit 3aa71a1

Browse files
authored
add build option to enable thread safety (#5)
1 parent 68d5872 commit 3aa71a1

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

build.zig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ pub fn build(b: *Build) void {
77

88
const mbedtls_dep = b.dependency("mbedtls", .{});
99

10+
const threading = b.option(bool, "threading", "Enable thread safety") orelse false;
11+
1012
const mbedtls = b.addLibrary(.{
1113
.name = "mbedtls",
1214
.linkage = .static,
@@ -25,6 +27,10 @@ pub fn build(b: *Build) void {
2527
// Otherwise `explicit_bzero` cannot be found
2628
mbedtls.root_module.addCMacro("__BSD_VISIBLE", "1");
2729
}
30+
if (threading) {
31+
mbedtls.root_module.addCMacro("MBEDTLS_THREADING_C", "");
32+
mbedtls.root_module.addCMacro("MBEDTLS_THREADING_PTHREAD", "");
33+
}
2834

2935
mbedtls.installHeadersDirectory(mbedtls_dep.path("include/mbedtls"), "mbedtls", .{});
3036
mbedtls.installHeadersDirectory(mbedtls_dep.path("include/psa"), "psa", .{});

0 commit comments

Comments
 (0)