diff --git a/build.zig b/build.zig index d96670a..a16b09b 100644 --- a/build.zig +++ b/build.zig @@ -38,18 +38,41 @@ pub fn build(b: *std.Build) void { // TODO: install libomt.so and libomt.h in a more convenient location const libvmx_build = b.addLibrary(.{ - .root_module //todo + .root_module = b.createModule(.{ + .root_source_file = null, + .target = target, + .optimize = optimize, + }), .name = "libvmx", .linkage = .dynamic, }); + + libvmx_build.linkLibC(); libvmx_build.linkLibCpp(); + const libvmx_sources = [_][]const u8{ + "3rd/libvmx/src/vmxcodec_x86.cpp", + "3rd/libvmx/src/vmxcodec_avx2.cpp", + "3rd/libvmx/src/vmxcodec.cpp", + }; + const libvmx_cflags = [_][]const u8{ + "-O3", + "-std=c++17", + "-fdeclspec", + "-fPIC", + "-mlzcnt", + "-mavx2", + "-mbmi", + "-shared", + "-Wl,-rpath,'$ORIGIN'", + }; 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'" }, + .files = &libvmx_sources, + .flags = &libvmx_cflags, .language = null, }); + b.installArtifact(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"}); @@ -93,9 +116,9 @@ pub fn build(b: *std.Build) void { b.installArtifact(receiver_exe); // Manual build step for libomt dependencies - const build_omt_step = b.step("build-omt", "Build libomt and libomtnet"); + const build_omt_step = b.step("build-omt", "Build libomtnet, libomt and libvmx"); build_omt_step.dependOn(&libomt_build.step); - // build_omt_step.dependOn(&libvmx_copy.step); + build_omt_step.dependOn(&libvmx_build.step); // Add run step for sender const run_sender_step = b.step("sender-run", "Run the sender client");