hostapps/build.zig

71 lines
1.8 KiB
Zig
Raw Normal View History

2024-01-12 22:47:10 -06:00
const std = @import("std");
2024-01-28 20:20:37 -06:00
const path = @import("src/path.zig");
2024-01-12 22:47:10 -06:00
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
2024-12-13 10:39:38 -06:00
const ssh_command = b.option(
2024-01-12 22:47:10 -06:00
[]const u8,
"ssh",
"path to ssh binary",
2024-01-28 20:20:37 -06:00
) orelse ssh: {
const p = path.expandPath(b.allocator, "ssh") catch {
break :ssh "ssh";
} orelse {
break :ssh "ssh";
};
break :ssh p;
};
2024-01-12 22:47:10 -06:00
2024-12-13 10:39:38 -06:00
const telnet_command = b.option(
2024-01-12 22:47:10 -06:00
[]const u8,
"telnet",
"path to telnet binary",
2024-01-28 20:20:37 -06:00
) orelse telnet: {
const p = path.expandPath(b.allocator, "telnet") catch {
break :telnet "telnet";
} orelse {
break :telnet "telnet";
};
break :telnet p;
};
2024-01-12 22:47:10 -06:00
const exe = b.addExecutable(.{
2024-12-13 10:39:38 -06:00
.name = "hostapps-connect",
.root_source_file = b.path("src/main.zig"),
2024-01-12 22:47:10 -06:00
.target = target,
.optimize = optimize,
});
const build_options = b.addOptions();
2024-12-13 10:39:38 -06:00
build_options.addOption([]const u8, "ssh_command", ssh_command);
build_options.addOption([]const u8, "telnet_command", telnet_command);
2024-01-12 22:47:10 -06:00
exe.root_module.addOptions("build_options", build_options);
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);
const exe_unit_tests = b.addTest(.{
2024-12-13 10:39:38 -06:00
.root_source_file = b.path("src/main.zig"),
2024-01-12 22:47:10 -06:00
.target = target,
.optimize = optimize,
});
const run_exe_unit_tests = b.addRunArtifact(exe_unit_tests);
const test_step = b.step("test", "Run unit tests");
test_step.dependOn(&run_exe_unit_tests.step);
}