const std = @import("std"); const bh = @import("bh"); pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false; const watcher = bh.MakeModlib(b, .{ .name = "watcher", .target = target, .optimize = optimize, .static_build = static_build, .root = b.path("src/watcher.zig"), }); watcher.install(); // Add include paths to module (for Zig @cImport) watcher.mod.addIncludePath(b.path("src/include")); // Configure library watcher.lib.linkLibC(); watcher.lib.linkLibCpp(); watcher.lib.addIncludePath(b.path("src/include")); watcher.lib.addCSourceFile(.{ .file = b.path("src/watcher.cpp") }); if (target.result.os.tag == .macos) { watcher.lib.linkFramework("CoreFoundation"); watcher.lib.linkFramework("CoreServices"); } const test_exe = b.addTest(.{ .root_module = b.createModule(.{ .target = target, .optimize = optimize, .root_source_file = b.path("tests/test.zig"), }), }); test_exe.root_module.addImport("watcher", watcher.mod); test_exe.root_module.linkLibrary(watcher.lib); const test_step = b.step("test", "runs sample unit tests for watcher"); test_step.dependOn(&b.addRunArtifact(test_exe).step); b.installArtifact(test_exe); }