Files
zig-a-puzzle-a-day/build.zig
T
2026-05-28 13:30:14 +02:00

58 lines
1.8 KiB
Zig

const std = @import("std");
const Translator = @import("translate_c").Translator;
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
// It's also possible to define more custom flags to toggle optional features
// of this build script using `b.option()`. All defined flags (including
// target and optimize options) will be listed when running `zig build --help`
// in this directory.
const llvm = b.option(bool, "llvm", "Build with llvm");
const translate_c = b.dependency("translate_c", .{});
const t: Translator = .init(translate_c, .{
.c_source_file = b.path("src/c.h"),
.target = target,
.optimize = optimize,
.default_init = false,
.warnings = .@"error",
});
const mod = b.addModule("puzzle", .{
.root_source_file = b.path("src/root.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "c", .module = t.mod },
},
});
const exe = b.addExecutable(.{
.name = "wl-main",
.linkage = .static,
.use_llvm = llvm,
.root_module = b.createModule(.{
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "puzzle", .module = mod },
},
}),
});
exe.root_module.link_libc = false;
exe.root_module.linkSystemLibrary("wayland-client", .{ .preferred_link_mode = .static });
exe.root_module.linkSystemLibrary("xkbcommon", .{ .preferred_link_mode = .static });
exe.root_module.addIncludePath(b.path("src"));
exe.root_module.addCSourceFiles(.{
.language = .c,
.files = &.{ "src/xdg-shell.c", "src/stbi.c", },
});
b.installArtifact(exe);
}