diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-10 01:55:22 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-10 01:55:32 -0300 |
| commit | 75db3e84e24ee75626074d93927261249b646386 (patch) | |
| tree | f794df2c86801e23191f4c8ef08d40106bd22d85 /build.zig | |
| parent | 428898ae93543ab47f977b2f6f287a6bb9287625 (diff) | |
| download | pardes-75db3e84e24ee75626074d93927261249b646386.tar.gz pardes-75db3e84e24ee75626074d93927261249b646386.zip | |
macos: the AppKit trackpad adapter for the SDL window (upstream a41360e3's Trackpad.zig, macos_trackpad.{h,m} and their test as they were), its gui.zig hooks on today's names (pointAt, view().jumps and active, one setFontPx for a key's step and a pinch) and the build's shim per gui module with macos-trackpad-test registered once after the loop, all gated to macOS so a Linux touchpad's pinch and the goldens stay as they were
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'build.zig')
| -rw-r--r-- | build.zig | 29 |
1 files changed, 29 insertions, 0 deletions
@@ -916,6 +916,8 @@ pub fn build(b: *std.Build) void { if (platform == .gui) root_mod else null; // The static step's gui module is a gui shell too. const gui_shell_mods: [2]?*std.Build.Module = .{ gui_shell_mod, if (platform == .gui) static_mod else null }; + // SDL's headers, for the macOS trackpad adapter's test after the loop. + var sdl_include: ?std.Build.LazyPath = null; for (gui_shell_mods) |gui_shell_entry| if (gui_shell_entry) |gm| { // SDL's build asks a cross build for macOS for the SDK's paths. const sdk: ?std.Build.LazyPath = if (macos_sdk) |p| .{ .cwd_relative = p } else null; @@ -933,12 +935,26 @@ pub fn build(b: *std.Build) void { \\#define SDL_DISABLE_OLD_NAMES 1 \\#include <SDL3/SDL.h> \\#include "font.h" + \\#include "macos_trackpad.h" \\ ); const gui_c = b.addTranslateC(.{ .root_source_file = header, .target = target, .optimize = optimize }); gui_c.addIncludePath(dep.path("include")); gui_c.addIncludePath(b.path("src/gui")); gm.addImport("gui_c", gui_c.createModule()); + sdl_include = dep.path("include"); + if (target.result.os.tag == .macos) { + const arch = if (target.result.cpu.arch == .aarch64) "arm64" else @tagName(target.result.cpu.arch); + const shim = b.addSystemCommand(&.{ "xcrun", "clang", "-fobjc-arc", "-O2", "-target", b.fmt("{s}-apple-macos13.0", .{arch}), "-I" }); + shim.addDirectoryArg(dep.path("include")); + shim.addArg("-c"); + shim.addFileArg(b.path("src/gui/macos_trackpad.m")); + // Header changes invalidate the independently compiled adapter. + shim.addFileInput(b.path("src/gui/macos_trackpad.h")); + shim.addArg("-o"); + gm.addObjectFile(shim.addOutputFileArg("macos_trackpad.o")); + gm.linkFramework("Cocoa", .{}); + } } const ft = freetype orelse continue; gm.linkLibrary(ft); @@ -997,6 +1013,19 @@ pub fn build(b: *std.Build) void { compileGlsl(b, name), }); }; + if (target.result.os.tag == .macos) if (sdl_include) |include| { + const adapter_test = b.addSystemCommand(&.{ "xcrun", "clang", "-fobjc-arc", "-O1", "-framework", "Cocoa", "-I" }); + adapter_test.addDirectoryArg(include); + adapter_test.addFileArg(b.path("test/macos_trackpad.m")); + adapter_test.addFileInput(b.path("src/gui/macos_trackpad.m")); + adapter_test.addFileInput(b.path("src/gui/macos_trackpad.h")); + adapter_test.addArg("-o"); + const adapter_bin = adapter_test.addOutputFileArg("macos-trackpad-test"); + const run_adapter = std.Build.Step.Run.create(b, "run macos-trackpad-test"); + run_adapter.addFileArg(adapter_bin); + run_adapter.has_side_effects = true; + b.step("macos-trackpad-test", "test native SDL trackpad decoding and haptics without hardware").dependOn(&run_adapter.step); + }; if (platform == .macos) { const header = b.addTranslateC(.{ |
