Skip to content

Commit

Permalink
core: remove linux support
Browse files Browse the repository at this point in the history
The `mach.Core` API needs major design changes, and every backend that it supports
today must be updated to account for those API design changes. Unless someone is
actively maintaining and improving the state of a given backend, it slows down our
ability to make those critical changes.

Unfortunately, the backends for X11 and Wayland today are half-baked, nobody is
actively maintaining on or contributing to them, and the Linux CI tests have been
broken for over a month as a result which harms overall stability of Mach.

As a result, this PR removes Linux support from `mach.Core`

Signed-off-by: Stephen Gutekanst <[email protected]>
  • Loading branch information
slimsag committed Aug 25, 2024
1 parent 51e996d commit 21c59b5
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 2,237 deletions.
45 changes: 4 additions & 41 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -102,46 +102,11 @@ pub fn build(b: *std.Build) !void {
if (want_examples) try buildExamples(b, optimize, target, module);
}
if (want_core) {
if (target.result.cpu.arch != .wasm32) {
// TODO: for some reason this is not functional, a Zig bug (only when using this Zig package
// externally):
//
// module.addCSourceFile(.{ .file = b.path("src/core/platform/wayland/wayland.c" });
//
// error: unable to check cache: stat file '/Volumes/data/hexops/mach-core-starter-project/zig-cache//Volumes/data/hexops/mach-core-starter-project/src/core/platform/wayland/wayland.c' failed: FileNotFound
//
// So instead we do this:
const lib = b.addStaticLibrary(.{
.name = "core-wayland",
.target = target,
.optimize = optimize,
});
lib.addCSourceFile(.{
.file = b.path("src/core/wayland/wayland.c"),
});
lib.linkLibC();
module.linkLibrary(lib);

if (b.lazyDependency("x11_headers", .{
.target = target,
.optimize = optimize,
})) |dep| {
module.linkLibrary(dep.artifact("x11-headers"));
lib.linkLibrary(dep.artifact("x11-headers"));
}
if (b.lazyDependency("wayland_headers", .{
if (target.result.isDarwin()) {
if (b.lazyDependency("mach_objc", .{
.target = target,
.optimize = optimize,
})) |dep| {
module.linkLibrary(dep.artifact("wayland-headers"));
lib.linkLibrary(dep.artifact("wayland-headers"));
}
if (target.result.isDarwin()) {
if (b.lazyDependency("mach_objc", .{
.target = target,
.optimize = optimize,
})) |dep| module.addImport("objc", dep.module("mach-objc"));
}
})) |dep| module.addImport("objc", dep.module("mach-objc"));
}
}
if (want_sysaudio) {
Expand Down Expand Up @@ -284,8 +249,6 @@ pub fn build(b: *std.Build) !void {
}

pub const Platform = enum {
x11,
wayland,
wasm,
win32,
darwin,
Expand All @@ -295,7 +258,7 @@ pub const Platform = enum {
if (target.cpu.arch == .wasm32) return .wasm;
if (target.os.tag.isDarwin()) return .darwin;
if (target.os.tag == .windows) return .win32;
return .x11;
return .null;
}
};

Expand Down
4 changes: 0 additions & 4 deletions src/Core.zig
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ pub const Timer = @import("core/Timer.zig");
const Frequency = @import("core/Frequency.zig");

pub const Platform = switch (build_options.core_platform) {
.x11 => @import("core/X11.zig"),
.wayland => @import("core/Wayland.zig"),
.wasm => @panic("TODO: support mach.Core WASM platform"),
.win32 => @import("core/win32.zig"),
.darwin => @import("core/Darwin.zig"),
Expand All @@ -25,8 +23,6 @@ pub const Platform = switch (build_options.core_platform) {
// platform must take control and drive the main loop itself.
pub const supports_non_blocking = switch (build_options.core_platform) {
.win32 => true,
.x11 => true,
.wayland => true,
.wasm => false,
.darwin => false,
.null => false,
Expand Down
Loading

0 comments on commit 21c59b5

Please sign in to comment.