Skip to content

Commit 7c3023f

Browse files
committed
update to zig 0.14.1
1 parent d3a7d21 commit 7c3023f

File tree

13 files changed

+60
-59
lines changed

13 files changed

+60
-59
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
sudo apt-get install libgtk-4-dev
1818
- uses: goto-bus-stop/setup-zig@v2
1919
with:
20-
version: 0.14.0-dev.2577+271452d22
20+
version: 0.14.1
2121
- name: Check formatting
2222
run: zig fmt --check src examples
2323
- name: Build Capy for native

.github/workflows/coverage.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- name: Install Zig
1818
uses: goto-bus-stop/setup-zig@v2
1919
with:
20-
version: 0.14.0-dev.2577+271452d22
20+
version: 0.14.1
2121

2222
- name: Test Coverage Capy for native
2323
run: xvfb-run -a zig build coverage

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010
**As of now, Capy is NOT ready for use in production as I'm still making breaking changes**
1111

12-
**Capy targets Zig version `0.14.0-dev.1911+3bf89f55c` / `2024.10.0-mach` ([Nominated Zig versions](https://machengine.org/docs/nominated-zig/))**
13-
, it doesn't work on Zig `0.13.0`
12+
**Capy targets Zig version `0.14.1`, the plan is to return to [Nominated Zig versions](https://machengine.org/docs/nominated-zig/)
13+
once a new one is published**
1414

1515
---
1616

build.zig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ fn installCapyDependencies(b: *std.Build, module: *std.Build.Module, options: Ca
6969
module.linkSystemLibrary("objc", .{ .use_pkg_config = .no });
7070
},
7171
.linux, .freebsd => {
72-
if (target.result.isAndroid()) {
72+
if (target.result.abi.isAndroid()) {
7373
const sdk = AndroidSdk.init(b, null, .{});
7474
var libraries = std.ArrayList([]const u8).init(b.allocator);
7575
try libraries.append("android");
@@ -108,7 +108,7 @@ fn installCapyDependencies(b: *std.Build, module: *std.Build.Module, options: Ca
108108
}
109109
},
110110
.wasi => {
111-
if (target.result.isWasm()) {
111+
if (target.result.cpu.arch.isWasm()) {
112112
// Things like the image reader require more stack than given by default
113113
// TODO: remove once ziglang/zig#12589 is merged
114114
module.export_symbol_names = &.{"_start"};
@@ -117,7 +117,7 @@ fn installCapyDependencies(b: *std.Build, module: *std.Build.Module, options: Ca
117117
}
118118
},
119119
.freestanding => {
120-
if (target.result.isWasm()) {
120+
if (target.result.cpu.arch.isWasm()) {
121121
std.log.warn("For targeting the Web, WebAssembly builds must now be compiled using the `wasm32-wasi` target.", .{});
122122
}
123123
return error.UnsupportedOs;

build.zig.zon

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
.{
2-
.name = "capy",
3-
.version = "0.4.0",
4-
.minimum_zig_version = "0.13.0",
2+
.name = .capy,
3+
.fingerprint = 0x4724968847bbbb92,
4+
.version = "0.4.1",
5+
.minimum_zig_version = "0.14.1",
56
.dependencies = .{
67
.@"zig-objc" = .{
78
.url = "https://github.com/mitchellh/zig-objc/archive/362d12f4d91dfde84668e0befc5a8ca76659965a.zip",
@@ -14,8 +15,8 @@
1415
.lazy = true,
1516
},
1617
.zigimg = .{
17-
.url = "git+https://github.com/zigimg/zigimg#c3bd7f9d593d75c60e70f0a950f499e55bd2a965",
18-
.hash = "1220a3427cad06407fb07843cf12395de92327dc629281ae17102fe09f5c1ead81c8",
18+
.url = "git+https://github.com/zigimg/zigimg#74caab5edd7c5f1d2f7d87e5717435ce0f0affa1",
19+
.hash = "zigimg-0.1.0-8_eo2nWlEgCddu8EGLOM_RkYshx3sC8tWv-yYA4-htS6",
1920
},
2021
},
2122
.paths = .{""},

build_capy.zig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ pub fn runStep(step: *std.Build.Step.Compile, options: CapyRunOptions) !*std.Bui
183183
},
184184
.macos => {},
185185
.linux, .freebsd => {
186-
if (step.rootModuleTarget().isAndroid()) {
186+
if (step.rootModuleTarget().abi.isAndroid()) {
187187
// TODO: find a new way to build Android applications
188188
// // TODO: automatically download the SDK and NDK and build tools?
189189
// // TODO: download Material components by parsing Maven?
@@ -292,9 +292,9 @@ pub fn runStep(step: *std.Build.Step.Compile, options: CapyRunOptions) !*std.Bui
292292
}
293293

294294
comptime {
295-
const supported_zig = std.SemanticVersion.parse("0.14.0-dev.2577+271452d22") catch unreachable;
295+
const supported_zig = std.SemanticVersion.parse("0.14.1") catch unreachable;
296296
const zig_version = @import("builtin").zig_version;
297297
if (zig_version.order(supported_zig) != .eq) {
298-
@compileError(std.fmt.comptimePrint("unsupported Zig version ({}). Required Zig version 2024.11.0-mach: https://machengine.org/docs/nominated-zig/#2024110-mach", .{@import("builtin").zig_version}));
298+
@compileError(std.fmt.comptimePrint("unsupported Zig version ({}). Zig 0.14.1 is required.", .{@import("builtin").zig_version}));
299299
}
300300
}

examples/calculator.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ pub fn main() !void {
8282
defer capy.deinit();
8383

8484
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
85-
defer if (comptime !@import("builtin").target.isWasm()) {
85+
defer if (comptime !@import("builtin").target.cpu.arch.isWasm()) {
8686
_ = gpa.deinit();
8787
};
8888

89-
if (comptime !@import("builtin").target.isWasm()) {
89+
if (comptime !@import("builtin").target.cpu.arch.isWasm()) {
9090
allocator = gpa.allocator();
9191
} else {
9292
allocator = std.heap.page_allocator;

flake.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
# The project requires exactly this Zig version (2024.11.0-mach)
2323
zigPkg = pkgs.stdenv.mkDerivation rec {
2424
pname = "zig";
25-
version = "0.14.0-dev.2577+271452d22";
25+
version = "0.14.1";
2626

2727
src = pkgs.fetchurl {
28-
url = "https://pkg.machengine.org/zig/zig-linux-x86_64-${version}.tar.xz";
28+
url = "https://ziglang.org/download/${version}/zig-x86_64-linux-${version}.tar.xz";
2929
sha256 = "sha256-e+ar3r+pcMYTjRZbNI0EZOhPFvUx5xyyDA4FL64djI0=";
3030
};
3131

src/backend.zig

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,24 @@ const backend = //if (@hasDecl(@import("root"), "capyBackend"))
77
// @import("root").capyBackend
88
//else
99
switch (builtin.os.tag) {
10-
.windows => @import("backends/win32/backend.zig"),
11-
.macos => @import("backends/macos/backend.zig"),
12-
.linux, .freebsd => blk: {
13-
if (builtin.target.isAndroid()) {
14-
break :blk @import("backends/android/backend.zig");
15-
} else {
16-
break :blk @import("backends/gtk/backend.zig");
17-
}
18-
},
19-
.wasi => blk: {
20-
if (builtin.cpu.arch == .wasm32 or builtin.cpu.arch == .wasm64) {
21-
break :blk @import("backends/wasm/backend.zig");
22-
} else {
23-
@compileError("Unsupported OS: wasi");
24-
}
25-
},
26-
else => @compileError(std.fmt.comptimePrint("Unsupported OS: {}", .{builtin.os.tag})),
27-
};
10+
.windows => @import("backends/win32/backend.zig"),
11+
.macos => @import("backends/macos/backend.zig"),
12+
.linux, .freebsd => blk: {
13+
if (builtin.target.abi.isAndroid()) {
14+
break :blk @import("backends/android/backend.zig");
15+
} else {
16+
break :blk @import("backends/gtk/backend.zig");
17+
}
18+
},
19+
.wasi => blk: {
20+
if (builtin.cpu.arch == .wasm32 or builtin.cpu.arch == .wasm64) {
21+
break :blk @import("backends/wasm/backend.zig");
22+
} else {
23+
@compileError("Unsupported OS: wasi");
24+
}
25+
},
26+
else => @compileError(std.fmt.comptimePrint("Unsupported OS: {}", .{builtin.os.tag})),
27+
};
2828
pub usingnamespace backend;
2929

3030
pub const DrawContext = struct {
@@ -158,10 +158,10 @@ test "backend: text field" {
158158
field.setReadOnly(true);
159159
field.setReadOnly(false);
160160

161-
try std.testing.fuzz(fuzzTextField, .{});
161+
try std.testing.fuzz({}, fuzzTextField, .{});
162162
}
163163

164-
fn fuzzTextField(input: []const u8) !void {
164+
fn fuzzTextField(_: void, input: []const u8) !void {
165165
var field = try backend.TextField.create();
166166
defer field.deinit();
167167
field.setText(input);
@@ -172,10 +172,10 @@ fn fuzzTextField(input: []const u8) !void {
172172
}
173173

174174
test "backend: button" {
175-
try std.testing.fuzz(fuzzButton, .{});
175+
try std.testing.fuzz({}, fuzzButton, .{});
176176
}
177177

178-
fn fuzzButton(input: []const u8) !void {
178+
fn fuzzButton(_: void, input: []const u8) !void {
179179
var button = try backend.Button.create();
180180
defer button.deinit();
181181

src/data.zig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,8 @@ pub fn Atom(comptime T: type) type {
206206
if (@inComptime()) return 0;
207207

208208
return switch (@typeInfo(T).pointer.size) {
209-
.One => Crc.hash(std.mem.asBytes(value)),
210-
.Many, .C, .Slice => Crc.hash(std.mem.sliceAsBytes(value)),
209+
.one => Crc.hash(std.mem.asBytes(value)),
210+
.many, .c, .slice => Crc.hash(std.mem.sliceAsBytes(value)),
211211
};
212212
}
213213

@@ -851,7 +851,7 @@ pub fn ListAtom(comptime T: type) type {
851851
self.lock.lock();
852852
defer self.lock.unlock();
853853

854-
const result = self.backing_list.popOrNull();
854+
const result = self.backing_list.pop();
855855
self.length.set(self.backing_list.items.len);
856856
break :blk result;
857857
};

0 commit comments

Comments
 (0)