build.zig (924B)
1 const std = @import("std"); 2 3 pub fn build(b: *std.Build) void { 4 const target = b.standardTargetOptions(.{}); 5 const optimize = b.standardOptimizeOption(.{}); 6 7 const lib = b.addStaticLibrary(.{ 8 .name = "pq", 9 .root_source_file = b.path("src/main.zig"), 10 .target = target, 11 .optimize = optimize, 12 }); 13 lib.linkLibC(); 14 lib.linkSystemLibrary("libpq"); 15 16 // for zig package manager 17 _ = b.addModule("pq", .{ .root_source_file = b.path("src/main.zig") }); 18 19 b.installArtifact(lib); 20 21 const main_tests = b.addTest(.{ 22 .root_source_file = b.path("src/main.zig"), 23 .target = target, 24 .optimize = optimize, 25 }); 26 main_tests.linkLibC(); 27 main_tests.linkSystemLibrary("libpq"); 28 29 const run_main_tests = b.addRunArtifact(main_tests); 30 31 const test_step = b.step("test", "Run library tests"); 32 test_step.dependOn(&run_main_tests.step); 33 }