From db186847a7e46dc532a98087e8d86511b8273f6c Mon Sep 17 00:00:00 2001 From: Joshua Holmes <joshua.phillip.holmes@gmail.com> Date: Fri, 3 Jan 2025 08:15:44 +0000 Subject: [PATCH] core: remove `core_platform` build option and remove Null.zig --- build.zig | 2 -- src/Core.zig | 15 +++++--- src/core/Null.zig | 89 ----------------------------------------------- 3 files changed, 10 insertions(+), 96 deletions(-) delete mode 100644 src/core/Null.zig diff --git a/build.zig b/build.zig index 2dd095a010..f74cc6152b 100644 --- a/build.zig +++ b/build.zig @@ -45,7 +45,6 @@ pub fn build(b: *std.Build) !void { const target = b.standardTargetOptions(.{}); const sysgpu_backend = b.option(SysgpuBackend, "sysgpu_backend", "sysgpu API backend") orelse .default; - const core_platform = b.option(Platform, "core_platform", "mach core platform to use") orelse Platform.fromTarget(target.result); const build_examples = b.option(bool, "examples", "build/install examples specifically"); const build_libs = b.option(bool, "libs", "build/install libraries specifically"); @@ -68,7 +67,6 @@ pub fn build(b: *std.Build) !void { build_options.addOption(bool, "want_sysaudio", want_sysaudio); build_options.addOption(bool, "want_sysgpu", want_sysgpu); build_options.addOption(SysgpuBackend, "sysgpu_backend", sysgpu_backend); - build_options.addOption(Platform, "core_platform", core_platform); var examples = [_]Example{ .{ .name = "core-custom-entrypoint", .deps = &.{} }, diff --git a/src/Core.zig b/src/Core.zig index 192004db1d..6c87365f4b 100644 --- a/src/Core.zig +++ b/src/Core.zig @@ -420,12 +420,17 @@ pub fn detectBackendType(allocator: std.mem.Allocator) !gpu.BackendType { @panic("unknown MACH_GPU_BACKEND type"); } -const Platform = switch (build_options.core_platform) { - .wasm => @panic("TODO: support mach.Core WASM platform"), +const Platform = switch (builtin.target.os.tag) { + .wasi => @panic("TODO: support mach.Core WASM platform"), + .ios => @panic("TODO: support mach.Core IOS platform"), .windows => @import("core/Windows.zig"), - .linux => @import("core/Linux.zig"), - .darwin => @import("core/Darwin.zig"), - .null => @import("core/Null.zig"), + .linux => blk: { + if (builtin.target.abi.isAndroid()) + @panic("TODO: support mach.Core Android platform"); + break :blk @import("core/Linux.zig"); + }, + .macos => @import("core/Darwin.zig"), + else => {}, }; pub const InputState = struct { diff --git a/src/core/Null.zig b/src/core/Null.zig deleted file mode 100644 index a222f2e3e4..0000000000 --- a/src/core/Null.zig +++ /dev/null @@ -1,89 +0,0 @@ -// The Null backend serves no purpose other than to show what the barebones structure of a Mach -// platform backend looks like. - -const std = @import("std"); -const mach = @import("../main.zig"); -const Core = @import("../Core.zig"); -const gpu = mach.gpu; -//const InitOptions = Core.InitOptions; -const Event = Core.Event; -const KeyEvent = Core.KeyEvent; -const MouseButtonEvent = Core.MouseButtonEvent; -const MouseButton = Core.MouseButton; -const Size = Core.Size; -const DisplayMode = Core.DisplayMode; -const CursorShape = Core.CursorShape; -const VSyncMode = Core.VSyncMode; -const CursorMode = Core.CursorMode; -const Position = Core.Position; -const Key = Core.Key; -const KeyMods = Core.KeyMods; - -const log = std.log.scoped(.mach); - -pub const Null = @This(); - -allocator: std.mem.Allocator, -core: *Core, -modifiers: KeyMods, -title: [:0]u8, -display_mode: DisplayMode, -vsync_mode: VSyncMode, -cursor_mode: CursorMode, -cursor_shape: CursorShape, -border: bool, -headless: bool, -refresh_rate: u32, -size: Size, -surface_descriptor: gpu.Surface.Descriptor, - -pub fn init( - nul: *Null, - core: *Core, - //options: InitOptions, -) !void { - _ = nul; - //_ = options; - _ = core; - return; -} - -pub fn deinit(_: *Null) void { - return; -} - -pub fn update(_: *Null) !void { - return; -} - -pub fn setTitle(_: *Null, _: [:0]const u8) void { - return; -} - -pub fn setDisplayMode(_: *Null, _: DisplayMode) void { - return; -} - -pub fn setBorder(_: *Null, _: bool) void { - return; -} - -pub fn setHeadless(_: *Null, _: bool) void { - return; -} - -pub fn setVSync(_: *Null, _: VSyncMode) void { - return; -} - -pub fn setSize(_: *Null, _: Size) void { - return; -} - -pub fn setCursorMode(_: *Null, _: CursorMode) void { - return; -} - -pub fn setCursorShape(_: *Null, _: CursorShape) void { - return; -}