dotfiles/scripts/mzteinit/build.zig

62 lines
1.8 KiB
Zig
Raw Normal View History

2022-09-08 17:03:54 +02:00
const std = @import("std");
2023-06-27 22:31:02 +02:00
const common = @import("build_common.zig");
2022-09-08 17:03:54 +02:00
2023-06-27 22:31:02 +02:00
pub fn build(b: *std.build.Builder) !void {
2022-09-08 17:03:54 +02:00
const target = b.standardTargetOptions(.{});
2023-10-31 20:40:56 +01:00
const optimize = b.standardOptimizeOption(.{});
const ansi_term_mod = b.dependency("ansi_term", .{}).module("ansi-term");
2022-09-08 17:03:54 +02:00
const exe = b.addExecutable(.{
.name = "mzteinit",
.root_source_file = .{ .path = "src/main.zig" },
.target = target,
2023-10-31 20:40:56 +01:00
.optimize = optimize,
});
const mzteinitctl = b.addExecutable(.{
.name = "mzteinitctl",
.root_source_file = .{ .path = "src/mzteinitctl.zig" },
.target = target,
.optimize = optimize,
});
2022-09-08 17:03:54 +02:00
2023-10-31 20:40:56 +01:00
exe.strip = switch (optimize) {
.ReleaseFast, .ReleaseSmall => true,
.ReleaseSafe, .Debug => false,
};
mzteinitctl.strip = exe.strip;
2022-09-08 17:03:54 +02:00
2023-10-31 20:40:56 +01:00
inline for (.{ mzteinitctl, exe }) |e| {
e.addModule("ansi-term", ansi_term_mod);
}
2022-09-08 17:03:54 +02:00
2023-06-27 22:31:02 +02:00
const cg_opt = try common.confgenGet(struct {
2023-06-27 23:20:35 +02:00
gtk_theme: []u8, // TODO: this being non-const is a workaround for an std bug
2023-06-27 22:31:02 +02:00
}, "../..", b.allocator);
const opts = b.addOptions();
opts.addOption([]const u8, "gtk_theme", cg_opt.gtk_theme);
exe.addOptions("opts", opts);
2023-04-17 21:29:15 +02:00
b.installArtifact(exe);
2023-10-31 20:40:56 +01:00
b.installArtifact(mzteinitctl);
const run_mzteinitctl = b.addRunArtifact(mzteinitctl);
run_mzteinitctl.step.dependOn(b.getInstallStep());
2022-09-08 17:03:54 +02:00
2023-04-17 21:29:15 +02:00
const run_cmd = b.addRunArtifact(exe);
2022-09-08 17:03:54 +02:00
run_cmd.step.dependOn(b.getInstallStep());
2023-10-31 20:40:56 +01:00
2022-09-08 17:03:54 +02:00
if (b.args) |args| {
2023-10-31 20:40:56 +01:00
run_mzteinitctl.addArgs(args);
2022-09-08 17:03:54 +02:00
run_cmd.addArgs(args);
}
2023-10-31 20:40:56 +01:00
const run_mzteinitctl_step = b.step("run-mzteinitctl", "Run mzteinitctl");
run_mzteinitctl_step.dependOn(&run_mzteinitctl.step);
2022-09-08 17:03:54 +02:00
const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step);
}