Skip to content

Commit 9539cf6

Browse files
committed
Merge branch 'MFAshby-main'
2 parents 1a5ed46 + b189f92 commit 9539cf6

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
This is [libgit2](https://libgit2.org/) packaged using Zig's build system.
33
Currently only supports Windows and Linux targets.
44

5-
While libgit2 supports many different options for system dependencies, I've opted to use [MbedTLS](https://www.trustedfirmware.org/projects/mbed-tls/) on Linux for TLS, crypto, and certificate support. SSH support is optional, and is provided by [libssh2](https://libssh2.org/).
5+
While libgit2 supports many different options for system dependencies, I've opted to use [MbedTLS](https://www.trustedfirmware.org/projects/mbed-tls/) by default on Linux for TLS, crypto, and certificate support. You can replace MbedTLS with OpenSSL if you prefer. SSH support is optional, and is provided by [libssh2](https://libssh2.org/).
66
All other dependencies are bundled in the source tree and compiled statically.
77

88
## Usage
@@ -17,6 +17,7 @@ const libgit2_dep = b.dependency("libgit2", .{
1717
.target = target,
1818
.optimize = optimize,
1919
.@"enable-ssh" = true, // optional ssh support via libssh2
20+
.@"enable-openssl" = true, // use openssl instead of mbedtls
2021
});
2122
your_compile_step.linkLibrary(libgit_dep.artifact("git2"));
2223
```

build.zig

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ pub fn build(b: *std.Build) !void {
44
const target = b.standardTargetOptions(.{});
55
const optimize = b.standardOptimizeOption(.{});
66

7+
const mbedtls_dep = b.dependency("mbedtls", .{
8+
.target = target,
9+
.optimize = optimize,
10+
});
11+
712
const libgit_src = b.dependency("libgit2", .{});
813
const libgit_root = libgit_src.path(".");
914

@@ -85,9 +90,7 @@ pub fn build(b: *std.Build) !void {
8590
});
8691
} else {
8792
// mbedTLS https and SHA backend
88-
lib.linkSystemLibrary("mbedtls");
89-
lib.linkSystemLibrary("mbedcrypto");
90-
lib.linkSystemLibrary("mbedx509");
93+
lib.linkLibrary(mbedtls_dep.artifact("mbedtls"));
9194
features.addValues(.{
9295
.GIT_HTTPS = 1,
9396
.GIT_MBEDTLS = 1,
@@ -109,7 +112,11 @@ pub fn build(b: *std.Build) !void {
109112
.link_libc = true,
110113
});
111114
ntlm.addIncludePath(libgit_src.path("deps/ntlmclient"));
112-
if (openssl) addOpenSSLHeaders(ntlm);
115+
if (openssl) {
116+
addOpenSSLHeaders(ntlm);
117+
} else {
118+
ntlm.linkLibrary(mbedtls_dep.artifact("mbedtls"));
119+
}
113120

114121
const ntlm_cflags = .{
115122
"-Wno-implicit-fallthrough",
@@ -355,7 +362,7 @@ pub fn build(b: *std.Build) !void {
355362
examples_step.dependOn(&example_run.step);
356363
}
357364

358-
const tests_step = b.step("run-tests", "Tests");
365+
const tests_step = b.step("test", "Run unit tests");
359366
{
360367
const tests = b.addTest(.{
361368
.root_source_file = b.path("tests/main.zig"),

build.zig.zon

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
.url = "https://github.com/allyourcodebase/openssl/archive/refs/tags/3.3.1-1.tar.gz",
1212
.hash = "12207c40cefa38fe90e4230dfba2e5c76b37e1ee36602512cad8ff0501f892002a65",
1313
},
14+
.mbedtls = .{
15+
.url = "https://github.com/allyourcodebase/mbedtls/archive/40a2c1126b45f87d19b256229620bc2995637e5a.tar.gz",
16+
.hash = "122034bd019496a4e20a775116c53ef05e3247e9a98436b3407d4c0503fa3a16cd42",
17+
},
1418
},
1519
.paths = .{
1620
"build.zig",

0 commit comments

Comments
 (0)