const std = @import("std"); pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); const triple = target.result; if (triple.os.tag != .linux or triple.cpu.arch != .x86_64) { std.log.warn("The build file only supports Linux x86-64 right now.\n", .{}); std.log.warn("You can extend the build.zig to call the appropriate platform scripts in 3rd/libomtnet/build/ and 3rd/libomt/build.\n", .{}); } // Build libomtnet const libomtnet_build = b.addSystemCommand(&.{ "bash", "buildall.sh", }); libomtnet_build.cwd = b.path("3rd/libomtnet/build"); // Build libomt const libomt_build = b.addSystemCommand(&.{ "bash", "buildlinuxx64.sh", }); libomt_build.cwd = b.path("3rd/libomt/build"); libomt_build.step.dependOn(&libomtnet_build.step); // Define executable const exe = b.addExecutable(.{ .name = "omtoy", .root_module = b.createModule(.{ .root_source_file = b.path("src/main.zig"), .target = target, .optimize = optimize, }), }); // Link libomt with the build { const omt_output_dir = b.path("3rd/libomt/bin/Release/net8.0/linux-x64/publish"); // exe.step.dependOn(&libomt_build.step); exe.addIncludePath(omt_output_dir); exe.addLibraryPath(omt_output_dir); exe.linkSystemLibrary("omt"); exe.linkLibC(); } b.installArtifact(exe); // 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); // Add run step const run_step = b.step("run", "Run the app"); const run_cmd = b.addRunArtifact(exe); run_step.dependOn(&run_cmd.step); run_cmd.step.dependOn(b.getInstallStep()); if (b.args) |args| { run_cmd.addArgs(args); } const exe_tests = b.addTest(.{ .root_module = exe.root_module, }); const run_exe_tests = b.addRunArtifact(exe_tests); const test_step = b.step("test", "Run tests"); test_step.dependOn(&run_exe_tests.step); }