glfw: fix cimport workaround errors for linux/windows

This commit is contained in:
Ali Chraghi 2022-09-02 11:06:10 +04:30 committed by Stephen Gutekanst
parent a945046224
commit 669ef41219
7 changed files with 40 additions and 33 deletions

View file

@ -40,28 +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 or !@import("builtin").target.isDarwin())
@cImport({
@cDefine("GLFW_INCLUDE_VULKAN", "1");
@cInclude("GLFW/glfw3.h");
if (options.win32) @cDefine("GLFW_EXPOSE_NATIVE_WIN32", "1");
if (options.wgl) @cDefine("GLFW_EXPOSE_NATIVE_WGL", "1");
if (options.cocoa) @cDefine("GLFW_EXPOSE_NATIVE_COCOA", "1");
if (options.nsgl) @cDefine("GLFW_EXPOSE_NATIVE_NGSL", "1");
if (options.x11) @cDefine("GLFW_EXPOSE_NATIVE_X11", "1");
if (options.glx) @cDefine("GLFW_EXPOSE_NATIVE_GLX", "1");
if (options.wayland) @cDefine("GLFW_EXPOSE_NATIVE_WAYLAND", "1");
if (options.egl) @cDefine("GLFW_EXPOSE_NATIVE_EGL", "1");
if (options.osmesa) @cDefine("GLFW_EXPOSE_NATIVE_OSMESA", "1");
@cInclude("GLFW/glfw3native.h");
})
else
// TODO(self-hosted): HACK: workaround https://github.com/ziglang/zig/issues/12483
//
// Extracted from a build using stage1 from zig-cache/ (`cimport.zig`)
// Then find+replace `= ?fn` -> `= ?*const fn`
@import("cimport1.zig");
const native = @import("c_native.zig").import(options);
return struct {
/// Returns the adapter device name of the specified monitor.