diff --git a/.zig-cache/h/cf20cbabf4bf295b89a59be7deb31436.txt b/.zig-cache/h/cf20cbabf4bf295b89a59be7deb31436.txt new file mode 100644 index 0000000..e69de29 diff --git a/.zig-cache/h/timestamp b/.zig-cache/h/timestamp new file mode 100644 index 0000000..e69de29 diff --git a/.zig-cache/o/fbc055654621661cdc60c369fbf138f9/dependencies.zig b/.zig-cache/o/fbc055654621661cdc60c369fbf138f9/dependencies.zig new file mode 100644 index 0000000..72e4e83 --- /dev/null +++ b/.zig-cache/o/fbc055654621661cdc60c369fbf138f9/dependencies.zig @@ -0,0 +1,2 @@ +pub const packages = struct {}; +pub const root_deps: []const struct { []const u8, []const u8 } = &.{}; diff --git a/.zig-cache/z/bcf15b946bf5c3c42c96c97e20c86c29 b/.zig-cache/z/bcf15b946bf5c3c42c96c97e20c86c29 new file mode 100644 index 0000000..7b12e79 Binary files /dev/null and b/.zig-cache/z/bcf15b946bf5c3c42c96c97e20c86c29 differ diff --git a/.zig-cache/z/d262569f7b449ddd507423ef7e4bd492 b/.zig-cache/z/d262569f7b449ddd507423ef7e4bd492 new file mode 100644 index 0000000..c2ff3ba Binary files /dev/null and b/.zig-cache/z/d262569f7b449ddd507423ef7e4bd492 differ diff --git a/build.zig b/build.zig index 235a2a8..8d1aeca 100644 --- a/build.zig +++ b/build.zig @@ -1,37 +1,30 @@ const std = @import("std"); -const zlib = @import("zlib.zig"); - -pub fn build(b: *std.build.Builder) void { - const target = b.standardTargetOptions(.{}); - const optimize = b.standardOptimizeOption(.{}); +pub fn build(b: *std.Build) void { // Modules available to downstream dependencies - _ = b.addModule("zlib", .{ - .source_file = .{ .path = (comptime thisDir()) ++ "/src/main.zig" }, + const zlib = b.addModule("zlib", .{ + .root_source_file = b.path("src/main.zig"), + .link_libc = true, }); - const lib = zlib.create(b, target, optimize); - b.installArtifact(lib.step); + const srcs = &.{ + "zlib/adler32.c", + "zlib/compress.c", + "zlib/crc32.c", + "zlib/deflate.c", + "zlib/gzclose.c", + "zlib/gzlib.c", + "zlib/gzread.c", + "zlib/gzwrite.c", + "zlib/inflate.c", + "zlib/infback.c", + "zlib/inftrees.c", + "zlib/inffast.c", + "zlib/trees.c", + "zlib/uncompr.c", + "zlib/zutil.c", + }; - const tests = b.addTest(.{ - .root_source_file = .{ .path = "src/main.zig" }, - }); - lib.link(tests, .{}); - - const test_step = b.step("test", "Run tests"); - test_step.dependOn(&tests.step); - - const bin = b.addExecutable(.{ - .name = "example1", - .root_source_file = .{ .path = "example/example1.zig" }, - .target = target, - .optimize = optimize, - }); - lib.link(bin, .{ .import_name = "zlib" }); - b.installArtifact(bin); -} - -/// Path to the directory with the build.zig. -fn thisDir() []const u8 { - return std.fs.path.dirname(@src().file) orelse unreachable; + zlib.addCSourceFiles(.{ .files = srcs, .flags = &.{"-std=c89"} }); + zlib.addIncludePath(b.path("zlib/")); } diff --git a/build.zig.zon b/build.zig.zon new file mode 100644 index 0000000..f40917a --- /dev/null +++ b/build.zig.zon @@ -0,0 +1,11 @@ +.{ + .name = "zlib", + .version = "0.1.0", + .dependencies = .{}, + .paths = .{ + "readme.md", + "build.zig", + "build.zig.zon", + "src", + }, +} diff --git a/example/exe/.zig-cache/h/f541f89a8c855e8d8c9e7ef3747d5de4.txt b/example/exe/.zig-cache/h/f541f89a8c855e8d8c9e7ef3747d5de4.txt new file mode 100644 index 0000000..e69de29 diff --git a/example/exe/.zig-cache/h/timestamp b/example/exe/.zig-cache/h/timestamp new file mode 100644 index 0000000..e69de29 diff --git a/example/exe/.zig-cache/o/440007da036dbe975f6edb49f40a7f83/dependencies.zig b/example/exe/.zig-cache/o/440007da036dbe975f6edb49f40a7f83/dependencies.zig new file mode 100644 index 0000000..d520c69 --- /dev/null +++ b/example/exe/.zig-cache/o/440007da036dbe975f6edb49f40a7f83/dependencies.zig @@ -0,0 +1,11 @@ +pub const packages = struct { + pub const @"1220d624669f633ebe6c7afaba1a702c05c4c8e55a57b77a4d0d6ab1e3da07db11e2" = struct { + pub const build_root = "/home/rain/.cache/zig/p/1220d624669f633ebe6c7afaba1a702c05c4c8e55a57b77a4d0d6ab1e3da07db11e2"; + pub const build_zig = @import("1220d624669f633ebe6c7afaba1a702c05c4c8e55a57b77a4d0d6ab1e3da07db11e2"); + pub const deps: []const struct { []const u8, []const u8 } = &.{}; + }; +}; + +pub const root_deps: []const struct { []const u8, []const u8 } = &.{ + .{ "zlib", "1220d624669f633ebe6c7afaba1a702c05c4c8e55a57b77a4d0d6ab1e3da07db11e2" }, +}; diff --git a/example/exe/.zig-cache/z/bcf15b946bf5c3c42c96c97e20c86c29 b/example/exe/.zig-cache/z/bcf15b946bf5c3c42c96c97e20c86c29 new file mode 100644 index 0000000..3d76936 Binary files /dev/null and b/example/exe/.zig-cache/z/bcf15b946bf5c3c42c96c97e20c86c29 differ diff --git a/zlib.zig b/zlib.zig deleted file mode 100644 index e6b1bf6..0000000 --- a/zlib.zig +++ /dev/null @@ -1,58 +0,0 @@ -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(.{ .path = include_dir }); - other.linkLibrary(self.step); - - if (opts.import_name) |import_name| - other.addAnonymousModule( - import_name, - .{ .source_file = .{ .path = 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(.{ .files = srcs, .flags = &.{"-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", -};