reorganize build script
This commit is contained in:
58
build.zig
58
build.zig
@@ -26,6 +26,8 @@ pub fn build(b: *std.Build) void {
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
// This comes from the libomt build scripts
|
||||
const omt_out_path = "3rd/libomt/bin/Release/net8.0/linux-x64/publish/";
|
||||
|
||||
@@ -34,8 +36,6 @@ pub fn build(b: *std.Build) void {
|
||||
libomtnet_build_script.cwd = b.path("3rd/libomtnet/build");
|
||||
libomtnet_build_script.addFileArg(b.path("3rd/libomtnet/build/buildall.sh"));
|
||||
|
||||
// Doesn't need install, libomt/build scripts assume a folder hierarchy
|
||||
|
||||
// Build libomt
|
||||
const libomt_build_script = b.addSystemCommand(&.{"bash"});
|
||||
libomt_build_script.cwd = b.path("3rd/libomt/build");
|
||||
@@ -67,6 +67,15 @@ pub fn build(b: *std.Build) void {
|
||||
);
|
||||
install_vmx_so.step.dependOn(&libvmx_build.step);
|
||||
|
||||
{
|
||||
// Manual build step for libomt dependencies
|
||||
const build_omt_step = b.step("omt", "Build libomtnet, libomt and libvmx");
|
||||
build_omt_step.dependOn(&install_omt_h.step);
|
||||
build_omt_step.dependOn(&install_omt_so.step);
|
||||
build_omt_step.dependOn(&install_vmx_so.step);
|
||||
}
|
||||
}
|
||||
|
||||
// The output lib and header directories
|
||||
const lib_output_path: std.Build.LazyPath = .{
|
||||
.cwd_relative = b.lib_dir,
|
||||
@@ -81,9 +90,13 @@ pub fn build(b: *std.Build) void {
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
omt_module.linkSystemLibrary("omt", .{});
|
||||
|
||||
// Define executable
|
||||
omt_module.linkSystemLibrary("omt", .{});
|
||||
omt_module.addLibraryPath(lib_output_path);
|
||||
omt_module.addIncludePath(include_output_path);
|
||||
|
||||
{
|
||||
// Define executables
|
||||
const sender_exe = b.addExecutable(.{
|
||||
.name = "omtoy-sender",
|
||||
.root_module = b.createModule(.{
|
||||
@@ -94,14 +107,26 @@ pub fn build(b: *std.Build) void {
|
||||
});
|
||||
sender_exe.root_module.addImport("omt", omt_module);
|
||||
|
||||
omt_module.addLibraryPath(lib_output_path);
|
||||
omt_module.addIncludePath(include_output_path);
|
||||
|
||||
sender_exe.root_module.addLibraryPath(lib_output_path);
|
||||
sender_exe.root_module.addIncludePath(include_output_path);
|
||||
sender_exe.linkSystemLibrary("omt");
|
||||
sender_exe.linkLibC();
|
||||
|
||||
b.installArtifact(sender_exe);
|
||||
|
||||
// Add run step for sender
|
||||
const run_sender_step = b.step("sender-run", "Run the sender client");
|
||||
const run_sender_cmd = b.addRunArtifact(sender_exe);
|
||||
run_sender_step.dependOn(&run_sender_cmd.step);
|
||||
run_sender_cmd.step.dependOn(b.getInstallStep());
|
||||
|
||||
// Don't actually have arguments, so this is moot
|
||||
if (b.args) |args| {
|
||||
run_sender_cmd.addArgs(args);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
const receiver_exe = b.addExecutable(.{
|
||||
.name = "omtoy-receiver",
|
||||
.root_module = b.createModule(.{
|
||||
@@ -117,33 +142,18 @@ pub fn build(b: *std.Build) void {
|
||||
receiver_exe.linkSystemLibrary("omt");
|
||||
receiver_exe.linkLibC();
|
||||
|
||||
b.installArtifact(sender_exe);
|
||||
b.installArtifact(receiver_exe);
|
||||
|
||||
// Manual build step for libomt dependencies
|
||||
const build_omt_step = b.step("omt", "Build libomtnet, libomt and libvmx");
|
||||
build_omt_step.dependOn(&install_omt_h.step);
|
||||
build_omt_step.dependOn(&install_omt_so.step);
|
||||
build_omt_step.dependOn(&install_vmx_so.step);
|
||||
|
||||
// Add run step for sender
|
||||
const run_sender_step = b.step("sender-run", "Run the sender client");
|
||||
const run_sender_cmd = b.addRunArtifact(sender_exe);
|
||||
run_sender_step.dependOn(&run_sender_cmd.step);
|
||||
|
||||
const run_receiver_step = b.step("receiver-run", "Run the receiver client");
|
||||
const run_receiver_cmd = b.addRunArtifact(receiver_exe);
|
||||
run_receiver_step.dependOn(&run_receiver_cmd.step);
|
||||
|
||||
// Add run step for receiver
|
||||
|
||||
run_sender_cmd.step.dependOn(b.getInstallStep());
|
||||
run_receiver_cmd.step.dependOn(b.getInstallStep());
|
||||
|
||||
// Don't actually have arguments so this is moot
|
||||
if (b.args) |args| {
|
||||
run_sender_cmd.addArgs(args);
|
||||
run_receiver_cmd.addArgs(args);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: write tests and stuff
|
||||
// const exe_tests = b.addTest(.{
|
||||
|
||||
Reference in New Issue
Block a user