You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.5 KiB
Zig

const std = @import("std");
const Self = @This();
fn root() []const u8 {
return std.fs.path.dirname(@src().file) orelse ".";
}
const root_path = root() ++ "/";
const package_path = root_path ++ "src/main.zig";
pub const include_dir = root_path ++ "zlib";
pub const Options = struct {
import_name: ?[]const u8 = null,
};
pub const Library = struct {
step: *std.build.LibExeObjStep,
pub fn link(self: Library, other: *std.build.LibExeObjStep, opts: Options) void {
other.addIncludePath(include_dir);
other.linkLibrary(self.step);
if (opts.import_name) |import_name|
other.addPackagePath(import_name, package_path);
}
};
pub fn create(b: *std.build.Builder, target: std.zig.CrossTarget, optimize: std.builtin.OptimizeMode) Library {
const ret = b.addStaticLibrary(.{
.name = "z",
.target = target,
.optimize = optimize,
});
ret.linkLibC();
ret.addCSourceFiles(srcs, &.{"-std=c89"});
return Library{ .step = ret };
}
const srcs = &.{
root_path ++ "zlib/adler32.c",
root_path ++ "zlib/compress.c",
root_path ++ "zlib/crc32.c",
root_path ++ "zlib/deflate.c",
root_path ++ "zlib/gzclose.c",
root_path ++ "zlib/gzlib.c",
root_path ++ "zlib/gzread.c",
root_path ++ "zlib/gzwrite.c",
root_path ++ "zlib/inflate.c",
root_path ++ "zlib/infback.c",
root_path ++ "zlib/inftrees.c",
root_path ++ "zlib/inffast.c",
root_path ++ "zlib/trees.c",
root_path ++ "zlib/uncompr.c",
root_path ++ "zlib/zutil.c",
};