remove intermediate static lib (#24)

This commit is contained in:
Matthew Knight 2021-09-05 18:49:45 -07:00 committed by GitHub
parent 8d8289fb43
commit b3729e7323
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -40,10 +40,6 @@ pub fn link(b: *Builder, step: *std.build.LibExeObjStep, options: Options) void
var arena = std.heap.ArenaAllocator.init(b.allocator); var arena = std.heap.ArenaAllocator.init(b.allocator);
defer arena.deinit(); defer arena.deinit();
const lib = b.addStaticLibrary("engine", "src/main.zig");
lib.setBuildMode(step.build_mode);
lib.setTarget(step.target);
const target = (std.zig.system.NativeTargetInfo.detect(b.allocator, step.target) catch unreachable).target; const target = (std.zig.system.NativeTargetInfo.detect(b.allocator, step.target) catch unreachable).target;
switch (target.os.tag) { switch (target.os.tag) {
.windows => { .windows => {
@ -71,10 +67,10 @@ pub fn link(b: *Builder, step: *std.build.LibExeObjStep, options: Options) void
var abs_path = std.fs.path.join(&arena.allocator, &.{ thisDir(), path }) catch unreachable; var abs_path = std.fs.path.join(&arena.allocator, &.{ thisDir(), path }) catch unreachable;
sources.append(abs_path) catch unreachable; sources.append(abs_path) catch unreachable;
} }
lib.addCSourceFiles(sources.items, &.{"-D_GLFW_WIN32"}); step.addCSourceFiles(sources.items, &.{"-D_GLFW_WIN32"});
}, },
.macos => { .macos => {
includeSdkMacOS(b, lib); includeSdkMacOS(b, step);
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
@ -99,7 +95,7 @@ pub fn link(b: *Builder, step: *std.build.LibExeObjStep, options: Options) void
var abs_path = std.fs.path.join(&arena.allocator, &.{ thisDir(), path }) catch unreachable; var abs_path = std.fs.path.join(&arena.allocator, &.{ thisDir(), path }) catch unreachable;
sources.append(abs_path) catch unreachable; sources.append(abs_path) catch unreachable;
} }
lib.addCSourceFiles(sources.items, &.{"-D_GLFW_COCOA"}); step.addCSourceFiles(sources.items, &.{"-D_GLFW_COCOA"});
}, },
else => { else => {
// Assume Linux-like // Assume Linux-like
@ -112,7 +108,7 @@ pub fn link(b: *Builder, step: *std.build.LibExeObjStep, options: Options) void
// thread 2004762 panic: attempt to unwrap error: LLDReportedFailure // thread 2004762 panic: attempt to unwrap error: LLDReportedFailure
// ``` // ```
step.target.abi = .gnu; step.target.abi = .gnu;
lib.setTarget(step.target); step.setTarget(step.target);
var general_sources = std.ArrayList([]const u8).init(&arena.allocator); var general_sources = std.ArrayList([]const u8).init(&arena.allocator);
const flag = switch (options.linux_window_manager) { const flag = switch (options.linux_window_manager) {
@ -138,7 +134,7 @@ pub fn link(b: *Builder, step: *std.build.LibExeObjStep, options: Options) void
var abs_path = std.fs.path.join(&arena.allocator, &.{ thisDir(), path }) catch unreachable; var abs_path = std.fs.path.join(&arena.allocator, &.{ thisDir(), path }) catch unreachable;
general_sources.append(abs_path) catch unreachable; general_sources.append(abs_path) catch unreachable;
} }
lib.addCSourceFiles(general_sources.items, &.{flag}); step.addCSourceFiles(general_sources.items, &.{flag});
switch (options.linux_window_manager) { switch (options.linux_window_manager) {
.X11 => { .X11 => {
@ -153,7 +149,7 @@ pub fn link(b: *Builder, step: *std.build.LibExeObjStep, options: Options) void
var abs_path = std.fs.path.join(&arena.allocator, &.{ thisDir(), path }) catch unreachable; var abs_path = std.fs.path.join(&arena.allocator, &.{ thisDir(), path }) catch unreachable;
x11_sources.append(abs_path) catch unreachable; x11_sources.append(abs_path) catch unreachable;
} }
lib.addCSourceFiles(x11_sources.items, &.{flag}); step.addCSourceFiles(x11_sources.items, &.{flag});
}, },
.Wayland => { .Wayland => {
var wayland_sources = std.ArrayList([]const u8).init(&arena.allocator); var wayland_sources = std.ArrayList([]const u8).init(&arena.allocator);
@ -165,15 +161,11 @@ pub fn link(b: *Builder, step: *std.build.LibExeObjStep, options: Options) void
var abs_path = std.fs.path.join(&arena.allocator, &.{ thisDir(), path }) catch unreachable; var abs_path = std.fs.path.join(&arena.allocator, &.{ thisDir(), path }) catch unreachable;
wayland_sources.append(abs_path) catch unreachable; wayland_sources.append(abs_path) catch unreachable;
} }
lib.addCSourceFiles(wayland_sources.items, &.{flag}); step.addCSourceFiles(wayland_sources.items, &.{flag});
}, },
} }
}, },
} }
linkGLFW(b, lib, options);
lib.install();
step.linkLibrary(lib);
linkGLFW(b, step, options); linkGLFW(b, step, options);
} }