joeylib2/installer/components/macosSdk.sh

57 lines
2.1 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
#
# The Apple SDK for macOS 15.5, and the Mach-O tools of the host's LLVM: what
# the macOS port (make macos) links its programs against and joins them
# with. The SDK holds the frameworks (Cocoa, CoreAudio, IOKit and the rest)
# and their stub libraries; zig (component zig) brings the C library. Apple
# ships the SDK only inside Xcode and offers no download of it, so it comes
# from the mirror osxcross users share (github.com/joseluisq/macosx-sdks),
# pinned to the release's SHA-256; a copy of the same tarball put in
# toolchains/cache/downloads first (MacOSX15.5.sdk.tar.xz) is used instead.
# Its licence is Apple's (LICENSES.md). llvm-lipo joins each architecture's
# build into one universal file and llvm-libtool-darwin archives universal
# objects (make/support/macos/cc.sh, make/macos.mk).
compDescription="macos: Apple MacOSX 15.5 SDK + LLVM's lipo and libtool"
compGroups="toolchain:macos"
compRequires="host"
compHostDeps="tar xz llvm"
compUrl="https://github.com/joseluisq/macosx-sdks/releases/download/15.5/MacOSX15.5.sdk.tar.xz"
compSha256="c15cf0f3f17d714d1aa5a642da8e118db53d79429eb015771ba816aa7c6c1cbd"
compPin="$compSha256"
# llvmTool NAME -- the path of LLVM's NAME: on the PATH, else the newest
# versioned LLVM's (Debian and Ubuntu keep llvm-lipo in /usr/lib/llvm-18/bin
# and the like, with only some tools linked into /usr/bin).
llvmTool() {
command -v "$1" 2>/dev/null || find /usr/lib -maxdepth 3 -path "/usr/lib/llvm-*/bin/$1" 2>/dev/null | sort -V | tail -n 1
}
compInstall() {
local archive
archive="$(fetchFile "$compUrl" "$compSha256")"
rm -rf "$compDir"
extractArchive "$archive" "$compDir" 1
}
compInstalled() {
[ -d "$compDir/System/Library/Frameworks/Cocoa.framework" ]
}
compVerify() {
compInstalled && [ -x "$(llvmTool llvm-lipo)" ] && [ -x "$(llvmTool llvm-libtool-darwin)" ]
}
compEnv() {
envVar MACOS_SDK "$compDir"
envVar MACOS_LIPO "$(llvmTool llvm-lipo)"
envVar MACOS_LIBTOOL "$(llvmTool llvm-libtool-darwin)"
}