oslib/server/build.zig
2024-06-24 12:54:49 -06:00

51 lines
1.6 KiB
Zig

const std = @import("std");
pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const translate_c = b.addTranslateC(.{
.root_source_file = b.path("libvirt/include/libvirt/libvirt.h"),
.target = target,
.optimize = optimize,
});
translate_c.addIncludeDir("libvirt/include");
const output = b.addInstallFile(translate_c.getOutput(), "libvirt.zig");
const exe = b.addExecutable(.{
.name = "server",
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
});
exe.step.dependOn(&output.step);
exe.linkLibC();
exe.root_module.addIncludePath(b.path("libvirt/include"));
// exe.linkSystemLibrary("libvirt");
exe.addLibraryPath(b.path("libvirt/lib"));
exe.addObjectFile(b.path("libvirt/lib/libvirt.so.0.10000.0"));
exe.addObjectFile(b.path("libvirt/lib/libvirt-admin.so.0.10000.0"));
exe.addObjectFile(b.path("libvirt/lib/libvirt-qemu.so.0.10000.0"));
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(.{
.root_source_file = b.path("src/main.zig"),
.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);
}