mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
pkg/macos: clean up for Zig 0.14, consolidate C imports into one decl
Fixes #6727 The major change in this commit is to consolidate all the C imports in a single decl in main.zig. This is required for Zig 0.14. Without it, the problem in #6727 will happen. I was never able to minimize why this happens in order to open a Zig bug. Beyond this, I fixed the build.zig and build.zig.zon to work with Zig 0.14 so that we can test building `pkg/macos` in isolation. There are no downstream impacting changes in the build.zig files.
This commit is contained in:
@ -1,3 +1 @@
|
|||||||
pub const c = @cImport({
|
pub const c = @import("../main.zig").c;
|
||||||
@cInclude("QuartzCore/CALayer.h");
|
|
||||||
});
|
|
||||||
|
@ -45,10 +45,8 @@ pub fn build(b: *std.Build) !void {
|
|||||||
module.linkFramework("CoreVideo", .{});
|
module.linkFramework("CoreVideo", .{});
|
||||||
module.linkFramework("QuartzCore", .{});
|
module.linkFramework("QuartzCore", .{});
|
||||||
|
|
||||||
if (!target.query.isNative()) {
|
try apple_sdk.addPaths(b, lib.root_module);
|
||||||
try apple_sdk.addPaths(b, lib.root_module);
|
try apple_sdk.addPaths(b, module);
|
||||||
try apple_sdk.addPaths(b, module);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
b.installArtifact(lib);
|
b.installArtifact(lib);
|
||||||
|
|
||||||
@ -59,9 +57,20 @@ pub fn build(b: *std.Build) !void {
|
|||||||
.target = target,
|
.target = target,
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
});
|
});
|
||||||
|
if (target.result.os.tag.isDarwin()) {
|
||||||
|
try apple_sdk.addPaths(b, test_exe.root_module);
|
||||||
|
}
|
||||||
test_exe.linkLibrary(lib);
|
test_exe.linkLibrary(lib);
|
||||||
|
|
||||||
var it = module.import_table.iterator();
|
var it = module.import_table.iterator();
|
||||||
while (it.next()) |entry| test_exe.root_module.addImport(entry.key_ptr.*, entry.value_ptr.*);
|
while (it.next()) |entry| {
|
||||||
|
test_exe.root_module.addImport(
|
||||||
|
entry.key_ptr.*,
|
||||||
|
entry.value_ptr.*,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
b.installArtifact(test_exe);
|
||||||
|
|
||||||
const tests_run = b.addRunArtifact(test_exe);
|
const tests_run = b.addRunArtifact(test_exe);
|
||||||
const test_step = b.step("test", "Run tests");
|
const test_step = b.step("test", "Run tests");
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
.{
|
.{
|
||||||
.name = "macos",
|
.name = .macos,
|
||||||
.version = "0.1.0",
|
.version = "0.1.0",
|
||||||
|
.fingerprint = 0x45e2f6107d5b2b2c,
|
||||||
.paths = .{""},
|
.paths = .{""},
|
||||||
.dependencies = .{
|
.dependencies = .{
|
||||||
.apple_sdk = .{ .path = "../apple-sdk" },
|
.apple_sdk = .{ .path = "../apple-sdk" },
|
||||||
|
@ -1,3 +1 @@
|
|||||||
pub const c = @cImport({
|
pub const c = @import("../main.zig").c;
|
||||||
@cInclude("Carbon/Carbon.h");
|
|
||||||
});
|
|
||||||
|
@ -1,3 +1 @@
|
|||||||
pub const c = @cImport({
|
pub const c = @import("../main.zig").c;
|
||||||
@cInclude("dispatch/dispatch.h");
|
|
||||||
});
|
|
||||||
|
@ -67,7 +67,7 @@ pub const MutableAttributedString = opaque {
|
|||||||
) void {
|
) void {
|
||||||
const T = @TypeOf(key);
|
const T = @TypeOf(key);
|
||||||
const info = @typeInfo(T);
|
const info = @typeInfo(T);
|
||||||
const Key = if (info != .Pointer) T else info.Pointer.child;
|
const Key = if (info != .pointer) T else info.pointer.child;
|
||||||
const key_arg = if (@hasDecl(Key, "key"))
|
const key_arg = if (@hasDecl(Key, "key"))
|
||||||
key.key()
|
key.key()
|
||||||
else
|
else
|
||||||
|
@ -1,3 +1 @@
|
|||||||
pub const c = @cImport({
|
pub const c = @import("../main.zig").c;
|
||||||
@cInclude("CoreFoundation/CoreFoundation.h");
|
|
||||||
});
|
|
||||||
|
@ -38,13 +38,13 @@ test {
|
|||||||
const cs = try graphics.ColorSpace.createDeviceGray();
|
const cs = try graphics.ColorSpace.createDeviceGray();
|
||||||
defer cs.release();
|
defer cs.release();
|
||||||
const ctx = try BitmapContext.create(null, 80, 80, 8, 80, cs, 0);
|
const ctx = try BitmapContext.create(null, 80, 80, 8, 80, cs, 0);
|
||||||
defer ctx.release();
|
const context = BitmapContext.context;
|
||||||
|
defer context.release(ctx);
|
||||||
ctx.setShouldAntialias(true);
|
context.setShouldAntialias(ctx, true);
|
||||||
ctx.setShouldSmoothFonts(false);
|
context.setShouldSmoothFonts(ctx, false);
|
||||||
ctx.setGrayFillColor(1, 1);
|
context.setGrayFillColor(ctx, 1, 1);
|
||||||
ctx.setGrayStrokeColor(1, 1);
|
context.setGrayStrokeColor(ctx, 1, 1);
|
||||||
ctx.setTextDrawingMode(.fill);
|
context.setTextDrawingMode(ctx, .fill);
|
||||||
ctx.setTextMatrix(graphics.AffineTransform.identity());
|
context.setTextMatrix(ctx, graphics.AffineTransform.identity());
|
||||||
ctx.setTextPosition(0, 0);
|
context.setTextPosition(ctx, 0, 0);
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1 @@
|
|||||||
pub const c = @cImport({
|
pub const c = @import("../main.zig").c;
|
||||||
@cInclude("CoreGraphics/CoreGraphics.h");
|
|
||||||
});
|
|
||||||
|
@ -3,7 +3,7 @@ const assert = std.debug.assert;
|
|||||||
const Allocator = std.mem.Allocator;
|
const Allocator = std.mem.Allocator;
|
||||||
const foundation = @import("../foundation.zig");
|
const foundation = @import("../foundation.zig");
|
||||||
const graphics = @import("../graphics.zig");
|
const graphics = @import("../graphics.zig");
|
||||||
const c = @import("c.zig");
|
const c = @import("c.zig").c;
|
||||||
|
|
||||||
pub const Path = opaque {
|
pub const Path = opaque {
|
||||||
pub fn createWithRect(
|
pub fn createWithRect(
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
const builtin = @import("builtin");
|
||||||
|
|
||||||
pub const carbon = @import("carbon.zig");
|
pub const carbon = @import("carbon.zig");
|
||||||
pub const foundation = @import("foundation.zig");
|
pub const foundation = @import("foundation.zig");
|
||||||
pub const animation = @import("animation.zig");
|
pub const animation = @import("animation.zig");
|
||||||
@ -7,6 +9,23 @@ pub const os = @import("os.zig");
|
|||||||
pub const text = @import("text.zig");
|
pub const text = @import("text.zig");
|
||||||
pub const video = @import("video.zig");
|
pub const video = @import("video.zig");
|
||||||
|
|
||||||
|
// All of our C imports consolidated into one place. We used to
|
||||||
|
// import them one by one in each package but Zig 0.14 has some
|
||||||
|
// kind of issue with that I wasn't able to minimize.
|
||||||
|
pub const c = @cImport({
|
||||||
|
@cInclude("CoreFoundation/CoreFoundation.h");
|
||||||
|
@cInclude("CoreGraphics/CoreGraphics.h");
|
||||||
|
@cInclude("CoreText/CoreText.h");
|
||||||
|
@cInclude("CoreVideo/CoreVideo.h");
|
||||||
|
@cInclude("QuartzCore/CALayer.h");
|
||||||
|
@cInclude("dispatch/dispatch.h");
|
||||||
|
@cInclude("os/log.h");
|
||||||
|
|
||||||
|
if (builtin.os.tag == .macos) {
|
||||||
|
@cInclude("Carbon/Carbon.h");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
test {
|
test {
|
||||||
@import("std").testing.refAllDecls(@This());
|
@import("std").testing.refAllDecls(@This());
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1 @@
|
|||||||
pub const c = @cImport({
|
pub const c = @import("../main.zig").c;
|
||||||
@cInclude("os/log.h");
|
|
||||||
});
|
|
||||||
|
@ -1,3 +1 @@
|
|||||||
pub const c = @cImport({
|
pub const c = @import("../main.zig").c;
|
||||||
@cInclude("CoreText/CoreText.h");
|
|
||||||
});
|
|
||||||
|
@ -280,7 +280,8 @@ test {
|
|||||||
const cs = try graphics.ColorSpace.createDeviceGray();
|
const cs = try graphics.ColorSpace.createDeviceGray();
|
||||||
defer cs.release();
|
defer cs.release();
|
||||||
const ctx = try graphics.BitmapContext.create(null, 80, 80, 8, 80, cs, 0);
|
const ctx = try graphics.BitmapContext.create(null, 80, 80, 8, 80, cs, 0);
|
||||||
defer ctx.release();
|
const context = graphics.BitmapContext.context;
|
||||||
|
defer context.release(ctx);
|
||||||
|
|
||||||
var pos = [_]graphics.Point{.{ .x = 0, .y = 0 }};
|
var pos = [_]graphics.Point{.{ .x = 0, .y = 0 }};
|
||||||
font.drawGlyphs(
|
font.drawGlyphs(
|
||||||
|
@ -276,7 +276,7 @@ test "descriptor" {
|
|||||||
const v = try FontDescriptor.createWithNameAndSize(name, 12);
|
const v = try FontDescriptor.createWithNameAndSize(name, 12);
|
||||||
defer v.release();
|
defer v.release();
|
||||||
|
|
||||||
const copy_name = v.copyAttribute(.name);
|
const copy_name = v.copyAttribute(.name).?;
|
||||||
defer copy_name.release();
|
defer copy_name.release();
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -1,3 +1 @@
|
|||||||
pub const c = @cImport({
|
pub const c = @import("../main.zig").c;
|
||||||
@cInclude("CoreVideo/CoreVideo.h");
|
|
||||||
});
|
|
||||||
|
Reference in New Issue
Block a user