Skip to content

Commit 9f8e2a3

Browse files
committed
Update Zig version to 0.16.0
1 parent 3fcbbe7 commit 9f8e2a3

16 files changed

Lines changed: 147 additions & 84 deletions

.github/workflows/docs.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Publish API Documentation
1+
name: Publish API documentation
22

33
on:
44
workflow_dispatch:
@@ -17,23 +17,23 @@ jobs:
1717
deploy-docs:
1818
runs-on: ubuntu-latest
1919
steps:
20-
- name: Checkout Repository
20+
- name: Checkout repository
2121
uses: actions/checkout@v4
2222

23-
- name: Install Zig
24-
uses: goto-bus-stop/setup-zig@v2
25-
with:
26-
version: '0.15.2'
23+
- name: Install Zig 0.16.0
24+
run: |
25+
curl -sSfL https://ziglang.org/download/0.16.0/zig-x86_64-linux-0.16.0.tar.xz | tar -xJ
26+
echo "$PWD/zig-x86_64-linux-0.16.0" >> "$GITHUB_PATH"
2727
28-
- name: Install System Dependencies
28+
- name: Install dependencies
2929
run: |
3030
sudo apt-get update
3131
sudo apt-get install -y make
3232
33-
- name: Generate Documentation
33+
- name: Generate documentation
3434
run: make docs
3535

36-
- name: Deploy to GitHub Pages
36+
- name: Deploy to GitHub pages
3737
uses: peaceiris/actions-gh-pages@v4
3838
with:
3939
github_token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/tests.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Run Tests
1+
name: Run tests
22

33
on:
44
workflow_dispatch:
@@ -24,18 +24,18 @@ jobs:
2424
runs-on: ubuntu-latest
2525

2626
steps:
27-
- name: Checkout Repository
27+
- name: Checkout repository
2828
uses: actions/checkout@v4
2929

30-
- name: Install Zig
31-
uses: goto-bus-stop/setup-zig@v2
32-
with:
33-
version: '0.15.2'
30+
- name: Install Zig 0.16.0
31+
run: |
32+
curl -sSfL https://ziglang.org/download/0.16.0/zig-x86_64-linux-0.16.0.tar.xz | tar -xJ
33+
echo "$PWD/zig-x86_64-linux-0.16.0" >> "$GITHUB_PATH"
3434
35-
- name: Install Dependencies
35+
- name: Install dependencies
3636
run: |
3737
sudo apt-get update
3838
sudo apt-get install -y make
3939
40-
- name: Run the Tests
40+
- name: Run the tests
4141
run: make test

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# ################################################################################
22
# # Configuration and Variables
33
# ################################################################################
4-
ZIG ?= $(shell which zig || echo ~/.local/share/zig/0.15.1/zig)
4+
ZIG_LOCAL := $(HOME)/.local/share/zig/0.16.0/zig
5+
ZIG ?= $(shell test -x $(ZIG_LOCAL) && echo $(ZIG_LOCAL) || which zig)
56
BUILD_TYPE ?= Debug
67
BUILD_OPTS = -Doptimize=$(BUILD_TYPE)
78
JOBS ?= $(shell nproc || echo 2)

