I will probably spend more time on this than I plan to, though I am not really writing this to run on Windows. At this point, Windows compilation works but when the driver attempts to read the HID descriptor, the response is only 45 bytes instead of the expected 75 (which is what it gets when run on Linux). I was under the impression that this response was just raw data from the device itself, but it's clearly handled differently on the different platforms, so I think it will be somewhat interesting to dig into what is different between the two and why. It's possible I may actually learn something along the way, unfortunately.
40 lines
1.1 KiB
Zig
40 lines
1.1 KiB
Zig
const std = @import("std");
|
|
|
|
pub fn build(b: *std.Build) !void {
|
|
const target = b.standardTargetOptions(.{});
|
|
const optimize = b.standardOptimizeOption(.{});
|
|
|
|
const use_udev = b.option(
|
|
bool,
|
|
"use_udev",
|
|
"link and use udev (Linux only. Default: false)",
|
|
) orelse false;
|
|
|
|
const liblabjackusb = b.addStaticLibrary(.{
|
|
.name = "labjackusb",
|
|
.target = target,
|
|
.optimize = optimize,
|
|
.link_libc = true,
|
|
});
|
|
|
|
if (optimize == .Debug) {
|
|
liblabjackusb.defineCMacro("LJ_DEBUG", "1");
|
|
}
|
|
|
|
liblabjackusb.addCSourceFile(.{ .file = b.path("liblabjackusb/labjackusb.c") });
|
|
liblabjackusb.installHeader(b.path("liblabjackusb/labjackusb.h"), "labjackusb.h");
|
|
|
|
// udev rules should be installed to /lib/udev/rules.d or /etc/udev/rules.d
|
|
// udevadm control --reload-rules
|
|
// /etc/init.d/udev-post reload
|
|
// udevstart
|
|
|
|
const usb_dep = b.dependency(
|
|
"usb",
|
|
.{ .target = target, .optimize = optimize, .use_udev = use_udev },
|
|
);
|
|
liblabjackusb.linkLibrary(usb_dep.artifact("usb"));
|
|
|
|
b.installArtifact(liblabjackusb);
|
|
}
|