Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ jobs:
- uses: actions/checkout@v3
- uses: mlugg/setup-zig@v1
with:
version: 0.14.0
version: 0.15.0
- run: zig build test
38 changes: 25 additions & 13 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ pub fn build(b: *std.Build) void {
.root_source_file = b.path("src/ini.zig"),
});

const lib = b.addStaticLibrary(.{
const lib = b.addLibrary(.{
.name = "ini",
.root_source_file = b.path("src/lib.zig"),
.target = target,
.optimize = optimize,
.root_module = b.createModule(.{
.root_source_file = b.path("src/lib.zig"),
.target = target,
.optimize = optimize,
}),
});
lib.bundle_compiler_rt = true;
lib.addIncludePath(b.path("src"));
Expand All @@ -23,8 +25,10 @@ pub fn build(b: *std.Build) void {
const example_step = b.step("example", "Build examples");
const example_c = b.addExecutable(.{
.name = "example-c",
.optimize = optimize,
.target = target,
.root_module = b.createModule(.{
.optimize = optimize,
.target = target,
}),
});
example_c.addCSourceFile(.{
.file = b.path("example/example.c"),
Expand All @@ -41,23 +45,31 @@ pub fn build(b: *std.Build) void {

const example_zig = b.addExecutable(.{
.name = "example-zig",
.root_source_file = b.path("example/example.zig"),
.optimize = optimize,
.target = target,
.root_module = b.createModule(.{
.root_source_file = b.path("example/example.zig"),
.optimize = optimize,
.target = target,
}),
});
example_zig.root_module.addImport("ini", b.modules.get("ini").?);
example_step.dependOn(&b.addInstallArtifact(example_zig, .{}).step);

const test_step = b.step("test", "Run library tests");
const main_tests = b.addTest(.{
.root_source_file = b.path("src/test.zig"),
.optimize = optimize,
.root_module = b.createModule(.{
.root_source_file = b.path("src/test.zig"),
.optimize = optimize,
.target = target,
}),
});
test_step.dependOn(&b.addRunArtifact(main_tests).step);

const binding_tests = b.addTest(.{
.root_source_file = b.path("src/lib-test.zig"),
.optimize = optimize,
.root_module = b.createModule(.{
.root_source_file = b.path("src/lib-test.zig"),
.optimize = optimize,
.target = target,
}),
});
binding_tests.addIncludePath(b.path("src"));
binding_tests.linkLibrary(lib);
Expand Down
2 changes: 1 addition & 1 deletion build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
.name = .ini,
.fingerprint = 0x7757b668623d2460,
.version = "0.1.0",
.minimum_zig_version = "0.14.0",
.minimum_zig_version = "0.15.0",
.paths = .{
"LICENCE",
"README.md",
Expand Down
4 changes: 2 additions & 2 deletions src/ini.zig
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub fn Parser(comptime Reader: type) type {
const Self = @This();

allocator: std.mem.Allocator,
line_buffer: std.ArrayList(u8),
line_buffer: std.array_list.Managed(u8),
reader: Reader,
comment_characters: []const u8,

Expand Down Expand Up @@ -114,7 +114,7 @@ pub fn Parser(comptime Reader: type) type {
pub fn parse(allocator: std.mem.Allocator, reader: anytype, comment_characters: []const u8) Parser(@TypeOf(reader)) {
return Parser(@TypeOf(reader)){
.allocator = allocator,
.line_buffer = std.ArrayList(u8).init(allocator),
.line_buffer = std.array_list.Managed(u8).init(allocator),
.reader = reader,
.comment_characters = comment_characters,
};
Expand Down
2 changes: 1 addition & 1 deletion src/lib.zig
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export fn ini_next(parser: *IniParser, record: *Record) IniError {
return .success;
}

const CReader = std.io.Reader(*std.c.FILE, std.fs.File.ReadError, cReaderRead);
const CReader = std.Io.GenericReader(*std.c.FILE, std.fs.File.ReadError, cReaderRead);

fn cReader(c_file: *std.c.FILE) CReader {
return .{ .context = c_file };
Expand Down
Loading