joeylib2/installer/components/zig.sh

44 lines
1.4 KiB
Bash

# shellcheck shell=bash
# Part of JoeyLib, Copyright (c) 2026 Scott Duensing, under the MIT License.
# See LICENSE.md for license information.
# SPDX-License-Identifier: MIT
#
# zig 0.15.2: the C compiler the macOS port (make macos) builds with. zig is
# clang with its own Mach-O linker, the macOS C library's headers and
# libSystem's stubs, so it builds Mac programs on Linux and signs the Apple
# silicon ones (ad hoc) as it links them; the frameworks come from the Apple
# SDK (component macosSdk). Prebuilt for Linux x86-64. Its cache stays inside
# toolchains/opt/zig, not in the user's home directory.
compDescription="macos: zig 0.15.2 (clang with a Mach-O linker)"
compGroups="toolchain:macos"
compRequires="host"
compHostDeps="tar xz"
compUrl="https://ziglang.org/download/0.15.2/zig-x86_64-linux-0.15.2.tar.xz"
compSha256="02aa270f183da276e5b5920b1dac44a63f1a49e55050ebde3aecc9eb82f93239"
compPin="$compSha256"
compInstall() {
local archive
archive="$(fetchFile "$compUrl" "$compSha256")"
rm -rf "$compDir"
extractArchive "$archive" "$compDir" 1
}
compInstalled() {
[ -x "$compDir/zig" ]
}
compVerify() {
ZIG_GLOBAL_CACHE_DIR="$compDir/cache" ZIG_LOCAL_CACHE_DIR="$compDir/cache" verifyCompiles "$compDir/zig" cc -target aarch64-macos
}
compEnv() {
envVar ZIG "$compDir/zig"
envVar ZIG_GLOBAL_CACHE_DIR "$compDir/cache"
envVar ZIG_LOCAL_CACHE_DIR "$compDir/cache"
}