Skip to content

Commit

Permalink
Merge pull request #63 from Vemahk/master
Browse files Browse the repository at this point in the history
Re-add -Dopenssl to zap build
  • Loading branch information
renerocksai authored Jan 7, 2024
2 parents 7ca46c4 + f38077c commit 689da4a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"));
Expand Down
4 changes: 2 additions & 2 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 689da4a

Please sign in to comment.