switch to zig build system and add conways game of life

This commit is contained in:
Squibid 2025-12-23 12:39:16 -05:00
parent 408de3a337
commit f219f0c5ce
Signed by: squibid
GPG key ID: BECE5684D3C4005D
12 changed files with 227 additions and 73 deletions

81
build.zig Normal file
View file

@ -0,0 +1,81 @@
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const ds = b.dependency("ds", .{});
const cargs = b.dependency("cargs", .{});
const log = b.dependency("log.c", .{});
const exe = b.addExecutable(.{
.name = "wom",
.root_module = b.createModule(.{
.target = target,
.optimize = optimize,
.link_libc = true,
}),
});
const games = b.addLibrary(.{
.name = "games",
.linkage = .static,
.root_module = b.createModule(.{
.root_source_file = b.path("src/subcmds/games.zig"),
.target = target,
.optimize = optimize,
.link_libc = true,
}),
});
games.pie = true;
exe.root_module.addCSourceFiles(.{
.files = &.{
"src/main.c",
"src/conf.c",
"src/api.c",
"src/subcmds/clock.c",
"src/subcmds/dev.c",
"src/subcmds/motd.c",
"src/subcmds/project.c",
"src/subcmds/subcmds.c",
"src/lua/wom.c",
"src/lua/wom_fs.c",
},
.flags = &.{
"-DVERSION=\"hi\"",
"-std=c23",
"-D_GNU_SOURCE",
"-MJ compile_commands.json",
}
});
exe.root_module.linkLibrary(games);
exe.root_module.linkSystemLibrary("lua", .{});
exe.root_module.addIncludePath(b.path("include"));
exe.root_module.addLibraryPath(ds.path("."));
exe.root_module.addLibraryPath(cargs.path("src"));
exe.root_module.addLibraryPath(log.path("src"));
exe.addCSourceFile(.{ .file = ds.builder.path("./ds.c") });
exe.addCSourceFile(.{ .file = cargs.builder.path("src/cargs.c") });
exe.addCSourceFile(.{ .file = log.builder.path("./src/log.c") });
exe.root_module.addIncludePath(ds.path("."));
exe.root_module.addIncludePath(cargs.path("include"));
exe.root_module.addIncludePath(log.path("src"));
b.installArtifact(exe);
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);
}