Files
WrldBox/build.zig
swim67667 c17dfc94ce
Some checks failed
Build Project / build (ubuntu-latest) (push) Failing after 12m33s
added multi-compiling stuff (only works on my mac for now)
2026-06-28 16:40:20 -04:00

90 lines
3.0 KiB
Zig

const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const exe = b.addExecutable(.{
.name = "wrldbox",
.root_module = b.createModule(.{
.target = target,
.optimize = optimize,
}),
});
// C Source files
exe.root_module.addCSourceFiles(.{
.files = &.{
"src/main.c",
"src/world.c",
"src/player.c",
"src/physics.c",
"src/render.c",
"src/collision.c",
},
.flags = &.{ "-O2", "-Wall" },
});
// Raylib source files (rutils.c removed as it's part of rcore.c now)
exe.root_module.addCSourceFiles(.{
.files = &.{
"raylib_src/src/rcore.c",
"raylib_src/src/rshapes.c",
"raylib_src/src/rtextures.c",
"raylib_src/src/rtext.c",
"raylib_src/src/rmodels.c",
"raylib_src/src/raudio.c",
"raylib_src/src/rglfw.c",
},
.flags = &.{ "-O2", "-Wall" },
});
// Header include paths
exe.root_module.addIncludePath(b.path("include"));
exe.root_module.addIncludePath(b.path("raylib_src/src"));
exe.root_module.addIncludePath(b.path("raylib_src/src/external/glfw/include"));
// Platform-specific configuration
const t = target.result;
if (t.os.tag == .linux) {
exe.root_module.addCMacro("_GNU_SOURCE", "");
exe.root_module.addCMacro("PLATFORM_DESKTOP", "");
exe.root_module.addCMacro("_GLFW_X11", "");
exe.root_module.linkSystemLibrary("dl", .{});
exe.root_module.linkSystemLibrary("rt", .{});
exe.root_module.linkSystemLibrary("m", .{});
exe.root_module.linkSystemLibrary("pthread", .{});
} else if (t.os.tag == .windows) {
exe.root_module.addCMacro("PLATFORM_DESKTOP", "");
exe.root_module.addCMacro("_GLFW_WIN32", "");
exe.root_module.linkSystemLibrary("opengl32", .{});
exe.root_module.linkSystemLibrary("gdi32", .{});
exe.root_module.linkSystemLibrary("winmm", .{});
exe.root_module.linkSystemLibrary("user32", .{});
exe.root_module.linkSystemLibrary("shell32", .{});
} else if (t.os.tag == .macos) {
exe.root_module.addCMacro("PLATFORM_DESKTOP", "");
exe.root_module.addCMacro("_GLFW_COCOA", "");
exe.root_module.linkFramework("OpenGL", .{});
exe.root_module.linkFramework("Cocoa", .{});
exe.root_module.linkFramework("IOKit", .{});
exe.root_module.linkFramework("CoreVideo", .{});
}
// Explicitly link LibC using the 0.16.0 boolean field
exe.root_module.link_libc = true;
b.installArtifact(exe);
// Standard run step
const run_cmd = b.addRunArtifact(exe);
run_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| {
run_cmd.addArgs(args);
}
const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step);
}