commit 96b8009bb3bc4d66634cee9a197858c426e74517
parent 1feb12cadace4707f693922eaea17b008f288f0f
Author: Christian Ermann <christianermann@gmail.com>
Date: Fri, 19 Apr 2024 22:36:33 -0400
Added zig build script
Diffstat:
2 files changed, 47 insertions(+), 1 deletion(-)
diff --git a/build.zig b/build.zig
@@ -0,0 +1,46 @@
+const std = @import("std");
+
+pub fn build(b: *std.Build) !void {
+ const target = b.standardTargetOptions(.{});
+ const optimize = b.standardOptimizeOption(.{});
+
+ const lib = b.addStaticLibrary(.{
+ .name = "engine",
+ .target = target,
+ .optimize = optimize,
+ });
+
+ var sources = std.ArrayList([]const u8).init(b.allocator);
+ {
+ var dir = try std.fs.cwd().openIterableDir("src/engine", .{});
+ var walker = try dir.walk(b.allocator);
+ defer walker.deinit();
+
+ while (try walker.next()) |entry| {
+ const ext = std.fs.path.extension(entry.basename);
+ if (std.mem.eql(u8, ext, ".c")) {
+ try sources.append(b.pathJoin(&.{ "src/engine", entry.path }));
+ }
+ }
+ }
+ lib.addCSourceFiles(sources.items, &[_][]const u8{});
+ lib.addIncludePath(std.build.LazyPath.relative("include"));
+ lib.addIncludePath(std.build.LazyPath.relative("include/engine"));
+
+ const exe = b.addExecutable(.{
+ .name = "app",
+ .target = target,
+ .optimize = optimize,
+ });
+ exe.addCSourceFile(.{
+ .file = std.build.LazyPath.relative("src/app/main.c"),
+ .flags = &.{},
+ });
+ exe.addIncludePath(std.build.LazyPath.relative("include"));
+ exe.linkLibrary(lib);
+ exe.addObjectFile(std.build.LazyPath.relative("lib/libglfw3.a"));
+ exe.linkFramework("Cocoa");
+ exe.linkFramework("IOKit");
+ exe.linkFramework("OpenGL");
+ b.installArtifact(exe);
+}
diff --git a/src/engine/app.c b/src/engine/app.c
@@ -46,7 +46,7 @@ App *App_make(const AppInfo *app_info)
glfwMakeContextCurrent(app->window);
- if (!gladLoadGLLoader(glfwGetProcAddress))
+ if (!gladLoadGLLoader((void*)glfwGetProcAddress))
{
LOGF("Failed to initialized GLAD.");
App_free(app);