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
19 changes: 19 additions & 0 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,23 @@ pub fn build(b: *std.Build) void {
.root_source_file = b.path("src/serial.zig"),
});

// Add platform-specific linking for macOS
if (target.result.os.tag == .macos) {
serial_mod.linkFramework("IOKit", .{});
serial_mod.linkFramework("CoreFoundation", .{});
}

const unit_tests = b.addTest(.{
.root_source_file = b.path("src/serial.zig"),
.target = target,
.optimize = optimize,
});

// Add platform-specific linking for macOS
if (target.result.os.tag == .macos) {
unit_tests.linkFramework("IOKit");
unit_tests.linkFramework("CoreFoundation");
}
const run_unit_tests = b.addRunArtifact(unit_tests);
const test_step = b.step("test", "Run unit tests");
test_step.dependOn(&run_unit_tests.step);
Expand All @@ -39,6 +51,13 @@ pub fn build(b: *std.Build) void {
// port info only works on Windows!
// TODO: Linux and MacOS port info support
example.root_module.addImport("serial", serial_mod);

// Add platform-specific linking for macOS
if (target.result.os.tag == .macos) {
example.linkFramework("IOKit");
example.linkFramework("CoreFoundation");
}

const install_example = b.addInstallArtifact(example, .{});
example_step.dependOn(&example.step);
example_step.dependOn(&install_example.step);
Expand Down
Loading