glfw: correct Linux -> MacOS cross compilation (header includes)
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
a60232e06b
commit
d0ff7bb2e9
1 changed files with 25 additions and 22 deletions
|
@ -74,6 +74,7 @@ pub fn link(b: *Builder, step: *std.build.LibExeObjStep, options: Options) void
|
||||||
lib.addCSourceFiles(sources.items, &.{});
|
lib.addCSourceFiles(sources.items, &.{});
|
||||||
},
|
},
|
||||||
.macos => {
|
.macos => {
|
||||||
|
includeSdkMacOS(b, lib);
|
||||||
var sources = std.ArrayList([]const u8).init(&arena.allocator);
|
var sources = std.ArrayList([]const u8).init(&arena.allocator);
|
||||||
for ([_][]const u8{
|
for ([_][]const u8{
|
||||||
// MacOS-specific sources
|
// MacOS-specific sources
|
||||||
|
@ -176,6 +177,22 @@ fn linkGLFW(b: *Builder, step: *std.build.LibExeObjStep, options: Options) void
|
||||||
// TODO(slimsag): create sdk-windows
|
// TODO(slimsag): create sdk-windows
|
||||||
},
|
},
|
||||||
.macos => {
|
.macos => {
|
||||||
|
includeSdkMacOS(b, step);
|
||||||
|
step.linkFramework("Cocoa");
|
||||||
|
step.linkFramework("IOKit");
|
||||||
|
step.linkFramework("CoreFoundation");
|
||||||
|
if (options.opengl) {
|
||||||
|
step.linkFramework("OpenGL");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
else => {
|
||||||
|
// Assume Linux-like
|
||||||
|
// TODO(slimsag): create sdk-linux
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn includeSdkMacOS(b: *Builder, step: *std.build.LibExeObjStep) void {
|
||||||
const sdk_root_dir = getSdkRoot(b.allocator, "sdk-macos-11.3") catch unreachable;
|
const sdk_root_dir = getSdkRoot(b.allocator, "sdk-macos-11.3") catch unreachable;
|
||||||
defer b.allocator.free(sdk_root_dir);
|
defer b.allocator.free(sdk_root_dir);
|
||||||
|
|
||||||
|
@ -195,21 +212,7 @@ fn linkGLFW(b: *Builder, step: *std.build.LibExeObjStep, options: Options) void
|
||||||
// Presumably has something to do with https://github.com/ziglang/zig/issues/6996 - I think zld doesn't consider addLibPath/addFrameworkDir
|
// Presumably has something to do with https://github.com/ziglang/zig/issues/6996 - I think zld doesn't consider addLibPath/addFrameworkDir
|
||||||
// resolution as part of dependant libs: https://github.com/ziglang/zig/blob/2d855745f91852af92ad970feef96e55919993d3/src/link/MachO/Dylib.zig#L477-L483
|
// resolution as part of dependant libs: https://github.com/ziglang/zig/blob/2d855745f91852af92ad970feef96e55919993d3/src/link/MachO/Dylib.zig#L477-L483
|
||||||
var sdk_sysroot = std.fs.path.join(b.allocator, &.{ sdk_root_dir, "root/" }) catch unreachable;
|
var sdk_sysroot = std.fs.path.join(b.allocator, &.{ sdk_root_dir, "root/" }) catch unreachable;
|
||||||
//defer b.allocator.free(sdk_sysroot); // TODO(slimsag): memory management here is terrible
|
b.sysroot = sdk_sysroot; // TODO(slimsag): leaks, b.sysroot doesn't get free'd by builder?
|
||||||
b.sysroot = sdk_sysroot;
|
|
||||||
|
|
||||||
step.linkFramework("Cocoa");
|
|
||||||
step.linkFramework("IOKit");
|
|
||||||
step.linkFramework("CoreFoundation");
|
|
||||||
if (options.opengl) {
|
|
||||||
step.linkFramework("OpenGL");
|
|
||||||
}
|
|
||||||
},
|
|
||||||
else => {
|
|
||||||
// Assume Linux-like
|
|
||||||
// TODO(slimsag): create sdk-linux
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Caller owns returned memory.
|
// Caller owns returned memory.
|
||||||
|
|
Loading…
Add table
Reference in a new issue