From c2fd2eb72d3942c07b3c71265d608e87cdbd4e66 Mon Sep 17 00:00:00 2001 From: Gabor Lekeny Date: Mon, 4 Nov 2024 15:46:04 +0100 Subject: [PATCH] Support x86_64 only --- build.zig | 25 ++++++------------------- build.zig.zon | 2 +- 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/build.zig b/build.zig index 37af048..a2ba54b 100644 --- a/build.zig +++ b/build.zig @@ -1,20 +1,11 @@ const std = @import("std"); -fn isAlpine() bool { - const f = std.fs.openFileAbsolute( - "/etc/alpine-release", - std.fs.File.OpenFlags{}, - ) catch { - return false; - }; - defer f.close(); - return true; -} - 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 have to be 'x86_64'"); + const options = b.addOptions(); const dynamic = b.option(bool, "dynamic", "link with dynamic library (default: false)") orelse false; options.addOption(bool, "dynamic", dynamic); @@ -26,13 +17,9 @@ pub fn build(b: *std.Build) void { }); lib.addLibraryPath(b.path("lib")); - if (isAlpine() and !dynamic) { - lib.linkSystemLibrary("aeron_static_musl", .{}); - } else if (isAlpine() and dynamic) { - lib.linkSystemLibrary("aeron_musl", .{}); - } else if (!isAlpine() and !dynamic) { - lib.linkSystemLibrary("aeron_static_libc", .{}); - } else if (!isAlpine() and dynamic) { - lib.linkSystemLibrary("aeron_libc", .{}); + 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 have to be 'musl' or 'gnu'"), } } diff --git a/build.zig.zon b/build.zig.zon index d6ec7e9..5aeb660 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -1,6 +1,6 @@ .{ .name = "aeron", - .version = "1.46.6", + .version = "1.46.6+x86", .minimum_zig_version = "0.13.0", .paths = .{ "build.zig",