51 lines
1.6 KiB
Zig
51 lines
1.6 KiB
Zig
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 spng = bh.MakeModlib(b, .{
|
|
.name = "spng",
|
|
.target = target,
|
|
.optimize = optimize,
|
|
.static_build = static_build,
|
|
.root = b.path("src/spng.zig"),
|
|
});
|
|
|
|
spng.install();
|
|
|
|
// Add include paths to module (for Zig @cImport)
|
|
spng.mod.addIncludePath(b.path("spng"));
|
|
spng.mod.addIncludePath(b.path("./"));
|
|
|
|
// Configure library
|
|
spng.lib.linkLibC();
|
|
|
|
spng.lib.addIncludePath(b.path("spng"));
|
|
spng.lib.addIncludePath(b.path("./"));
|
|
|
|
spng.lib.addCSourceFile(.{ .file = b.path("spng/spng.c") });
|
|
spng.lib.addCSourceFile(.{ .file = b.path("miniz.c") });
|
|
|
|
spng.lib.root_module.addCMacro("SPNG_USE_MINIZ", "1");
|
|
|
|
const test_step = b.step("test", "run unit tests for spng");
|
|
const tests = b.addTest(.{
|
|
.root_module = b.createModule(.{
|
|
.target = target,
|
|
.optimize = optimize,
|
|
.root_source_file = b.path("src/spng.zig"),
|
|
.link_libc = true,
|
|
}),
|
|
});
|
|
tests.root_module.addImport("spng", spng.mod);
|
|
tests.root_module.linkLibrary(spng.lib);
|
|
tests.root_module.addIncludePath(b.path("spng"));
|
|
tests.root_module.addIncludePath(b.path("./"));
|
|
const runArtifact = b.addRunArtifact(tests);
|
|
test_step.dependOn(&runArtifact.step);
|
|
}
|