forked from NotAShelf/rogged
build: migrate from Make to Zig build system + Just
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I7585121a5ec8e797adc43ba8e30d4ac86a6a6964
This commit is contained in:
parent
62c030527f
commit
7af642612b
7 changed files with 144 additions and 52 deletions
73
build.zig
Normal file
73
build.zig
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
const std = @import("std");
|
||||
|
||||
pub fn build(b: *std.Build) void {
|
||||
const target = b.standardTargetOptions(.{});
|
||||
const optimize = b.standardOptimizeOption(.{});
|
||||
|
||||
// Zig combat library
|
||||
const combat_lib = b.addLibrary(.{
|
||||
.name = "combat",
|
||||
.root_module = b.createModule(.{
|
||||
.root_source_file = b.path("libs/combat/combat.zig"),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.link_libc = true,
|
||||
}),
|
||||
});
|
||||
combat_lib.addIncludePath(b.path("src"));
|
||||
|
||||
// C sources (everything except combat, which is now Zig)
|
||||
const c_sources = [_][]const u8{
|
||||
"src/audio.c",
|
||||
"src/enemy.c",
|
||||
"src/items.c",
|
||||
"src/main.c",
|
||||
"src/map.c",
|
||||
"src/player.c",
|
||||
"src/render.c",
|
||||
"src/rng.c",
|
||||
"src/settings.c",
|
||||
"src/utils.c",
|
||||
};
|
||||
|
||||
const c_flags = [_][]const u8{
|
||||
"-std=c99",
|
||||
"-Wall",
|
||||
"-Wextra",
|
||||
"-O2",
|
||||
};
|
||||
|
||||
// Main executable
|
||||
const exe = b.addExecutable(.{
|
||||
.name = "roguelike",
|
||||
.root_module = b.createModule(.{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.link_libc = true,
|
||||
}),
|
||||
});
|
||||
|
||||
exe.addCSourceFiles(.{
|
||||
.files = &c_sources,
|
||||
.flags = &c_flags,
|
||||
});
|
||||
|
||||
exe.addIncludePath(b.path("src"));
|
||||
exe.linkLibrary(combat_lib);
|
||||
exe.linkSystemLibrary("raylib");
|
||||
exe.linkSystemLibrary("m");
|
||||
exe.linkSystemLibrary("pthread");
|
||||
exe.linkSystemLibrary("dl");
|
||||
exe.linkSystemLibrary("rt");
|
||||
|
||||
b.installArtifact(exe);
|
||||
|
||||
// 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", "Build and run the roguelike");
|
||||
run_step.dependOn(&run_cmd.step);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue