2024-06-28 21:24:46 -07:00
|
|
|
const std = @import("std");
|
|
|
|
|
|
|
|
pub fn build(b: *std.Build) void {
|
|
|
|
const target = b.standardTargetOptions(.{});
|
|
|
|
const optimize = b.standardOptimizeOption(.{});
|
|
|
|
|
2024-07-11 22:14:20 -07:00
|
|
|
const libusb_use_udev = b.option(
|
2024-06-28 21:24:46 -07:00
|
|
|
bool,
|
|
|
|
"use_udev",
|
|
|
|
"link and use udev (Linux only. Default: false)",
|
|
|
|
) orelse false;
|
|
|
|
|
2024-07-11 22:14:20 -07:00
|
|
|
const libusb_enable_logging = b.option(
|
|
|
|
bool,
|
|
|
|
"libusb_enable_logging",
|
|
|
|
"enable libusb's built-in logging (Default: false)",
|
|
|
|
) orelse false;
|
|
|
|
|
|
|
|
const libusb_enable_debug_logging = b.option(
|
|
|
|
bool,
|
|
|
|
"libusb_enable_debug_logging",
|
|
|
|
"enable libusb's debug logging (Default: false)",
|
|
|
|
) orelse false;
|
|
|
|
|
2024-06-28 21:24:46 -07:00
|
|
|
const exe = b.addExecutable(.{
|
|
|
|
.name = "yaes",
|
|
|
|
.root_source_file = b.path("src/main.zig"),
|
|
|
|
.target = target,
|
|
|
|
.optimize = optimize,
|
|
|
|
});
|
|
|
|
|
2024-07-10 18:22:17 -07:00
|
|
|
if (target.result.os.tag == .windows) {
|
2024-07-10 22:28:49 -07:00
|
|
|
if (target.result.cpu.arch == .x86) {
|
|
|
|
exe.addObjectFile(b.path("deps/labjack/windows/ljackuw32.lib"));
|
|
|
|
b.getInstallStep().dependOn(
|
|
|
|
&b.addInstallBinFile(
|
|
|
|
b.path("deps/labjack/windows/ljackuw32.dll"),
|
|
|
|
"ljackuw.dll",
|
|
|
|
).step,
|
|
|
|
);
|
|
|
|
} else if (target.result.cpu.arch == .x86_64) {
|
|
|
|
exe.addObjectFile(b.path("deps/labjack/windows/ljackuw64.lib"));
|
|
|
|
b.getInstallStep().dependOn(
|
|
|
|
&b.addInstallBinFile(
|
|
|
|
b.path("deps/labjack/windows/ljackuw64.dll"),
|
|
|
|
"ljackuw.dll",
|
|
|
|
).step,
|
|
|
|
);
|
|
|
|
} else @panic("Unsupported CPU arch for Windows build (must be x86 or x86_64).");
|
2024-07-10 18:22:17 -07:00
|
|
|
} else {
|
|
|
|
const ljacklm_dep = b.dependency(
|
|
|
|
"ljacklm",
|
2024-07-11 22:14:20 -07:00
|
|
|
.{
|
|
|
|
.target = target,
|
|
|
|
.optimize = optimize,
|
|
|
|
.libusb_use_udev = libusb_use_udev,
|
|
|
|
.libusb_enable_logging = libusb_enable_logging,
|
|
|
|
.libusb_enable_debug_logging = libusb_enable_debug_logging,
|
|
|
|
},
|
2024-07-10 18:22:17 -07:00
|
|
|
);
|
|
|
|
exe.linkLibrary(ljacklm_dep.artifact("ljacklm"));
|
|
|
|
}
|
|
|
|
|
2024-07-07 15:34:03 -07:00
|
|
|
exe.root_module.addImport(
|
|
|
|
"udev_rules",
|
|
|
|
b.addModule("udev_rules", .{
|
|
|
|
.root_source_file = b.path("deps/labjack/exodriver/udev_rules.zig"),
|
|
|
|
}),
|
|
|
|
);
|
2024-06-28 21:24:46 -07:00
|
|
|
|
|
|
|
b.installArtifact(exe);
|
|
|
|
}
|