From 9075971696cae25228779e9deb9dba113b3d1b43 Mon Sep 17 00:00:00 2001 From: Martin Ashby Date: Mon, 28 Aug 2023 20:22:21 +0100 Subject: Switch to zig package manager instead of using submodules Add smtp library Send a notification on comment. --- comments/build.zig | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'comments/build.zig') diff --git a/comments/build.zig b/comments/build.zig index b7f3bcc..a678527 100644 --- a/comments/build.zig +++ b/comments/build.zig @@ -15,6 +15,8 @@ pub fn build(b: *std.Build) void { // set a preferred release mode, allowing the user to decide how to optimize. const optimize = b.standardOptimizeOption(.{}); + const opts = .{ .target = target, .optimize = optimize }; + const exe = b.addExecutable(.{ .name = "comments", // In this case the main source file is merely a path, however, in more @@ -24,15 +26,21 @@ pub fn build(b: *std.Build) void { .optimize = optimize, }); - const zws = b.addModule("zws", .{ .source_file = .{ .path = "lib/zigwebserver/src/zigwebserver.zig" } }); - exe.addModule("zws", zws); + const zws = b.dependency("zigwebserver", opts); + exe.addModule("zws", zws.module("zigwebserver")); + exe.linkLibrary(zws.artifact("zigwebserver")); exe.linkLibC(); exe.linkSystemLibrary("libpq"); exe.addIncludePath(.{ .path = "/usr/include" }); - const mustache = b.addModule("mustache", .{ .source_file = .{ .path = "lib/mustache-zig/src/mustache.zig" } }); - exe.addModule("mustache", mustache); + const mustache = b.dependency("mustache", opts); + exe.addModule("mustache", mustache.module("mustache")); + exe.linkLibrary(mustache.artifact("mustache-static")); + + const smtp = b.dependency("smtp", opts); + exe.addModule("smtp", smtp.module("smtp")); + exe.linkLibrary(smtp.artifact("smtp")); // This declares intent for the executable to be installed into the // standard location when the user invokes the "install" step (the default @@ -69,7 +77,7 @@ pub fn build(b: *std.Build) void { .target = target, .optimize = optimize, }); - unit_tests.addModule("mustache", mustache); + unit_tests.addModule("mustache", mustache.module("mustache")); const run_unit_tests = b.addRunArtifact(unit_tests); -- cgit v1.2.3-ZIG