diff options
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(.{ |
