dotfiles/scripts/mzteinit/build.zig

58 lines
1.8 KiB
Zig
Raw Normal View History

2022-09-08 17:03:54 +02:00
const std = @import("std");
2024-03-20 20:45:59 +01:00
const common = @import("common");
2022-09-08 17:03:54 +02:00
pub fn build(b: *std.Build) !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");
2024-03-20 20:45:59 +01:00
const common_mod = b.dependency("common", .{}).module("common");
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
inline for (.{ mzteinitctl, exe }) |e| {
e.root_module.addImport("ansi-term", ansi_term_mod);
2024-03-20 20:45:59 +01:00
e.root_module.addImport("common", common_mod);
2023-10-31 20:40:56 +01:00
}
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
2024-03-20 20:45:59 +01:00
}, b.allocator);
2023-06-27 22:31:02 +02:00
const opts = b.addOptions();
opts.addOption([]const u8, "gtk_theme", cg_opt.gtk_theme);
exe.root_module.addImport("opts", opts.createModule());
2023-06-27 22:31:02 +02:00
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);
}