build.zig

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,18 @@ pub fn build(b: *std.Build) void {
6262

6363
// --- Example Setup ---
6464
const examples_path = "examples";
65+
const io = b.graph.io;
6566
examples_blk: {
6667
// If the examples directory isn't present (common when used as a dependency),
6768
// skip setting up example artifacts instead of panicking.
68-
var examples_dir = fs.cwd().openDir(examples_path, .{ .iterate = true }) catch |err| {
69+
var examples_dir = b.build_root.handle.openDir(io, examples_path, .{ .iterate = true }) catch |err| {
6970
if (err == error.FileNotFound or err == error.NotDir) break :examples_blk;
7071
@panic("Can't open 'examples' directory");
7172
};
72-
defer examples_dir.close();
73+
defer examples_dir.close(io);
7374

7475
var dir_iter = examples_dir.iterate();
75-
while (dir_iter.next() catch @panic("Failed to iterate examples")) |entry| {
76+
while (dir_iter.next(io) catch @panic("Failed to iterate examples")) |entry| {
7677
if (!std.mem.endsWith(u8, entry.name, ".zig")) continue;
7778

7879
const exe_name = fs.path.stem(entry.name);

build.zig.zon

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
.{
22
.name = .chilli,
3-
.version = "0.2.4",
3+
.version = "0.3.0",
44
.fingerprint = 0x6c259741ae4f5f73, // Changing this has security and trust implications.
5-
.minimum_zig_version = "0.15.2",
5+
.minimum_zig_version = "0.16.0",
66
.paths = .{
77
"build.zig",
88
"build.zig.zon",

examples/e1_simple_cli.zig

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ const AppContext = struct {
55
config_path: []const u8,
66
};
77

8-
pub fn main() anyerror!void {
9-
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
8+
pub fn main(init: std.process.Init.Minimal) anyerror!void {
9+
var gpa: std.heap.DebugAllocator(.{}) = .init;
1010
defer _ = gpa.deinit();
1111
const allocator = gpa.allocator();
1212

@@ -54,13 +54,17 @@ pub fn main() anyerror!void {
5454
.variadic = true,
5555
});
5656

57-
try root_command.run(&app_context);
57+
try root_command.run(init.args, &app_context);
5858
}
5959

6060
fn rootExec(ctx: chilli.CommandContext) anyerror!void {
6161
const app_ctx = ctx.getContextData(AppContext).?;
6262
const config_slice = try ctx.getFlag("config", []const u8);
63-
const stdout = std.fs.File.stdout().deprecatedWriter();
63+
const io = std.Options.debug_io;
64+
var stdout_buf: [4096]u8 = undefined;
65+
var stdout_fw = std.Io.File.stdout().writer(io, &stdout_buf);
66+
defer stdout_fw.flush() catch {};
67+
const stdout = &stdout_fw.interface;
6468

6569
if (app_ctx.config_path.len > 0) {
6670
ctx.app_allocator.free(app_ctx.config_path);
@@ -75,7 +79,11 @@ fn rootExec(ctx: chilli.CommandContext) anyerror!void {
7579
fn runExec(ctx: chilli.CommandContext) anyerror!void {
7680
const task_name = try ctx.getArg("task-name", []const u8);
7781
const files = ctx.getArgs("files");
78-
const stdout = std.fs.File.stdout().deprecatedWriter();
82+
const io = std.Options.debug_io;
83+
var stdout_buf: [4096]u8 = undefined;
84+
var stdout_fw = std.Io.File.stdout().writer(io, &stdout_buf);
85+
defer stdout_fw.flush() catch {};
86+
const stdout = &stdout_fw.interface;
7987

8088
try stdout.print("Running task '{s}'...\n", .{task_name});
8189

examples/e2_nested_commands.zig

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,26 @@ fn rootExec(ctx: chilli.CommandContext) !void {
77

88
fn dbMigrateExec(ctx: chilli.CommandContext) !void {
99
_ = ctx;
10-
const stdout = std.fs.File.stdout().deprecatedWriter();
10+
const io = std.Options.debug_io;
11+
var stdout_buf: [4096]u8 = undefined;
12+
var stdout_fw = std.Io.File.stdout().writer(io, &stdout_buf);
13+
defer stdout_fw.flush() catch {};
14+
const stdout = &stdout_fw.interface;
1115
try stdout.print("Running database migrations...\n", .{});
1216
}
1317

1418
fn dbSeedExec(ctx: chilli.CommandContext) !void {
1519
const file = try ctx.getArg("file", []const u8);
16-
const stdout = std.fs.File.stdout().deprecatedWriter();
20+
const io = std.Options.debug_io;
21+
var stdout_buf: [4096]u8 = undefined;
22+
var stdout_fw = std.Io.File.stdout().writer(io, &stdout_buf);
23+
defer stdout_fw.flush() catch {};
24+
const stdout = &stdout_fw.interface;
1725
try stdout.print("Seeding database from file: {s}\n", .{file});
1826
}
1927

20-
pub fn main() anyerror!void {
21-
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
28+
pub fn main(init: std.process.Init.Minimal) anyerror!void {
29+
var gpa: std.heap.DebugAllocator(.{}) = .init;
2230
defer _ = gpa.deinit();
2331
const allocator = gpa.allocator();
2432

@@ -56,7 +64,7 @@ pub fn main() anyerror!void {
5664
.is_required = true,
5765
});
5866

59-
try root_cmd.run(null);
67+
try root_cmd.run(init.args, null);
6068
}
6169

6270
// Example Invocations

examples/e3_help_output.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ fn dummyExec(ctx: chilli.CommandContext) !void {
66
}
77

88
pub fn main() anyerror!void {
9-
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
9+
var gpa: std.heap.DebugAllocator(.{}) = .init;
1010
defer _ = gpa.deinit();
1111
const allocator = gpa.allocator();
1212

examples/e4_custom_sections.zig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ fn dummyExec(ctx: chilli.CommandContext) !void {
55
try ctx.command.printHelp();
66
}
77

8-
pub fn main() anyerror!void {
9-
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
8+
pub fn main(init: std.process.Init.Minimal) anyerror!void {
9+
var gpa: std.heap.DebugAllocator(.{}) = .init;
1010
defer _ = gpa.deinit();
1111
const allocator = gpa.allocator();
1212

@@ -56,7 +56,7 @@ pub fn main() anyerror!void {
5656
});
5757
try root_cmd.addSubcommand(cmd_other);
5858

59-
try root_cmd.run(null);
59+
try root_cmd.run(init.args, null);
6060
}
6161

6262
// Example Invocation

examples/e5_advanced_cli.zig

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ fn addExec(ctx: chilli.CommandContext) !void {
2929
const precision = try ctx.getFlag("precision", f64);
3030
const result = @as(f64, @floatFromInt(a)) + @as(f64, @floatFromInt(b));
3131

32-
const stdout = std.fs.File.stdout().deprecatedWriter();
32+
const io = std.Options.debug_io;
33+
var stdout_buf: [4096]u8 = undefined;
34+
var stdout_fw = std.Io.File.stdout().writer(io, &stdout_buf);
35+
defer stdout_fw.flush() catch {};
36+
const stdout = &stdout_fw.interface;
3337
const precision_int: u32 = @intFromFloat(@max(0.0, @min(precision, 20.0)));
3438

3539
var buf: [64]u8 = undefined;
@@ -43,18 +47,22 @@ fn addExec(ctx: chilli.CommandContext) !void {
4347

4448
fn greetExec(ctx: chilli.CommandContext) !void {
4549
const name = try ctx.getArg("name", []const u8);
46-
const stdout = std.fs.File.stdout().deprecatedWriter();
50+
const io = std.Options.debug_io;
51+
var stdout_buf: [4096]u8 = undefined;
52+
var stdout_fw = std.Io.File.stdout().writer(io, &stdout_buf);
53+
defer stdout_fw.flush() catch {};
54+
const stdout = &stdout_fw.interface;
4755
try stdout.print("Hello, {s}!\n", .{name});
4856
}
4957

50-
pub fn main() anyerror!void {
51-
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
58+
pub fn main(init: std.process.Init.Minimal) anyerror!void {
59+
var gpa: std.heap.DebugAllocator(.{}) = .init;
5260
defer _ = gpa.deinit();
5361
const allocator = gpa.allocator();
5462

5563
var app_context = AppContext{
5664
.log_level = 0,
57-
.start_time = std.time.timestamp(),
65+
.start_time = 0,
5866
};
5967

6068
var root_cmd = try chilli.Command.init(allocator, .{
@@ -107,7 +115,7 @@ pub fn main() anyerror!void {
107115
.default_value = .{ .String = "World" },
108116
});
109117

110-
try root_cmd.run(&app_context);
118+
try root_cmd.run(init.args, &app_context);
111119
}
112120

113121
// Example Invocations

0 commit comments

Comments
 (0)