From 749296c2363157df7c47243799aba2f5ce1572f9 Mon Sep 17 00:00:00 2001 From: Gabor Lekeny Date: Wed, 13 Nov 2024 11:40:03 +0100 Subject: [PATCH] NO-JIRA: Fix build for library users 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). --- build.zig | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/build.zig b/build.zig index 0b797ce..e266d6c 100644 --- a/build.zig +++ b/build.zig @@ -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; @@ -17,9 +19,11 @@ pub fn build(b: *std.Build) void { }); lib.addLibraryPath(b.path("lib")); - 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'"), + if (target.result.cpu.arch == .x86_64) { + 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 => |abi| log.err("The target ABI needs to be 'musl' or 'gnu': {s}", .{@tagName(abi)}), + } } }