From 1e0fa20622b8a5457f69934f5bb203d0f028632e Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Sat, 27 Aug 2022 11:19:57 -0700 Subject: [PATCH] all: employ self-hosted @cImport hack only on Darwin targets This is an poor approximation for the host OS running Darwin, which is good enough for now. In practice this means macOS works but can't cross-compile (until the cImport issue is fixed in Zig itself), but Windows/Linux are unaffected and should be able to build natively and cross-compile. Signed-off-by: Stephen Gutekanst --- libs/freetype/src/c.zig | 2 +- libs/glfw/src/c.zig | 2 +- libs/glfw/src/native.zig | 2 +- libs/gpu/src/dawn_impl.zig | 2 +- libs/sysaudio/soundio/c.zig | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libs/freetype/src/c.zig b/libs/freetype/src/c.zig index ce33d405..3d681b5b 100644 --- a/libs/freetype/src/c.zig +++ b/libs/freetype/src/c.zig @@ -1,4 +1,4 @@ -pub usingnamespace if (@import("builtin").zig_backend == .stage1) +pub usingnamespace if (@import("builtin").zig_backend == .stage1 or !@import("builtin").target.isDarwin()) @cImport({ @cInclude("hb-ft.h"); @cInclude("freetype/ftadvanc.h"); diff --git a/libs/glfw/src/c.zig b/libs/glfw/src/c.zig index ece61c9a..10268859 100644 --- a/libs/glfw/src/c.zig +++ b/libs/glfw/src/c.zig @@ -1,4 +1,4 @@ -pub const c = if (@import("builtin").zig_backend == .stage1) +pub const c = if (@import("builtin").zig_backend == .stage1 or !@import("builtin").target.isDarwin()) @cImport({ @cDefine("GLFW_INCLUDE_VULKAN", "1"); @cInclude("GLFW/glfw3.h"); diff --git a/libs/glfw/src/native.zig b/libs/glfw/src/native.zig index fff86a1d..75dd1f79 100644 --- a/libs/glfw/src/native.zig +++ b/libs/glfw/src/native.zig @@ -40,7 +40,7 @@ pub const BackendOptions = struct { /// The chosen backends must match those the library was compiled for. Failure to do so /// will cause a link-time error. pub fn Native(comptime options: BackendOptions) type { - const native = if (@import("builtin").zig_backend == .stage1) + const native = if (@import("builtin").zig_backend == .stage1 or !@import("builtin").target.isDarwin()) @cImport({ @cDefine("GLFW_INCLUDE_VULKAN", "1"); @cInclude("GLFW/glfw3.h"); diff --git a/libs/gpu/src/dawn_impl.zig b/libs/gpu/src/dawn_impl.zig index 36f59cd1..245a9847 100644 --- a/libs/gpu/src/dawn_impl.zig +++ b/libs/gpu/src/dawn_impl.zig @@ -1,6 +1,6 @@ const gpu = @import("main.zig"); -const c = if (@import("builtin").zig_backend == .stage1) +const c = if (@import("builtin").zig_backend == .stage1 or !@import("builtin").target.isDarwin()) @cImport({ @cInclude("dawn/webgpu.h"); @cInclude("mach_dawn.h"); diff --git a/libs/sysaudio/soundio/c.zig b/libs/sysaudio/soundio/c.zig index 24ade795..5940f578 100644 --- a/libs/sysaudio/soundio/c.zig +++ b/libs/sysaudio/soundio/c.zig @@ -1,4 +1,4 @@ -pub usingnamespace if (@import("builtin").zig_backend == .stage1) +pub usingnamespace if (@import("builtin").zig_backend == .stage1 or !@import("builtin").target.isDarwin()) @cImport({ @cInclude("soundio/soundio.h"); })