1
0
Fork 0
mirror of https://github.com/zigzap/zap.git synced 2025-10-20 15:14:08 +00:00

Merge pull request #63 from Vemahk/master

Re-add -Dopenssl to zap build
This commit is contained in:
Rene Schallner 2024-01-07 21:08:12 +01:00 committed by GitHub
commit 689da4abea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 6 deletions

View file

@ -41,7 +41,8 @@ Exactly the goals I set out to achieve!
- Q: **Does ZAP support TLS / HTTPS?**
- A: Yes, ZAP supports using the system's openssl. See the
[https](./examples/https/https.zig) example and make sure to build with
the environment variable `ZAP_USE_OPENSSL=true`:
the -Dopenssl flag or the environment variable `ZAP_USE_OPENSSL=true`:
- `.openssl = true,` (in build.zig, `b.dependency("zap" .{...})`)
- `ZAP_USE_OPENSSL=true zig build https`
## Here's what works
@ -117,10 +118,11 @@ necessary to show a feature.
call `r.sendError(err, status_code)` when you catch an error and a stack trace
will be returned to the client / browser.
- [**HTTPS**](examples/https/https.zig): Shows how easy it is to use facil.io's
openssl support. Must be compiled with the environment variable
`ZAP_USE_OPENSSL` set to `true` and requires openssl dev dependencies
openssl support. Must be compiled with `-Dopenssl=true` or the environment
variable `ZAP_USE_OPENSSL` set to `true` and requires openssl dev dependencies
(headers, lib) to be installed on the system.
- run it like this: `ZAP_USE_OPENSSL=true zig build run-https`
- run it like this: `ZAP_USE_OPENSSL=true zig build run-https`
OR like this: `zig build -Dopenssl=true run-https`
- it will tell you how to generate certificates
I'll continue wrapping more of facil.io's functionality and adding stuff to zap
@ -273,6 +275,7 @@ Then, in your `build.zig`'s `build` function, add the following before
const zap = b.dependency("zap", .{
.target = target,
.optimize = optimize,
.openssl = false, // set to true to enable TLS support
});
exe.addModule("zap", zap.module("zap"));
exe.linkLibrary(zap.artifact("facil.io"));

View file

@ -7,8 +7,8 @@ pub fn build(b: *std.build.Builder) !void {
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall.
const optimize = b.standardOptimizeOption(.{});
// Use an os env var to determine whether to build openssl support
const use_openssl = blk: {
const use_openssl = b.option(bool, "openssl", "Use system-installed openssl for TLS support in zap") orelse blk: {
// Alternatively, use an os env var to determine whether to build openssl support
if (std.os.getenv("ZAP_USE_OPENSSL")) |val| {
if (std.mem.eql(u8, val, "true")) break :blk true;
}