successfully attempt to build libvmx

This commit is contained in:
2025-10-18 11:47:31 +03:00
parent ef7a396c02
commit 0421c88fd7

View File

@@ -38,18 +38,41 @@ pub fn build(b: *std.Build) void {
// TODO: install libomt.so and libomt.h in a more convenient location // TODO: install libomt.so and libomt.h in a more convenient location
const libvmx_build = b.addLibrary(.{ const libvmx_build = b.addLibrary(.{
.root_module //todo .root_module = b.createModule(.{
.root_source_file = null,
.target = target,
.optimize = optimize,
}),
.name = "libvmx", .name = "libvmx",
.linkage = .dynamic, .linkage = .dynamic,
}); });
libvmx_build.linkLibC();
libvmx_build.linkLibCpp(); 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(.{ libvmx_build.root_module.addCSourceFiles(.{
.root = b.path("3rd/libvmx/build/"), .files = &libvmx_sources,
.files = .{ "../src/vmxcodec_x86.cpp", "../src/vmxcodec_avx2.cpp", "../src/vmxcodec.cpp" }, .flags = &libvmx_cflags,
.flags = .{ "-O3", "-std=c++17", "-fdeclspec", "-fPIC", "-mlzcnt", "-mavx2", "-mbmi", "-shared", "-Wl,-rpath,'$ORIGIN'" },
.language = null, .language = null,
}); });
b.installArtifact(libvmx_build);
// Copy libvmx to a place of happiness // Copy libvmx to a place of happiness
// TODO: Runs but doesn't do what I'd expect it to. What's going on? // TODO: Runs but doesn't do what I'd expect it to. What's going on?
// const libvmx_copy = b.addSystemCommand(&.{"cp"}); // const libvmx_copy = b.addSystemCommand(&.{"cp"});
@@ -93,9 +116,9 @@ pub fn build(b: *std.Build) void {
b.installArtifact(receiver_exe); b.installArtifact(receiver_exe);
// Manual build step for libomt dependencies // 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(&libomt_build.step);
// build_omt_step.dependOn(&libvmx_copy.step); build_omt_step.dependOn(&libvmx_build.step);
// Add run step for sender // Add run step for sender
const run_sender_step = b.step("sender-run", "Run the sender client"); const run_sender_step = b.step("sender-run", "Run the sender client");