From 4dad52926d917c7e714511af554038e2f7ddfa09 Mon Sep 17 00:00:00 2001 From: Kai Angulo <116330012+sinnwrig@users.noreply.github.com> Date: Sun, 2 Jun 2024 20:53:13 -0700 Subject: [PATCH] Added library macro definitions --- build.zig | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/build.zig b/build.zig index 03d5258a..01ee438c 100644 --- a/build.zig +++ b/build.zig @@ -1,5 +1,7 @@ const std = @import("std"); +const log = std.log.scoped(.spirv_tools); + pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); @@ -10,6 +12,30 @@ pub fn build(b: *std.Build) void { .target = target, .optimize = optimize, }); + + const tag = target.result.os.tag; + + if (tag == .windows) { + lib.defineCMacro("SPIRV_WINDOWS", ""); + } else if (tag == .linux) { + lib.defineCMacro("SPIRV_LINUX", ""); + } else if (tag == .macos) { + lib.defineCMacro("SPIRV_MAC", ""); + } else if (tag == .ios) { + lib.defineCMacro("SPIRV_IOS", ""); + } else if (tag == .tvos) { + lib.defineCMacro("SPIRV_TVOS", ""); + } else if (tag == .kfreebsd) { + lib.defineCMacro("SPIRV_FREEBSD", ""); + } else if (tag == .openbsd) { + lib.defineCMacro("SPIRV_OPENBSD", ""); + } else if (tag == .fuchsia) { + lib.defineCMacro("SPIRV_FUCHSIA", ""); + } else { + log.err("Incompatible target platform.", .{}); + std.process.exit(1); + } + lib.linkLibCpp(); lib.addCSourceFiles(.{ .files = sources }); lib.addIncludePath(b.path("."));