82 lines
2.5 KiB
Zig
82 lines
2.5 KiB
Zig
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);
|
|
}
|
|
// TODO It does not look like the cleanest solution, however, the build
|
|
// system code is too cryptic to come up with a better solution and the
|
|
// Internet is surprisingly silent about this very basic use case.
|
|
run_cmd.setCwd(.{ .cwd_relative = b.exe_dir });
|
|
|
|
const run_step = b.step("run", "Run the app");
|
|
run_step.dependOn(&run_cmd.step);
|
|
}
|