const std = @import("std"); pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); const src_dep = b.dependency("src", .{}); // TODO: This is a workaround to avoid a translate-c bug. // Remove this when fixed, likely when 0.17 is released. const remove_pragma_step = b.addRunArtifact(b.addExecutable(.{ .name = "remove pragma", .root_module = b.createModule(.{ .root_source_file = b.path("scripts/remove-pragma.zig"), .target = b.graph.host }) })); remove_pragma_step.addFileArg(src_dep.path("miniz.h")); var clean_miniz_h = remove_pragma_step.addOutputFileArg("miniz.h"); const mod = b.addModule("miniz", .{ .target = target, .optimize = optimize, .root_source_file = b.path("src/root.zig"), .link_libc = true }); mod.addIncludePath(clean_miniz_h.dirname()); mod.addCSourceFiles(.{ .root = src_dep.path("."), .files = &.{ "miniz.c" }, }); const write_file_step = b.addWriteFiles(); const translate_c = b.addTranslateC(.{ .root_source_file = write_file_step.add("c.h", "#include \"miniz.h\""), .target = target, .optimize = optimize, }); translate_c.addIncludePath(clean_miniz_h.dirname()); mod.addImport("c", translate_c.createModule()); }