diff --git a/browser_patches/chromium/build.sh b/browser_patches/chromium/build.sh index 32393c8b05..521fb32e70 100755 --- a/browser_patches/chromium/build.sh +++ b/browser_patches/chromium/build.sh @@ -56,8 +56,7 @@ compile_chromium() { source "${SCRIPT_FOLDER}/ensure_depot_tools.sh" if is_mac; then - # As of Apr, 2022 Chromium mac compilation requires Xcode13.3 - selectXcodeVersionOrDie "13.3" + selectXcodeVersionOrDie $(node "${SCRIPT_FOLDER}/../get_xcode_version.js" chromium) fi cd "${CR_CHECKOUT_PATH}/src" diff --git a/browser_patches/ffmpeg/build-mac.sh b/browser_patches/ffmpeg/build-mac.sh index 6d93062cc5..91ac05f633 100755 --- a/browser_patches/ffmpeg/build-mac.sh +++ b/browser_patches/ffmpeg/build-mac.sh @@ -27,14 +27,7 @@ cd "$(dirname $0)" SCRIPT_FOLDER="$(pwd -P)" source "${SCRIPT_FOLDER}/../utils.sh" -CURRENT_HOST_OS_VERSION=$(getMacVersion) -# As of Oct 2021, we build FFMPEG for Mac with Xcode 13 to align toolchains. -if [[ "${CURRENT_HOST_OS_VERSION}" == "10."* ]]; then - echo "ERROR: ${CURRENT_HOST_OS_VERSION} is not supported" - exit 1 -else - selectXcodeVersionOrDie "13.2" -fi +selectXcodeVersionOrDie $(node "${SCRIPT_FOLDER}/../get_xcode_version.js" ffmpeg) source ./CONFIG.sh diff --git a/browser_patches/firefox-beta/build.sh b/browser_patches/firefox-beta/build.sh index 3b8a68dcab..e30367e02d 100755 --- a/browser_patches/firefox-beta/build.sh +++ b/browser_patches/firefox-beta/build.sh @@ -21,14 +21,7 @@ fi rm -rf .mozconfig if is_mac; then - CURRENT_HOST_OS_VERSION=$(getMacVersion) - # As of Oct 2021, building Firefox requires XCode 13 - if [[ "${CURRENT_HOST_OS_VERSION}" != "10."* ]]; then - selectXcodeVersionOrDie "13.2" - else - echo "ERROR: ${CURRENT_HOST_OS_VERSION} is not supported" - exit 1 - fi + selectXcodeVersionOrDie $(node "${SCRIPT_FOLDER}/../get_xcode_version.js" firefox) echo "-- building on Mac" elif is_linux; then echo "-- building on Linux" diff --git a/browser_patches/firefox/build.sh b/browser_patches/firefox/build.sh index 27797de21a..7b9591d9d0 100755 --- a/browser_patches/firefox/build.sh +++ b/browser_patches/firefox/build.sh @@ -21,14 +21,7 @@ fi rm -rf .mozconfig if is_mac; then - CURRENT_HOST_OS_VERSION=$(getMacVersion) - # As of Oct 2021, building Firefox requires XCode 13 - if [[ "${CURRENT_HOST_OS_VERSION}" != "10."* ]]; then - selectXcodeVersionOrDie "13.2" - else - echo "ERROR: ${CURRENT_HOST_OS_VERSION} is not supported" - exit 1 - fi + selectXcodeVersionOrDie $(node "${SCRIPT_FOLDER}/../get_xcode_version.js" firefox) echo "-- building on Mac" elif is_linux; then echo "-- building on Linux" diff --git a/browser_patches/get_xcode_version.js b/browser_patches/get_xcode_version.js new file mode 100755 index 0000000000..c1da2eb228 --- /dev/null +++ b/browser_patches/get_xcode_version.js @@ -0,0 +1,30 @@ +#!/usr/bin/env node + +const child_process = require('child_process'); + +const XCODE_VERSIONS = { + "macos-10.15": { + webkit: '11.7', + }, + "macos-11": { + webkit: '12.5', // WebKit strongly requires xcode 12.5 and not higher on MacOS 11 + firefox: '13.2', // As of Oct 2021 building Firefox requires XCode 13 + ffmpeg: '13.2', + }, + "macos-12": { + webkit: '13.3', + firefox: '13.2', // As of Oct 2021 building Firefox requires XCode 13 + chromium: '13.3', // As of Apr 2022 Chromium requires Xcode13.3 + ffmpeg: '13.2', + }, +}; + +const [major, minor, patch] = child_process.execSync(`sw_vers -productVersion`).toString().trim().split('.'); +const browserName = process.argv[2]; +const macosVersion = major === '10' ? `macos-${major}.${minor}` : `macos-${major}`; +const versions = XCODE_VERSIONS[macosVersion]; +if (!versions || !versions[browserName.toLowerCase()]) + throw new Error(`Compilation of ${browserName} is not supported on ${macosVersion}`); + +console.log(versions[browserName.toLowerCase()]); + diff --git a/browser_patches/webkit/build.sh b/browser_patches/webkit/build.sh index 5123366732..063d2c413f 100755 --- a/browser_patches/webkit/build.sh +++ b/browser_patches/webkit/build.sh @@ -52,17 +52,7 @@ else fi if is_mac; then - CURRENT_HOST_OS_VERSION=$(getMacVersion) - if [[ "${CURRENT_HOST_OS_VERSION}" == "10.15" ]]; then - selectXcodeVersionOrDie "11.7" - elif [[ "${CURRENT_HOST_OS_VERSION}" == "11."* ]]; then - selectXcodeVersionOrDie "12.5" - elif [[ "${CURRENT_HOST_OS_VERSION}" == "12."* ]]; then - selectXcodeVersionOrDie "13.3" - else - echo "ERROR: ${CURRENT_HOST_OS_VERSION} is not supported" - exit 1 - fi + selectXcodeVersionOrDie $(node "$SCRIPT_FOLDER/../get_xcode_version.js" webkit) ./Tools/Scripts/build-webkit --release --touch-events --orientation-events elif is_linux; then if [[ $# == 0 || (-z "$1") ]]; then