Mac Dev PR 1 (#336)

* Add libraries for macos + deps_local

* Tab characters

* build.zig.zon: MacOS comment, use relative path

* build.zig.zon: Add dot to url field

* build.zig: lazily load deps_local

* build.zig: revert bad debug edit
This commit is contained in:
archbirdplus 2024-04-28 02:20:20 -07:00 committed by GitHub
parent 50d9c9a825
commit 1a6454a92c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 29 additions and 5 deletions

View File

@ -21,10 +21,17 @@ pub fn build(b: *std.Build) !void {
exe.linkLibC(); exe.linkLibC();
exe.linkLibCpp(); exe.linkLibCpp();
const deps = b.dependency("deps", .{ // For the time being, MacOS cubyz_deps will not have released binaries.
const depsName = if (t.os.tag == .macos) "deps_local" else "deps";
const deps = b.lazyDependency(depsName, .{
.target = target, .target = target,
.optimize = optimize, .optimize = optimize,
}); }) orelse {
// Lazy dependencies with a `url` field will fail here the first time.
// build.zig will restart and try again.
std.log.info("Downloading dependency {s}.", .{depsName});
return;
};
exe.addLibraryPath(deps.path("lib")); exe.addLibraryPath(deps.path("lib"));
exe.addIncludePath(deps.path("include")); exe.addIncludePath(deps.path("include"));
@ -42,6 +49,19 @@ pub fn build(b: *std.Build) !void {
exe.linkSystemLibrary("asound"); exe.linkSystemLibrary("asound");
exe.linkSystemLibrary("x11"); exe.linkSystemLibrary("x11");
exe.linkSystemLibrary("GL"); exe.linkSystemLibrary("GL");
} else if(t.os.tag == .macos) {
exe.linkFramework("AudioUnit");
exe.linkFramework("AudioToolbox");
exe.linkFramework("CoreAudio");
exe.linkFramework("CoreServices");
exe.linkFramework("Foundation");
exe.linkFramework("IOKit");
exe.linkFramework("Cocoa");
exe.linkFramework("QuartzCore");
exe.linkSystemLibrary("GL");
exe.linkSystemLibrary("X11");
exe.addLibraryPath(.{.path="/usr/local/GL/lib"});
exe.addLibraryPath(.{.path="/opt/X11/lib"});
} else { } else {
std.log.err("Unsupported target: {}\n", .{t.os.tag}); std.log.err("Unsupported target: {}\n", .{t.os.tag});
} }

View File

@ -3,10 +3,14 @@
.version = "0.0.0", .version = "0.0.0",
.paths = .{""}, .paths = .{""},
.dependencies = .{ .dependencies = .{
.deps_local = .{
.path = "../Cubyz-libs/zig-out", // macos has no official deps release
.lazy = true,
},
.deps = .{ .deps = .{
//.url = "file:///home/mint/Cubyz-libs/zig-out.tar.gz", // fetching the lib from the local folder //.url = "file:../Cubyz-libs/zig-out.tar.gz", // fetching the lib from the local folder
.url = "https://github.com/PixelGuys/Cubyz-libs/releases/download/2/zig-out.tar.gz", .url = "https://github.com/PixelGuys/Cubyz-libs/releases/download/2/zig-out.tar.gz",
.hash = "12201446153e8822c020a10199880fae5fac7eb3f1e3f7c7a9b653e58914fa3e2223", .hash = "12201446153e8822c020a10199880fae5fac7eb3f1e3f7c7a9b653e58914fa3e2223",
}, },
}, },
} }

View File

@ -451,4 +451,4 @@ pub fn main() void {
test "abc" { test "abc" {
_ = @import("json.zig"); _ = @import("json.zig");
} }