build and install libomtnet, libomt and libvmx
This commit is contained in:
64
build.zig
64
build.zig
@@ -3,12 +3,12 @@
|
|||||||
//
|
//
|
||||||
// Build required OMT parts and link against our code
|
// Build required OMT parts and link against our code
|
||||||
//
|
//
|
||||||
// Run `zig build build-omt` to build dependencies before anything else.
|
// Run `zig build omt` to build dependencies before anything else.
|
||||||
|
//
|
||||||
|
// I don't know yet how to best create a conditional step to build and install
|
||||||
|
// the dependencies only if they aren't installed yet. Just putting the installs
|
||||||
|
// as dependencies runs the omt build scripts on every `zig build`.
|
||||||
//
|
//
|
||||||
// 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");
|
const std = @import("std");
|
||||||
|
|
||||||
pub fn build(b: *std.Build) void {
|
pub fn build(b: *std.Build) void {
|
||||||
@@ -20,42 +20,52 @@ pub fn build(b: *std.Build) void {
|
|||||||
std.log.warn("The build file only supports Linux x86-64 right now.\n", .{});
|
std.log.warn("The build file only supports Linux x86-64 right now.\n", .{});
|
||||||
std.log.warn(
|
std.log.warn(
|
||||||
"You can extend the build.zig to call the appropriate platform scripts " ++
|
"You can extend the build.zig to call the appropriate platform scripts " ++
|
||||||
"in 3rd/libomtnet/build/ and 3rd/libomt/build and 3rd/libvmx/build/\n",
|
"in 3rd/libomtnet/build/ and 3rd/libomt/build and 3rd/libvmx/build/ " ++
|
||||||
|
"and modifying the install scripts",
|
||||||
.{},
|
.{},
|
||||||
);
|
);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
// This comes from the libomt build scripts
|
||||||
|
const omt_out_path = "3rd/libomt/bin/Release/net8.0/linux-x64/publish/";
|
||||||
|
|
||||||
// Build libomtnet
|
// Build libomtnet
|
||||||
const libomtnet_build_script = b.addSystemCommand(&.{"bash"});
|
const libomtnet_build_script = b.addSystemCommand(&.{"bash"});
|
||||||
libomtnet_build_script.cwd = b.path("3rd/libomtnet/build");
|
libomtnet_build_script.cwd = b.path("3rd/libomtnet/build");
|
||||||
libomtnet_build_script.addFileArg(b.path("3rd/libomtnet/build/buildall.sh"));
|
libomtnet_build_script.addFileArg(b.path("3rd/libomtnet/build/buildall.sh"));
|
||||||
|
|
||||||
|
// Doesn't need install, libomt/build scripts assume a folder hierarchy
|
||||||
|
|
||||||
// Build libomt
|
// Build libomt
|
||||||
const libomt_build_script = b.addSystemCommand(&.{"bash"});
|
const libomt_build_script = b.addSystemCommand(&.{"bash"});
|
||||||
libomt_build_script.cwd = b.path("3rd/libomt/build");
|
libomt_build_script.cwd = b.path("3rd/libomt/build");
|
||||||
libomt_build_script.addFileArg(b.path("3rd/libomt/build/buildlinuxx64.sh"));
|
libomt_build_script.addFileArg(b.path("3rd/libomt/build/buildlinuxx64.sh"));
|
||||||
libomt_build_script.step.dependOn(&libomtnet_build_script.step);
|
libomt_build_script.step.dependOn(&libomtnet_build_script.step);
|
||||||
|
|
||||||
// const libvmx_build = b.addSystemCommand(&.{"bash"});
|
// Install libomt
|
||||||
// libvmx_build.cwd = b.path("3rd/libvmx/build");
|
const install_omt_h = b.addInstallHeaderFile(
|
||||||
// libvmx_build.addFileArg(b.path("3rd/libvmx/build/buildlinuxx64.sh"));
|
|
||||||
// b.installArtifact(libvmx_build);
|
|
||||||
|
|
||||||
const omt_out_path = "3rd/libomt/bin/Release/net8.0/linux-x64/publish/";
|
|
||||||
|
|
||||||
const copy_omt_h = b.addInstallFileWithDir(
|
|
||||||
b.path(b.pathJoin(&.{ omt_out_path, "libomt.h" })),
|
b.path(b.pathJoin(&.{ omt_out_path, "libomt.h" })),
|
||||||
.header,
|
|
||||||
"libomt.h",
|
"libomt.h",
|
||||||
);
|
);
|
||||||
copy_omt_h.step.dependOn(&libomt_build_script.step);
|
install_omt_h.step.dependOn(&libomt_build_script.step);
|
||||||
|
|
||||||
const copy_omt_so = b.addInstallFileWithDir(
|
const install_omt_so = b.addInstallLibFile(
|
||||||
b.path(b.pathJoin(&.{ omt_out_path, "libomt.so" })),
|
b.path(b.pathJoin(&.{ omt_out_path, "libomt.so" })),
|
||||||
.lib,
|
|
||||||
"libomt.so",
|
"libomt.so",
|
||||||
);
|
);
|
||||||
copy_omt_so.step.dependOn(&libomt_build_script.step);
|
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);
|
||||||
|
|
||||||
// Define executable
|
// Define executable
|
||||||
const sender_exe = b.addExecutable(.{
|
const sender_exe = b.addExecutable(.{
|
||||||
@@ -67,6 +77,15 @@ pub fn build(b: *std.Build) void {
|
|||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const lib_output_path: std.Build.LazyPath = .{
|
||||||
|
.cwd_relative = b.lib_dir,
|
||||||
|
};
|
||||||
|
const include_output_path: std.Build.LazyPath = .{
|
||||||
|
.cwd_relative = b.h_dir,
|
||||||
|
};
|
||||||
|
|
||||||
|
sender_exe.root_module.addLibraryPath(lib_output_path);
|
||||||
|
sender_exe.root_module.addIncludePath(include_output_path);
|
||||||
sender_exe.linkSystemLibrary("omt");
|
sender_exe.linkSystemLibrary("omt");
|
||||||
sender_exe.linkLibC();
|
sender_exe.linkLibC();
|
||||||
|
|
||||||
@@ -79,6 +98,8 @@ pub fn build(b: *std.Build) void {
|
|||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
receiver_exe.root_module.addLibraryPath(lib_output_path);
|
||||||
|
receiver_exe.root_module.addIncludePath(include_output_path);
|
||||||
receiver_exe.linkSystemLibrary("omt");
|
receiver_exe.linkSystemLibrary("omt");
|
||||||
receiver_exe.linkLibC();
|
receiver_exe.linkLibC();
|
||||||
|
|
||||||
@@ -87,8 +108,9 @@ pub fn build(b: *std.Build) void {
|
|||||||
|
|
||||||
// Manual build step for libomt dependencies
|
// Manual build step for libomt dependencies
|
||||||
const build_omt_step = b.step("omt", "Build libomtnet, libomt and libvmx");
|
const build_omt_step = b.step("omt", "Build libomtnet, libomt and libvmx");
|
||||||
build_omt_step.dependOn(©_omt_h.step);
|
build_omt_step.dependOn(&install_omt_h.step);
|
||||||
build_omt_step.dependOn(©_omt_so.step);
|
build_omt_step.dependOn(&install_omt_so.step);
|
||||||
|
build_omt_step.dependOn(&install_vmx_so.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");
|
||||||
|
|||||||
Reference in New Issue
Block a user