Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub fn build(b: *Build) void {

const build_all = b.step("all", "build libusb for all targets");
for (targets(b)) |t| {
if (t.result.os.tag == .freebsd) continue;
const lib = create_libusb(b, t, optimize);
build_all.dependOn(&lib.step);
}
Expand All @@ -30,7 +31,7 @@ fn create_libusb(
optimize: std.builtin.OptimizeMode,
) *Build.Step.Compile {
const is_posix =
target.result.isDarwin() or
target.result.os.tag == .macos or
target.result.os.tag == .linux or
target.result.os.tag == .openbsd;

Expand All @@ -45,10 +46,10 @@ fn create_libusb(
if (is_posix)
lib.addCSourceFiles(.{ .files = posix_platform_src });

if (target.result.isDarwin()) {
if (target.result.os.tag == .macos) {
lib.addCSourceFiles(.{ .files = darwin_src });
lib.linkFrameworkNeeded("IOKit");
lib.linkFrameworkNeeded("Security");
lib.linkFramework("IOKit");
lib.linkFramework("Security");
} else if (target.result.os.tag == .linux) {
lib.addCSourceFiles(.{ .files = linux_src });
lib.linkSystemLibrary("udev");
Expand All @@ -69,7 +70,7 @@ fn create_libusb(
lib.installHeader(b.path("libusb/libusb.h"), "libusb.h");

// config header
if (target.result.isDarwin()) {
if (target.result.os.tag == .macos) {
lib.addIncludePath(b.path("Xcode"));
} else if (target.result.abi == .msvc) {
lib.addIncludePath(b.path("msvc"));
Expand All @@ -91,7 +92,7 @@ fn create_libusb(
.HAVE_DLFCN_H = null,
.HAVE_EVENTFD = null,
.HAVE_INTTYPES_H = null,
.HAVE_IOKIT_USB_IOUSBHOSTFAMILYDEFINITIONS_H = define_from_bool(target.result.isDarwin()),
.HAVE_IOKIT_USB_IOUSBHOSTFAMILYDEFINITIONS_H = define_from_bool(target.result.os.tag == .macos),
.HAVE_LIBUDEV = null,
.HAVE_NFDS_T = null,
.HAVE_PIPE2 = null,
Expand Down
1 change: 1 addition & 0 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"COPYING",
"build.zig",
"build.zig.zon",
"config.h.in",
"libusb",
},
}