Backlog/lib/spng/build.zig

51 lines
1.5 KiB
Zig

const std = @import("std");
const bh = @import("bh");
pub fn build(b: *std.Build) void {
const opts = bh.declareOptions(b);
const spng_c = b.addLibrary(.{
.linkage = if (opts.static_build) .static else .dynamic,
.name = "spng_c",
.root_module = b.createModule(.{
.optimize = opts.optimize,
.target = opts.target,
.link_libc = true,
}),
});
spng_c.addCSourceFile(.{ .file = b.path("spng/spng.c") });
spng_c.addCSourceFile(.{ .file = b.path("miniz.c") });
spng_c.addIncludePath(b.path("spng"));
spng_c.addIncludePath(b.path("./"));
spng_c.root_module.addCMacro("SPNG_USE_MINIZ", "1");
const mod = b.addModule("spng", .{
.target = opts.target,
.optimize = opts.optimize,
.root_source_file = b.path("src/spng.zig"),
});
mod.addIncludePath(b.path("spng"));
mod.addIncludePath(b.path("./"));
mod.linkLibrary(spng_c);
b.installArtifact(spng_c);
const test_step = b.step("test", "run unit tests for spng");
const tests = b.addTest(.{
.root_module = b.createModule(.{
.target = opts.target,
.optimize = opts.optimize,
.root_source_file = b.path("src/spng.zig"),
.link_libc = true,
}),
});
tests.root_module.linkLibrary(spng_c);
tests.root_module.addIncludePath(b.path("spng"));
tests.root_module.addIncludePath(b.path("./"));
const runArtifact = b.addRunArtifact(tests);
test_step.dependOn(&runArtifact.step);
}