Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

all: update to latest Zig version #23

Merged
merged 3 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
10 changes: 4 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- name: Setup Zig
run: |
sudo apt install xz-utils
sudo sh -c 'wget -c https://pkg.machengine.org/zig/zig-linux-x86_64-0.13.0-dev.351+64ef45eb0.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin'
sudo sh -c 'wget -c https://pkg.machengine.org/zig/zig-linux-x86_64-0.14.0-dev.1710+8ee52f99c.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin'
- name: x86_64-linux -> aarch64-macos
run: zig build -Dtarget=aarch64-macos
# TODO: re-enable this, unsure why it is failing during cross-compilation:
Expand All @@ -25,10 +25,10 @@ jobs:
# - name: Setup Zig
# run: |
# $ProgressPreference = 'SilentlyContinue'
# Invoke-WebRequest -Uri "https://pkg.machengine.org/zig/zig-windows-x86_64-0.13.0-dev.351+64ef45eb0.zip" -OutFile "C:\zig.zip"
# Invoke-WebRequest -Uri "https://pkg.machengine.org/zig/zig-windows-x86_64-0.14.0-dev.1710+8ee52f99c.zip" -OutFile "C:\zig.zip"
# cd C:\
# 7z x zig.zip
# Add-Content $env:GITHUB_PATH "C:\zig-windows-x86_64-0.13.0-dev.351+64ef45eb0\"
# Add-Content $env:GITHUB_PATH "C:\zig-windows-x86_64-0.14.0-dev.1710+8ee52f99c\"
# - name: x86_64-windows -> aarch64-macos
# run: zig build -Dtarget=aarch64-macos
x86_64-macos:
Expand All @@ -39,8 +39,6 @@ jobs:
- name: Setup Zig
run: |
brew install xz
sudo sh -c 'wget -c https://pkg.machengine.org/zig/zig-macos-x86_64-0.13.0-dev.351+64ef45eb0.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin'
sudo sh -c 'wget -c https://pkg.machengine.org/zig/zig-macos-x86_64-0.14.0-dev.1710+8ee52f99c.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin'
- name: build
run: zig build
- name: test
run: zig build test
12 changes: 0 additions & 12 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,6 @@ pub fn build(b: *std.Build) void {
.optimize = optimize,
});
b.installArtifact(generator_exe);

const main_tests = b.addTest(.{
.name = "mach-objc-tests",
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
});
addPaths(&main_tests.root_module);
main_tests.linkFramework("Foundation");

const test_step = b.step("test", "Run library tests");
test_step.dependOn(&b.addRunArtifact(main_tests).step);
}

pub fn addPaths(mod: *std.Build.Module) void {
Expand Down
2 changes: 1 addition & 1 deletion src/foundation.zig
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ pub fn Array(comptime ObjectType: type) type {
}

pub const Bundle = opaque {
pub const InternalInfo = objc.ExternClass("", @This(), ObjectInterface, .{});
pub const InternalInfo = objc.ExternClass("", @This(), ObjectInterface, &.{});
pub const as = InternalInfo.as;
pub const retain = InternalInfo.retain;
pub const release = InternalInfo.release;
Expand Down
4 changes: 2 additions & 2 deletions src/objc.zig
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ pub fn msgSend(receiver: anytype, comptime selector: []const u8, return_type: ty
.type = [*:0]c_char,
},
};
for (@typeInfo(@TypeOf(args)).Struct.fields) |field| {
for (@typeInfo(@TypeOf(args)).@"struct".fields) |field| {
params = params ++
.{.{
.is_generic = false,
Expand All @@ -89,7 +89,7 @@ pub fn msgSend(receiver: anytype, comptime selector: []const u8, return_type: ty
}};
}
break :init std.builtin.Type{
.Fn = .{
.@"fn" = .{
.calling_convention = .C,
.is_generic = false,
.is_var_args = false,
Expand Down
12 changes: 6 additions & 6 deletions src/system.zig
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ extern fn _Block_copy(*const anyopaque) *anyopaque; // Provided by libSystem on
extern fn _Block_release(*const anyopaque) void; // Provided by libSystem on iOS but not macOS.

pub fn Block(comptime Signature: type) type {
const signature_fn_info = @typeInfo(Signature).Fn;
const signature_fn_info = @typeInfo(Signature).@"fn";
return opaque {
pub fn invoke(self: *@This(), args: std.meta.ArgsTuple(Signature)) signature_fn_info.return_type.? {
const self_param = std.builtin.Type.Fn.Param{
Expand All @@ -19,7 +19,7 @@ pub fn Block(comptime Signature: type) type {
.type = *@This(),
};
const SignatureForInvoke = @Type(.{
.Fn = .{
.@"fn" = .{
.calling_convention = .C,
.is_generic = signature_fn_info.is_generic,
.is_var_args = signature_fn_info.is_var_args,
Expand Down Expand Up @@ -71,7 +71,7 @@ pub fn BlockLiteral(comptime Context: type) type {
}

pub fn BlockLiteralWithSignature(comptime Context: type, comptime Signature: type) type {
// We could also obtain `Context` from `@typeInfo(Signature).Fn.params[0].type`.
// We could also obtain `Context` from `@typeInfo(Signature).@"fn".params[0].type`.
return extern struct {
literal: BlockLiteral(Context),

Expand Down Expand Up @@ -118,14 +118,14 @@ fn CopyDisposeBlockDescriptor(comptime Context: type) type {

fn SignatureWithoutBlockLiteral(comptime Signature: type) type {
var type_info = @typeInfo(Signature);
type_info.Fn.calling_convention = .Unspecified;
type_info.Fn.params = type_info.Fn.params[1..];
type_info.@"fn".calling_convention = .Unspecified;
type_info.@"fn".params = type_info.@"fn".params[1..];
return @Type(type_info);
}

fn validateBlockSignature(comptime Invoke: type, comptime ExpectedLiteralType: type) void {
switch (@typeInfo(Invoke)) {
.Fn => |fn_info| {
.@"fn" => |fn_info| {
if (fn_info.calling_convention != .C) {
@compileError("A block's `invoke` must use the C calling convention");
}
Expand Down
Loading