build libvmx and adjust build script

Trying to make a new build location, but not sure how that works.
Can't get libvmx to be copied over for the other dependencies
This commit is contained in:
2025-10-15 00:36:21 +03:00
parent 7a13e4ed6c
commit 3fe7487c5a

View File

@@ -1,3 +1,14 @@
//
// Omtoy build script
//
// Build required OMT parts and link against our code
//
// Run `zig build build-omt` to build dependencies before anything else.
//
// TODO: I don't know if libvmx needs to be in the same directory as libomt _for libomt.so_
// or for the final executables. Right now I just move it next to libomt which is also
// passed as libLibrary for the executables
// TODO: Use install commands to move the libomt artifacts to a more sensible place
const std = @import("std");
pub fn build(b: *std.Build) void {
@@ -7,23 +18,36 @@ pub fn build(b: *std.Build) void {
const triple = target.result;
if (triple.os.tag != .linux or triple.cpu.arch != .x86_64) {
std.log.warn("The build file only supports Linux x86-64 right now.\n", .{});
std.log.warn("You can extend the build.zig to call the appropriate platform scripts in 3rd/libomtnet/build/ and 3rd/libomt/build.\n", .{});
std.log.warn(
"You can extend the build.zig to call the appropriate platform scripts " ++
"in 3rd/libomtnet/build/ and 3rd/libomt/build.\n",
.{},
);
}
// Build libomtnet
const libomtnet_build = b.addSystemCommand(&.{
"bash",
"buildall.sh",
});
const libomtnet_build = b.addSystemCommand(&.{"bash"});
libomtnet_build.cwd = b.path("3rd/libomtnet/build");
libomtnet_build.addFileArg(b.path("3rd/libomtnet/build/buildall.sh"));
// Build libomt
const libomt_build = b.addSystemCommand(&.{
"bash",
"buildlinuxx64.sh",
});
const libomt_build = b.addSystemCommand(&.{"bash"});
libomt_build.cwd = b.path("3rd/libomt/build");
libomt_build.addFileArg(b.path("3rd/libomt/build/buildlinuxx64.sh"));
libomt_build.step.dependOn(&libomtnet_build.step);
// TODO: install libomt.so and libomt.h in a more convenient location
// Build libvmx
const libvmx_build = b.addSystemCommand(&.{"bash"});
libvmx_build.addFileArg(b.path("3rd/libvmx/build/buildlinuxx64.sh"));
libvmx_build.cwd = b.path("3rd/libvmx/build");
// Copy libvmx to a place of happiness
// TODO: Runs but doesn't do what I'd expect it to. What's going on?
const libvmx_copy = b.addSystemCommand(&.{"cp"});
libvmx_copy.addFileArg(b.path("3rd/libvmx/build/libvmx.so"));
_ = libvmx_copy.addOutputFileArg("3rd/libomt/bin/Release/net8.0/linux-x64/publish/");
libvmx_copy.step.dependOn(&libvmx_build.step);
// Define executable
const sender_exe = b.addExecutable(.{
@@ -60,19 +84,10 @@ pub fn build(b: *std.Build) void {
b.installArtifact(sender_exe);
b.installArtifact(receiver_exe);
// Link libomt with the receiver
{
const omt_output_dir = b.path("3rd/libomt/bin/Release/net8.0/linux-x64/publish");
// exe.step.dependOn(&libomt_build.step);
sender_exe.addIncludePath(omt_output_dir);
sender_exe.addLibraryPath(omt_output_dir);
sender_exe.linkSystemLibrary("omt");
sender_exe.linkLibC();
}
// Manual build step for libomt dependencies
const build_omt_step = b.step("build-omt", "Build libomt and libomtnet");
build_omt_step.dependOn(&libomt_build.step);
build_omt_step.dependOn(&libvmx_copy.step);
// Add run step for sender
const run_sender_step = b.step("sender-run", "Run the sender client");