fixes
This commit is contained in:
parent
5d231649a9
commit
d4613bb2ca
0
.zig-cache/h/cf20cbabf4bf295b89a59be7deb31436.txt
Normal file
0
.zig-cache/h/cf20cbabf4bf295b89a59be7deb31436.txt
Normal file
0
.zig-cache/h/timestamp
Normal file
0
.zig-cache/h/timestamp
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
pub const packages = struct {};
|
||||||
|
pub const root_deps: []const struct { []const u8, []const u8 } = &.{};
|
BIN
.zig-cache/z/bcf15b946bf5c3c42c96c97e20c86c29
Normal file
BIN
.zig-cache/z/bcf15b946bf5c3c42c96c97e20c86c29
Normal file
Binary file not shown.
BIN
.zig-cache/z/d262569f7b449ddd507423ef7e4bd492
Normal file
BIN
.zig-cache/z/d262569f7b449ddd507423ef7e4bd492
Normal file
Binary file not shown.
53
build.zig
53
build.zig
@ -1,37 +1,30 @@
|
|||||||
const std = @import("std");
|
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
|
// Modules available to downstream dependencies
|
||||||
_ = b.addModule("zlib", .{
|
const zlib = b.addModule("zlib", .{
|
||||||
.source_file = .{ .path = (comptime thisDir()) ++ "/src/main.zig" },
|
.root_source_file = b.path("src/main.zig"),
|
||||||
|
.link_libc = true,
|
||||||
});
|
});
|
||||||
|
|
||||||
const lib = zlib.create(b, target, optimize);
|
const srcs = &.{
|
||||||
b.installArtifact(lib.step);
|
"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(.{
|
zlib.addCSourceFiles(.{ .files = srcs, .flags = &.{"-std=c89"} });
|
||||||
.root_source_file = .{ .path = "src/main.zig" },
|
zlib.addIncludePath(b.path("zlib/"));
|
||||||
});
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
11
build.zig.zon
Normal file
11
build.zig.zon
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
.{
|
||||||
|
.name = "zlib",
|
||||||
|
.version = "0.1.0",
|
||||||
|
.dependencies = .{},
|
||||||
|
.paths = .{
|
||||||
|
"readme.md",
|
||||||
|
"build.zig",
|
||||||
|
"build.zig.zon",
|
||||||
|
"src",
|
||||||
|
},
|
||||||
|
}
|
0
example/exe/.zig-cache/h/timestamp
Normal file
0
example/exe/.zig-cache/h/timestamp
Normal file
@ -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" },
|
||||||
|
};
|
BIN
example/exe/.zig-cache/z/bcf15b946bf5c3c42c96c97e20c86c29
Normal file
BIN
example/exe/.zig-cache/z/bcf15b946bf5c3c42c96c97e20c86c29
Normal file
Binary file not shown.
58
zlib.zig
58
zlib.zig
@ -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",
|
|
||||||
};
|
|
Loading…
x
Reference in New Issue
Block a user