mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-05-05 15:33:00 +00: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:
parent
550edd4262
commit
5ad8ea6b22
@ -1,3 +1 @@
|
||||
pub const c = @cImport({
|
||||
@cInclude("QuartzCore/CALayer.h");
|
||||
});
|
||||
pub const c = @import("../main.zig").c;
|
||||
|
@ -45,10 +45,8 @@ pub fn build(b: *std.Build) !void {
|
||||
module.linkFramework("CoreVideo", .{});
|
||||
module.linkFramework("QuartzCore", .{});
|
||||
|
||||
if (!target.query.isNative()) {
|
||||
try apple_sdk.addPaths(b, lib.root_module);
|
||||
try apple_sdk.addPaths(b, module);
|
||||
}
|
||||
try apple_sdk.addPaths(b, lib.root_module);
|
||||
try apple_sdk.addPaths(b, module);
|
||||
}
|
||||
b.installArtifact(lib);
|
||||
|
||||
@ -59,9 +57,20 @@ pub fn build(b: *std.Build) !void {
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
if (target.result.os.tag.isDarwin()) {
|
||||
try apple_sdk.addPaths(b, test_exe.root_module);
|
||||
}
|
||||
test_exe.linkLibrary(lib);
|
||||
|
||||
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 test_step = b.step("test", "Run tests");
|
||||
|
@ -1,6 +1,7 @@
|
||||
.{
|
||||
.name = "macos",
|
||||
.name = .macos,
|
||||
.version = "0.1.0",
|
||||
.fingerprint = 0x45e2f6107d5b2b2c,
|
||||
.paths = .{""},
|
||||
.dependencies = .{
|
||||
.apple_sdk = .{ .path = "../apple-sdk" },
|
||||
|
@ -1,3 +1 @@
|
||||
pub const c = @cImport({
|
||||
@cInclude("Carbon/Carbon.h");
|
||||
});
|
||||
pub const c = @import("../main.zig").c;
|
||||
|
@ -1,3 +1 @@
|
||||
pub const c = @cImport({
|
||||
@cInclude("dispatch/dispatch.h");
|
||||
});
|
||||
pub const c = @import("../main.zig").c;
|
||||
|
@ -67,7 +67,7 @@ pub const MutableAttributedString = opaque {
|
||||
) void {
|
||||
const T = @TypeOf(key);
|
||||
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"))
|
||||
key.key()
|
||||
else
|
||||
|
@ -1,3 +1 @@
|
||||
pub const c = @cImport({
|
||||
@cInclude("CoreFoundation/CoreFoundation.h");
|
||||
});
|
||||
pub const c = @import("../main.zig").c;
|
||||
|
@ -38,13 +38,13 @@ test {
|
||||
const cs = try graphics.ColorSpace.createDeviceGray();
|
||||
defer cs.release();
|
||||
const ctx = try BitmapContext.create(null, 80, 80, 8, 80, cs, 0);
|
||||
defer ctx.release();
|
||||
|
||||
ctx.setShouldAntialias(true);
|
||||
ctx.setShouldSmoothFonts(false);
|
||||
ctx.setGrayFillColor(1, 1);
|
||||
ctx.setGrayStrokeColor(1, 1);
|
||||
ctx.setTextDrawingMode(.fill);
|
||||
ctx.setTextMatrix(graphics.AffineTransform.identity());
|
||||
ctx.setTextPosition(0, 0);
|
||||
const context = BitmapContext.context;
|
||||
defer context.release(ctx);
|
||||
context.setShouldAntialias(ctx, true);
|
||||
context.setShouldSmoothFonts(ctx, false);
|
||||
context.setGrayFillColor(ctx, 1, 1);
|
||||
context.setGrayStrokeColor(ctx, 1, 1);
|
||||
context.setTextDrawingMode(ctx, .fill);
|
||||
context.setTextMatrix(ctx, graphics.AffineTransform.identity());
|
||||
context.setTextPosition(ctx, 0, 0);
|
||||
}
|
||||
|
@ -1,3 +1 @@
|
||||
pub const c = @cImport({
|
||||
@cInclude("CoreGraphics/CoreGraphics.h");
|
||||
});
|
||||
pub const c = @import("../main.zig").c;
|
||||
|
@ -3,7 +3,7 @@ const assert = std.debug.assert;
|
||||
const Allocator = std.mem.Allocator;
|
||||
const foundation = @import("../foundation.zig");
|
||||
const graphics = @import("../graphics.zig");
|
||||
const c = @import("c.zig");
|
||||
const c = @import("c.zig").c;
|
||||
|
||||
pub const Path = opaque {
|
||||
pub fn createWithRect(
|
||||
|
@ -1,3 +1,5 @@
|
||||
const builtin = @import("builtin");
|
||||
|
||||
pub const carbon = @import("carbon.zig");
|
||||
pub const foundation = @import("foundation.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 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 {
|
||||
@import("std").testing.refAllDecls(@This());
|
||||
}
|
||||
|
@ -1,3 +1 @@
|
||||
pub const c = @cImport({
|
||||
@cInclude("os/log.h");
|
||||
});
|
||||
pub const c = @import("../main.zig").c;
|
||||
|
@ -1,3 +1 @@
|
||||
pub const c = @cImport({
|
||||
@cInclude("CoreText/CoreText.h");
|
||||
});
|
||||
pub const c = @import("../main.zig").c;
|
||||
|
@ -280,7 +280,8 @@ test {
|
||||
const cs = try graphics.ColorSpace.createDeviceGray();
|
||||
defer cs.release();
|
||||
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 }};
|
||||
font.drawGlyphs(
|
||||
|
@ -276,7 +276,7 @@ test "descriptor" {
|
||||
const v = try FontDescriptor.createWithNameAndSize(name, 12);
|
||||
defer v.release();
|
||||
|
||||
const copy_name = v.copyAttribute(.name);
|
||||
const copy_name = v.copyAttribute(.name).?;
|
||||
defer copy_name.release();
|
||||
|
||||
{
|
||||
|
@ -1,3 +1 @@
|
||||
pub const c = @cImport({
|
||||
@cInclude("CoreVideo/CoreVideo.h");
|
||||
});
|
||||
pub const c = @import("../main.zig").c;
|
||||
|
Loading…
x
Reference in New Issue
Block a user