const std = @import("std"); pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{ .whitelist = &.{ .{ .cpu_arch = .x86_64, .os_tag = .windows, .abi = .msvc, }, .{ .cpu_arch = .aarch64, .os_tag = .windows, .abi = .msvc, }, .{ .cpu_arch = .x86_64, .os_tag = .linux, .abi = .gnu, }, .{ .cpu_arch = .aarch64, .os_tag = .linux, .abi = .gnu, }, }, }); const optimize = b.standardOptimizeOption(.{}); const exe_mod = b.createModule(.{ .root_source_file = b.path("src/main.zig"), .target = target, .optimize = optimize, }); const exe = b.addExecutable(.{ .name = "sciter", .root_module = exe_mod, }); b.installArtifact(exe); switch (target.result.os.tag) { .windows => { const zigwin32 = b.dependency("zigwin32", .{}); const zigwin32_mod = zigwin32.module("win32"); zigwin32_mod.resolved_target = target; zigwin32_mod.optimize = optimize; exe_mod.addImport("win32", zigwin32_mod); const dll_source_path = b.path(b.fmt("vendor/windows/{s}/sciter.dll", .{@tagName(target.result.cpu.arch)})); const dll_dest_path = "sciter.dll"; b.getInstallStep().dependOn(&b.addInstallBinFile(dll_source_path, dll_dest_path).step); }, .linux => { exe_mod.linkSystemLibrary("c", .{}); exe_mod.linkSystemLibrary("X11", .{}); const so_source_path = b.path(b.fmt("vendor/linux/{s}/libsciter.so", .{@tagName(target.result.cpu.arch)})); const so_dest_path = "libsciter.so"; b.getInstallStep().dependOn(&b.addInstallBinFile(so_source_path, so_dest_path).step); }, else => unreachable, } const run_cmd = b.addRunArtifact(exe); run_cmd.step.dependOn(b.getInstallStep()); if (b.args) |args| { run_cmd.addArgs(args); } run_cmd.setCwd(.{ .cwd_relative = b.exe_dir }); //run_cmd.setCwd(exe.getEmittedBinDirectory()); const run_step = b.step("run", "Run the app"); run_step.dependOn(&run_cmd.step); }