revert back to old approach

This commit is contained in:
2025-10-27 22:35:22 +02:00
parent bc222b77b7
commit bd3a49dc5a
5 changed files with 82 additions and 57 deletions

129
build.zig
View File

@@ -27,53 +27,51 @@ pub fn build(b: *std.Build) void {
return; return;
} }
// This comes from the libomt build scripts
const omt_out_path = "3rd/libomt/bin/Release/net8.0/linux-x64/publish/";
// Build libomtnet
const libomtnet_build_script = b.addSystemCommand(&.{"bash"});
libomtnet_build_script.cwd = b.path("3rd/libomtnet/build");
libomtnet_build_script.addFileArg(b.path("3rd/libomtnet/build/buildall.sh"));
// Build libomt
const libomt_build_script = b.addSystemCommand(&.{"bash"});
libomt_build_script.cwd = b.path("3rd/libomt/build");
libomt_build_script.addFileArg(b.path("3rd/libomt/build/buildlinuxx64.sh"));
libomt_build_script.step.dependOn(&libomtnet_build_script.step);
// Install libomt
const install_omt_h = b.addInstallHeaderFile(
b.path(b.pathJoin(&.{ omt_out_path, "libomt.h" })),
"libomt.h",
);
install_omt_h.step.dependOn(&libomt_build_script.step);
const install_omt_so = b.addInstallLibFile(
b.path(b.pathJoin(&.{ omt_out_path, "libomt.so" })),
"libomt.so",
);
install_omt_so.step.dependOn(&libomt_build_script.step);
// Build libvmx
const libvmx_build = b.addSystemCommand(&.{"bash"});
libvmx_build.cwd = b.path("3rd/libvmx/build");
libvmx_build.addFileArg(b.path("3rd/libvmx/build/buildlinuxx64.sh"));
// Install libvmx
const install_vmx_so = b.addInstallLibFile(
b.path("3rd/libvmx/build/libvmx.so"),
"libvmx.so",
);
install_vmx_so.step.dependOn(&libvmx_build.step);
{ {
// This comes from the libomt build scripts // Manual build step for libomt dependencies
const omt_out_path = "3rd/libomt/bin/Release/net8.0/linux-x64/publish/"; const build_omt_step = b.step("omt", "Build libomtnet, libomt and libvmx");
build_omt_step.dependOn(&install_omt_h.step);
// Build libomtnet build_omt_step.dependOn(&install_omt_so.step);
const libomtnet_build_script = b.addSystemCommand(&.{"bash"}); build_omt_step.dependOn(&install_vmx_so.step);
libomtnet_build_script.cwd = b.path("3rd/libomtnet/build");
libomtnet_build_script.addFileArg(b.path("3rd/libomtnet/build/buildall.sh"));
// Build libomt
const libomt_build_script = b.addSystemCommand(&.{"bash"});
libomt_build_script.cwd = b.path("3rd/libomt/build");
libomt_build_script.addFileArg(b.path("3rd/libomt/build/buildlinuxx64.sh"));
libomt_build_script.step.dependOn(&libomtnet_build_script.step);
// Install libomt
const install_omt_h = b.addInstallHeaderFile(
b.path(b.pathJoin(&.{ omt_out_path, "libomt.h" })),
"libomt.h",
);
install_omt_h.step.dependOn(&libomt_build_script.step);
const install_omt_so = b.addInstallLibFile(
b.path(b.pathJoin(&.{ omt_out_path, "libomt.so" })),
"libomt.so",
);
install_omt_so.step.dependOn(&libomt_build_script.step);
// Build libvmx
const libvmx_build = b.addSystemCommand(&.{"bash"});
libvmx_build.cwd = b.path("3rd/libvmx/build");
libvmx_build.addFileArg(b.path("3rd/libvmx/build/buildlinuxx64.sh"));
// Install libvmx
const install_vmx_so = b.addInstallLibFile(
b.path("3rd/libvmx/build/libvmx.so"),
"libvmx.so",
);
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 // The output lib and header directories
@@ -85,27 +83,45 @@ pub fn build(b: *std.Build) void {
}; };
// Zig omt module // Zig omt module
const omt_module = b.addModule("omt", .{ const omt_mod = b.addModule("omt", .{
.root_source_file = b.path("src/omt.zig"), .root_source_file = b.path("src/omt.zig"),
.target = target, .target = target,
.optimize = optimize, .optimize = optimize,
}); });
omt_module.linkSystemLibrary("omt", .{}); omt_mod.linkSystemLibrary("omt", .{});
omt_module.addLibraryPath(lib_output_path); omt_mod.addLibraryPath(lib_output_path);
omt_module.addIncludePath(include_output_path); omt_mod.addIncludePath(include_output_path);
// Main executable
const omtoy_exe = b.addExecutable(.{
.name = "omtoy",
.root_module = b.createModule(.{
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
}),
});
b.installArtifact(omtoy_exe);
const omtoy_run_step = b.step("run", "Run omtoy");
const omtoy_run = b.addRunArtifact(omtoy_exe);
omtoy_run_step.dependOn(&omtoy_run);
omtoy_run.step.dependOn(b.getInstallStep());
// Util executables
{ {
// Define executables // Define executables
const sender_exe = b.addExecutable(.{ const sender_exe = b.addExecutable(.{
.name = "omtoy-sender", .name = "sender",
.root_module = b.createModule(.{ .root_module = b.createModule(.{
.root_source_file = b.path("src/sender.zig"), .root_source_file = b.path("utils/sender.zig"),
.target = target, .target = target,
.optimize = optimize, .optimize = optimize,
}), }),
}); });
sender_exe.root_module.addImport("omt", omt_module); sender_exe.root_module.addImport("omt", omt_mod);
sender_exe.root_module.addLibraryPath(lib_output_path); sender_exe.root_module.addLibraryPath(lib_output_path);
sender_exe.root_module.addIncludePath(include_output_path); sender_exe.root_module.addIncludePath(include_output_path);
@@ -128,14 +144,14 @@ pub fn build(b: *std.Build) void {
{ {
const receiver_exe = b.addExecutable(.{ const receiver_exe = b.addExecutable(.{
.name = "omtoy-receiver", .name = "receiver",
.root_module = b.createModule(.{ .root_module = b.createModule(.{
.root_source_file = b.path("src/receiver.zig"), .root_source_file = b.path("utils/receiver.zig"),
.target = target, .target = target,
.optimize = optimize, .optimize = optimize,
}), }),
}); });
receiver_exe.root_module.addImport("omt", omt_module); receiver_exe.root_module.addImport("omt", omt_mod);
receiver_exe.root_module.addLibraryPath(lib_output_path); receiver_exe.root_module.addLibraryPath(lib_output_path);
receiver_exe.root_module.addIncludePath(include_output_path); receiver_exe.root_module.addIncludePath(include_output_path);
@@ -154,7 +170,6 @@ pub fn build(b: *std.Build) void {
run_receiver_cmd.addArgs(args); run_receiver_cmd.addArgs(args);
} }
} }
// TODO: write tests and stuff // TODO: write tests and stuff
// const exe_tests = b.addTest(.{ // const exe_tests = b.addTest(.{
// .root_module = sender_exe.root_module, // .root_module = sender_exe.root_module,

6
src/main.zig Normal file
View File

@@ -0,0 +1,6 @@
const std = @import("std");
const omt = @import("omt.zig");
pub fn main() void {
std.log.info("Starting omtoy...", .{});
}

View File

@@ -25,3 +25,7 @@ pub fn colorSpaceToString(cs: c.OMTColorSpace) []const u8 {
else => "Invalid", else => "Invalid",
}; };
} }
pub fn whaaat() void {
std.log.info("Whaaaat", .{});
}