From ef7a396c02ca78b449f8203b8580d953045e7328 Mon Sep 17 00:00:00 2001 From: Kasper Sauramo Date: Thu, 16 Oct 2025 22:50:52 +0300 Subject: [PATCH] build libvmx with zig (wip) --- build.zig | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/build.zig b/build.zig index 07c5989..d96670a 100644 --- a/build.zig +++ b/build.zig @@ -37,17 +37,25 @@ pub fn build(b: *std.Build) void { 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"); + const libvmx_build = b.addLibrary(.{ + .root_module //todo + .name = "libvmx", + .linkage = .dynamic, + }); + libvmx_build.linkLibCpp(); + libvmx_build.root_module.addCSourceFiles(.{ + .root = b.path("3rd/libvmx/build/"), + .files = .{ "../src/vmxcodec_x86.cpp", "../src/vmxcodec_avx2.cpp", "../src/vmxcodec.cpp" }, + .flags = .{ "-O3", "-std=c++17", "-fdeclspec", "-fPIC", "-mlzcnt", "-mavx2", "-mbmi", "-shared", "-Wl,-rpath,'$ORIGIN'" }, + .language = null, + }); // 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); + // 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.so"); + // libvmx_copy.step.dependOn(&libvmx_build.step); // Define executable const sender_exe = b.addExecutable(.{ @@ -87,7 +95,7 @@ pub fn build(b: *std.Build) void { // 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); + // build_omt_step.dependOn(&libvmx_copy.step); // Add run step for sender const run_sender_step = b.step("sender-run", "Run the sender client");