core: remove core_platform build option and remove Null.zig

This commit is contained in:
Joshua Holmes 2025-01-03 08:15:44 +00:00 committed by Emi Gutekanst
parent caf297512c
commit db186847a7
3 changed files with 10 additions and 96 deletions

View file

@ -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 = &.{} },

View file

@ -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 {

View file

@ -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;
}