summaryrefslogtreecommitdiff
path: root/build.zig
diff options
context:
space:
mode:
Diffstat (limited to 'build.zig')
-rw-r--r--build.zig24
1 files changed, 24 insertions, 0 deletions
diff --git a/build.zig b/build.zig
index 4485140d..a04880bb 100644
--- a/build.zig
+++ b/build.zig
@@ -1076,12 +1076,36 @@ 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());
+ 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 adapter_test = b.addSystemCommand(&.{ "xcrun", "clang", "-fobjc-arc", "-O1", "-framework", "Cocoa", "-I" });
+ adapter_test.addDirectoryArg(dep.path("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);
+ }
}
gm.linkLibrary(freetype.?);
// HarfBuzz from source, like FreeType: its FreeType integration