diff --git a/.github/actions/build-plugin/action.yaml b/.github/actions/build-plugin/action.yaml index 3bb219d..1d44a2d 100644 --- a/.github/actions/build-plugin/action.yaml +++ b/.github/actions/build-plugin/action.yaml @@ -12,6 +12,10 @@ inputs: description: 'Enable acceleration' required: false default: 'generic' + macos_version: + description: 'Version of MacOS to target' + required: false + default: '12' codesign: description: 'Enable codesigning (macOS only)' required: false @@ -32,6 +36,7 @@ runs: shell: zsh --no-rcs --errexit --pipefail {0} working-directory: ${{ inputs.workingDirectory }} env: + MACOS_VERSION: ${{ inputs.macos_version }} CODESIGN_IDENT: ${{ inputs.codesignIdent }} CODESIGN_TEAM: ${{ inputs.codesignTeam }} run: | diff --git a/.github/actions/package-plugin/action.yaml b/.github/actions/package-plugin/action.yaml index dc2adf7..64d091c 100644 --- a/.github/actions/package-plugin/action.yaml +++ b/.github/actions/package-plugin/action.yaml @@ -12,6 +12,10 @@ inputs: description: 'Enable acceleration' required: false default: 'generic' + macos_version: + description: 'Version of MacOS to target' + required: false + default: '12' codesign: description: 'Enable codesigning (macOS only)' required: false @@ -56,6 +60,7 @@ runs: shell: zsh --no-rcs --errexit --pipefail {0} working-directory: ${{ inputs.workingDirectory }} env: + MACOS_VERSION: ${{ inputs.macos_version }} CODESIGN_IDENT: ${{ inputs.codesignIdent }} CODESIGN_IDENT_INSTALLER: ${{ inputs.installerIdent }} CODESIGN_TEAM: ${{ inputs.codesignTeam }} diff --git a/.github/scripts/.build.zsh b/.github/scripts/.build.zsh index f938533..ae4ff07 100755 --- a/.github/scripts/.build.zsh +++ b/.github/scripts/.build.zsh @@ -245,6 +245,21 @@ ${_usage_host:-}" log_error "No MACOS_ARCH environment variable set. Please set it to the desired architecture." exit 2 } + + # check the MACOS_VERSION env var to determine which version of MacOS to target + if [[ -n ${MACOS_VERSION} ]] { + if [[ ${MACOS_VERSION} == "13" ]] { + # Setting target version to 13.3 to match Whisper.cpp deps target, as that's when the new Accelerate interface was added + cmake_args+=(-DCMAKE_OSX_DEPLOYMENT_TARGET=${MACOS_VERSION}.3) + } else { + cmake_args+=(-DCMAKE_OSX_DEPLOYMENT_TARGET=${MACOS_VERSION}.0) + } + } else { + # error out + log_error "No MACOS_VERSION environment variable set. Please set it to the desired architecture." + exit 2 + } + cmake_install_args+=(build_macos --config ${config} --prefix "${project_root}/release/${config}") local -a xcbeautify_opts=() diff --git a/.github/scripts/.package.zsh b/.github/scripts/.package.zsh index 044b894..feae75e 100755 --- a/.github/scripts/.package.zsh +++ b/.github/scripts/.package.zsh @@ -176,7 +176,7 @@ ${_usage_host:-}" # get the arch from MACOS_ARCH env var local -r macos_arch=${MACOS_ARCH:-$(uname -m)} - local output_name="${product_name}-${product_version}-${host_os}-${macos_arch}" + local output_name="${product_name}-${product_version}-${host_os}-${MACOS_VERSION}-${macos_arch}" if [[ ! -d ${project_root}/release/${config}/${product_name}.plugin ]] { log_error 'No release artifact found. Run the build script or the CMake install procedure first.' diff --git a/.github/workflows/build-project.yaml b/.github/workflows/build-project.yaml index db0f57f..102024c 100644 --- a/.github/workflows/build-project.yaml +++ b/.github/workflows/build-project.yaml @@ -78,6 +78,7 @@ jobs: strategy: matrix: architecture: [x86_64, arm64] + macos_version: [12, 13, 14, 15] defaults: run: shell: zsh --no-rcs --errexit --pipefail {0} @@ -163,6 +164,7 @@ jobs: with: target: macos-${{ matrix.architecture }} config: ${{ needs.check-event.outputs.config }} + macos_version: ${{ matrix.macos_version }} codesign: ${{ fromJSON(needs.check-event.outputs.codesign) }} codesignIdent: ${{ steps.codesign.outputs.codesignIdent }} env: @@ -175,6 +177,7 @@ jobs: with: target: macos-${{ matrix.architecture }} config: ${{ needs.check-event.outputs.config }} + macos_version: ${{ matrix.macos_version }} package: ${{ fromJSON(needs.check-event.outputs.package) }} codesign: ${{ fromJSON(needs.check-event.outputs.codesign) && fromJSON(steps.codesign.outputs.haveCodesignIdent) }} codesignIdent: ${{ steps.codesign.outputs.codesignIdent }} diff --git a/.github/workflows/push.yaml b/.github/workflows/push.yaml index 90cfecf..2f881d9 100644 --- a/.github/workflows/push.yaml +++ b/.github/workflows/push.yaml @@ -78,8 +78,14 @@ jobs: 'windows-x64-generic;zip|exe' 'windows-x64-nvidia;zip|exe' 'windows-x64-amd;zip|exe' - 'macos-arm64;tar.xz|pkg' - 'macos-x86_64;tar.xz|pkg' + 'macos-12-arm64;tar.xz|pkg' + 'macos-13-arm64;tar.xz|pkg' + 'macos-14-arm64;tar.xz|pkg' + 'macos-15-arm64;tar.xz|pkg' + 'macos-12-x86_64;tar.xz|pkg' + 'macos-13-x86_64;tar.xz|pkg' + 'macos-14-x86_64;tar.xz|pkg' + 'macos-15-x86_64;tar.xz|pkg' 'ubuntu-22.04-x86_64-generic;tar.xz|deb|ddeb' 'ubuntu-22.04-x86_64-nvidia;tar.xz|deb|ddeb' 'ubuntu-22.04-x86_64-amd;tar.xz|deb|ddeb' diff --git a/cmake/BuildWhispercpp.cmake b/cmake/BuildWhispercpp.cmake index 29cfd36..ef11bc6 100644 --- a/cmake/BuildWhispercpp.cmake +++ b/cmake/BuildWhispercpp.cmake @@ -14,7 +14,19 @@ if(APPLE) # check the "MACOS_ARCH" env var to figure out if this is x86 or arm64 if($ENV{MACOS_ARCH} STREQUAL "x86_64") - set(WHISPER_CPP_HASH "27e506e0c473de33ccfd55b99364d1f829f4958f1443cbdd6fab33b0e10cf555") + if($ENV{MACOS_VERSION} STREQUAL "12") + set(METAL_STD 2.4) + set(WHISPER_CPP_HASH "58a938440e2c1d955e829daee9858ef683b7cf9afd6edd22a3f8b812d8c31492") + elseif($ENV{MACOS_VERSION} STREQUAL "13") + set(METAL_STD 3.0) + set(WHISPER_CPP_HASH "c6cdb11289415babba4b3379a84086f98f93e5f7fd60f0528e060a9af4009c8c") + elseif($ENV{MACOS_VERSION} STREQUAL "14") + set(METAL_STD 3.1) + set(WHISPER_CPP_HASH "1786c38df8d12cde1f364f0049f9c88e3b5dcb1a867e7d884fed4be250a10fb3") + elseif($ENV{MACOS_VERSION} STREQUAL "15") + set(METAL_STD 3.2) + set(WHISPER_CPP_HASH "91e406e3dfd36a33bd3b5ae0b68edd0019475ccda41428415908bb0ff0effdb1") + endif() list( APPEND @@ -28,7 +40,19 @@ if(APPLE) GGMLCPU-ALDERLAKE GGMLCPU-SAPPHIRERAPIDS) elseif($ENV{MACOS_ARCH} STREQUAL "arm64") - set(WHISPER_CPP_HASH "5ef495c799ef7c2aa0aa7b096b2bc8aa812717f036b6cf2e76db445a2a74899f") + if($ENV{MACOS_VERSION} STREQUAL "12") + set(METAL_STD 2.4) + set(WHISPER_CPP_HASH "89d19b1d270b6084f8455f26c52e59e8ef2ca0e6b1353bfc2aaadb0d5fdcb9a1") + elseif($ENV{MACOS_VERSION} STREQUAL "13") + set(METAL_STD 3.0) + set(WHISPER_CPP_HASH "29a79af5e918d5f531c99f66b66d9043814bc1250a836029706217ccf736f492") + elseif($ENV{MACOS_VERSION} STREQUAL "14") + set(METAL_STD 3.1) + set(WHISPER_CPP_HASH "c0759798ba927f2803161d70ba9769b817cd87aaf1cbaaf8247496a8cc939699") + elseif($ENV{MACOS_VERSION} STREQUAL "15") + set(METAL_STD 3.2) + set(WHISPER_CPP_HASH "5957c41f41621db03e33c6d12c5eeda735fb361f6b4128aa077da2b74548f8bb") + endif() list(APPEND WHISPER_RUNTIME_MODULES GGMLCPU-APPLE_M1 GGMLCPU-APPLE_M2_M3 GGMLCPU-APPLE_M4) else() message( @@ -36,7 +60,7 @@ if(APPLE) "The MACOS_ARCH environment variable is not set to a valid value. Please set it to either `x86_64` or `arm64`") endif() set(WHISPER_CPP_URL - "${PREBUILT_WHISPERCPP_URL_BASE}/whispercpp-macos-$ENV{MACOS_ARCH}-metalembedded-${PREBUILT_WHISPERCPP_VERSION}.tar.gz" + "${PREBUILT_WHISPERCPP_URL_BASE}/whispercpp-macos-$ENV{MACOS_ARCH}-metal${METAL_STD}-${PREBUILT_WHISPERCPP_VERSION}.tar.gz" ) set(WHISPER_LIBRARIES Whisper Whisper_1 WhisperCoreML GGML GGMLBase) @@ -57,7 +81,7 @@ if(APPLE) install_library_to_bundle(${whispercpp_fetch_SOURCE_DIR} libomp.dylib) install_library_to_bundle(${whispercpp_fetch_SOURCE_DIR} libvulkan.1.dylib) - # target_add_resource(${CMAKE_PROJECT_NAME} ${whispercpp_fetch_SOURCE_DIR}/bin/default.metallib) + target_add_resource(${CMAKE_PROJECT_NAME} ${whispercpp_fetch_SOURCE_DIR}/bin/default.metallib) elseif(WIN32) add_compile_definitions(WHISPER_DYNAMIC_BACKENDS)