dotfiles/scripts/mzteinit/build.zig

69 lines
2.1 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",
2024-06-21 18:43:42 +02:00
.root_source_file = b.path("src/main.zig"),
.target = target,
2023-10-31 20:40:56 +01:00
.optimize = optimize,
});
const mzteinitctl = b.addExecutable(.{
.name = "mzteinitctl",
2024-06-21 18:43:42 +02:00
.root_source_file = b.path("src/mzteinitctl.zig"),
2023-10-31 20:40:56 +01:00
.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
2024-07-09 18:24:01 +02:00
// TODO: Broken, see: https://github.com/ziglang/zig/issues/20525
//const cg_opt = try common.confgenGet(struct {
// gtk_theme: []const u8,
// mzteinit_entries: []const struct {
// key: []const u8,
// label: []const u8,
// cmd: []const []const u8,
// quit: bool = false,
// },
//}, b.allocator);
2023-06-27 22:31:02 +02:00
const cg_opt = try common.confgenGet(struct {
2024-06-21 18:43:42 +02:00
gtk_theme: []const u8,
2024-03-20 20:45:59 +01:00
}, b.allocator);
2023-06-27 22:31:02 +02:00
const opts = b.addOptions();
2024-07-09 18:24:01 +02:00
opts.addOption(@TypeOf(cg_opt), "cg", cg_opt);
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);
}