gpu: pretranslate @cImport to workaround self-hosted compiler bug

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2022-08-20 01:18:29 -07:00
parent 80e127b5ae
commit 51932241c1
2 changed files with 2887 additions and 4 deletions

View file

@ -1,9 +1,18 @@
const gpu = @import("main.zig");
const c = @cImport({
@cInclude("dawn/webgpu.h");
@cInclude("mach_dawn.h");
});
const c = if (@import("builtin").zig_backend == .stage1)
@cImport({
@cInclude("dawn/webgpu.h");
@cInclude("mach_dawn.h");
})
else
// HACK: workaround https://github.com/ziglang/zig/issues/12483
//
// cd gpu/src/
// echo '#include <dawn/webgpu.h>' > tmp.c
// echo '#include "mach_dawn.h"' >> tmp.c
// zig translate-c tmp.c -I ../zig-cache/mach/gpu-dawn/release-777728f/include/ > dawn_webgpu_h.zig
@import("dawn_webgpu_h.zig");
var procs: c.DawnProcTable = undefined;

2874
gpu/src/dawn_webgpu_h.zig Normal file

File diff suppressed because it is too large Load diff