Skip to content

Commit

Permalink
NO-JIRA: Fix build for library users
Browse files Browse the repository at this point in the history
Do not quit if the CPU and ABI does not match with the required ones,
because the IDE will not recognize the referenced modules on other
architectures (like Apple silicon).
  • Loading branch information
leki75 committed Nov 13, 2024
1 parent 8ad8de2 commit 7ece554
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions build.zig
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
const std = @import("std");

const log = std.log.scoped(.aeron);

pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});

if (target.result.cpu.arch != .x86_64) @panic("The target CPU architecture needs to be 'x86_64'");
if (target.result.cpu.arch != .x86_64) log.err("The target CPU architecture needs to be 'x86_64': {s}", .{@tagName(target.result.cpu.arch)});

const options = b.addOptions();
const dynamic = b.option(bool, "dynamic", "link with dynamic library (default: false)") orelse false;
Expand All @@ -20,6 +22,6 @@ pub fn build(b: *std.Build) void {
switch (target.result.abi) {
.gnu => lib.linkSystemLibrary(if (dynamic) "aeron_libc" else "aeron_static_libc", .{}),
.musl => lib.linkSystemLibrary(if (dynamic) "aeron_musl" else "aeron_static_musl", .{}),
else => @panic("The target ABI needs to be 'musl' or 'gnu'"),
else => |abi| log.err("The target ABI needs to be 'musl' or 'gnu': {s}", .{@tagName(abi)}),
}
}

0 comments on commit 7ece554

Please sign in to comment.