Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mixxx for macOS on M1/M2 Apple silicon #11398

Merged
merged 10 commits into from
May 11, 2023
34 changes: 30 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
artifacts_path: build/*.deb
artifacts_slug: ubuntu-jammy
qt_qpa_platform: offscreen
- name: macOS 11
- name: macOS 11 x64
os: macos-11
cmake_args: >-
-DBULK=ON
Expand All @@ -67,17 +67,41 @@ jobs:
-DMACOS_BUNDLE=ON
-DMODPLUG=ON
-DWAVPACK=ON
-DVCPKG_TARGET_TRIPLET=x64-osx-min1012
-DVCPKG_DEFAULT_HOST_TRIPLET=x64-osx-min1012
# TODO: Fix this broken test on macOS
ctest_args: --exclude-regex DirectoryDAOTest.relocateDirectory
cpack_generator: DragNDrop
compiler_cache: ccache
compiler_cache_path: /Users/runner/Library/Caches/ccache
buildenv_basepath: /Users/runner/buildenv
buildenv_script: tools/macos_buildenv.sh
artifacts_name: macOS DMG
buildenv_script: tools/macos_release_buildenv.sh
artifacts_name: macOS Intel DMG
artifacts_path: build/*.dmg
artifacts_slug: macos-macosintel
qt_qpa_platform: offscreen
- name: macOS 11 arm64
os: macos-11
cmake_args: >-
-DBULK=ON
-DCOREAUDIO=ON
-DHSS1394=ON
-DMACOS_BUNDLE=ON
-DMODPLUG=ON
-DWAVPACK=ON
-DVCPKG_TARGET_TRIPLET=arm64-osx-min1100
-DVCPKG_DEFAULT_HOST_TRIPLET=x64-osx-min1012
# TODO: Fix this broken test on macOS
crosscompile: true
cpack_generator: DragNDrop
compiler_cache: ccache
compiler_cache_path: /Users/runner/Library/Caches/ccache
buildenv_basepath: /Users/runner/buildenv
buildenv_script: tools/macos_arm64-cross-release_buildenv.sh
artifacts_name: macOS ARM DMG
artifacts_path: build/*.dmg
artifacts_slug: macos-macosarm
qt_qpa_platform: offscreen
- name: Windows 2019 (MSVC)
os: windows-2019
# TODO: Re-enable FFmpeg after licensing issues have been clarified
Expand All @@ -101,7 +125,7 @@ jobs:
compiler_cache: sccache
compiler_cache_path: C:\Users\runneradmin\AppData\Local\Mozilla\sccache\cache
buildenv_basepath: C:\buildenv
buildenv_script: tools/windows_buildenv.bat
buildenv_script: tools/windows_release_buildenv.bat
artifacts_name: Windows Installer
artifacts_path: build/*.msi
artifacts_slug: windows-win64
Expand Down Expand Up @@ -294,6 +318,7 @@ jobs:
run: ${{ matrix.compiler_cache }} -s

- name: "Test"
if: matrix.crosscompile != true
run: ctest --timeout 45 ${{ matrix.ctest_args }}
working-directory: build
env:
Expand All @@ -305,6 +330,7 @@ jobs:
CTEST_OUTPUT_ON_FAILURE: 1

- name: Benchmark
if: matrix.crosscompile != true
run: cmake --build . --target mixxx-benchmark --config RelWithDebInfo
working-directory: build
env:
Expand Down
20 changes: 14 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,21 @@ if(APPLE)
set(VCPKG_TARGET_TRIPLET "x64-osx-min10.15")
endif()
else()
# Minimum macOS version supported by Qt 5.12
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.12 CACHE STRING "Minimum macOS version the build will be able to run on")
if(NOT VCPKG_TARGET_TRIPLET)
set(VCPKG_TARGET_TRIPLET "x64-osx-min1012")
if(VCPKG_TARGET_TRIPLET STREQUAL "arm64-osx-min1100")
# Minimum macOS version for arm64 Support
set(CMAKE_OSX_DEPLOYMENT_TARGET 11.0 CACHE STRING "Minimum macOS version the build will be able to run on")
set(CMAKE_OSX_ARCHITECTURES arm64 CACHE STRING "The target achritecture")
set(CMAKE_SYSTEM_PROCESSOR arm64 CACHE STRING "The target system processor")
set(CMAKE_SYSTEM_NAME Darwin CACHE STRING "Setting this enables CMAKE_CROSSCOMPILE")
else()
# Minimum macOS version supported by Qt 5.12
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.12 CACHE STRING "Minimum macOS version the build will be able to run on")
if(NOT VCPKG_TARGET_TRIPLET)
set(VCPKG_TARGET_TRIPLET "x64-osx-min1012")
endif()
# Needed for deployment target < 10.14
add_compile_options(-fno-aligned-allocation)
endif()
# Needed for deployment target < 10.14
add_compile_options(-fno-aligned-allocation)
endif()
endif()

Expand Down
2 changes: 0 additions & 2 deletions packaging/macos/build_environment

This file was deleted.

1 change: 0 additions & 1 deletion packaging/windows/build_environment

This file was deleted.

3 changes: 3 additions & 0 deletions tools/macos_arm64-cross-release_buildenv.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
tools_path=$(dirname "$0")
BUILDENV_ARM64=TRUE BUILDENV_RELEASE=TRUE "${tools_path}/macos_buildenv.sh" "$@"
3 changes: 3 additions & 0 deletions tools/macos_arm64-cross_buildenv.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
tools_path=$(dirname "$0")
BUILDENV_ARM64=TRUE "${tools_path}/macos_buildenv.sh" "$@"
26 changes: 23 additions & 3 deletions tools/macos_buildenv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,29 @@ realpath() {
THIS_SCRIPT_NAME=${BASH_SOURCE[0]}
[ -z "$THIS_SCRIPT_NAME" ] && THIS_SCRIPT_NAME=$0

MIXXX_ROOT="$(realpath "$(dirname "$THIS_SCRIPT_NAME")/..")"
if [ -n "${BUILDENV_ARM64}" ]; then
if [ -n "${BUILDENV_RELEASE}" ]; then
BUILDENV_BRANCH="2.4-rel"
BUILDENV_NAME="mixxx-deps-2.4-arm64-osx-min1100-8f8342a"
BUILDENV_SHA256="0c9a0639aa8ef61c2acb2fd85e5dd785bbfd8e7e6d3320762304bb35b713e230"
else
BUILDENV_BRANCH="2.4"
BUILDENV_NAME="mixxx-deps-2.4-arm64-osx-min1100-50ff351"
BUILDENV_SHA256="bc835488aacb3e6cf582e929acee42074af9be0758de04e910025b76e4665a00"
fi
else
if [ -n "${BUILDENV_RELEASE}" ]; then
BUILDENV_BRANCH="2.4-rel"
BUILDENV_NAME="mixxx-deps-2.4-x64-osx-min1012-8f8342a"
BUILDENV_SHA256="6738f2fc5e4ef2156e363e84b1f8705db3d25350b44126d00e4c78285dfa82ef"
else
BUILDENV_BRANCH="2.4"
BUILDENV_NAME="mixxx-deps-2.4-x64-osx-min1012-50ff351"
BUILDENV_SHA256="8d42a9210b596a85d78c85a00fa81fdb7af6c9f2caa243e260ce279fd09afc5e"
fi
fi

read -r -d'\n' BUILDENV_NAME BUILDENV_SHA256 < "${MIXXX_ROOT}/packaging/macos/build_environment"
MIXXX_ROOT="$(realpath "$(dirname "$THIS_SCRIPT_NAME")/..")"

[ -z "$BUILDENV_BASEPATH" ] && BUILDENV_BASEPATH="${MIXXX_ROOT}/buildenv"

Expand All @@ -40,7 +60,7 @@ case "$1" in
if [ ! -d "${BUILDENV_PATH}" ]; then
if [ "$1" != "--profile" ]; then
echo "Build environment $BUILDENV_NAME not found in mixxx repository, downloading it..."
curl "https://downloads.mixxx.org/dependencies/2.4/macOS/${BUILDENV_NAME}.zip" -o "${BUILDENV_PATH}.zip"
curl "https://downloads.mixxx.org/dependencies/${BUILDENV_BRANCH}/macOS/${BUILDENV_NAME}.zip" -o "${BUILDENV_PATH}.zip"
OBSERVED_SHA256=$(shasum -a 256 "${BUILDENV_PATH}.zip"|cut -f 1 -d' ')
if [[ "$OBSERVED_SHA256" == "$BUILDENV_SHA256" ]]; then
echo "Download matched expected SHA256 sum $BUILDENV_SHA256"
Expand Down
3 changes: 3 additions & 0 deletions tools/macos_release_buildenv.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
tools_path=$(dirname "$0")
BUILDENV_RELEASE=TRUE "${tools_path}/macos_buildenv.sh" "$@"
42 changes: 22 additions & 20 deletions tools/windows_buildenv.bat
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ IF NOT DEFINED PLATFORM (
SET PLATFORM=x64
)

IF NOT DEFINED CONFIGURATION (
SET CONFIGURATION=release-fastbuild
)

IF NOT DEFINED BUILDENV_BASEPATH (
SET BUILDENV_BASEPATH=%MIXXX_ROOT%\buildenv
)
Expand All @@ -25,6 +21,16 @@ IF NOT DEFINED INSTALL_ROOT (
SET INSTALL_ROOT=%MIXXX_ROOT%\install
)

IF DEFINED BUILDENV_RELEASE (
SET BUILDENV_BRANCH=2.4-rel
SET BUILDENV_NAME=mixxx-deps-2.4-x64-windows-8f8342a
SET BUILDENV_SHA256=8dc9f310cde271e20e9dc21563aeb5fc7f618a316eae3dcb77f41cf18fc310f3
) ELSE (
SET BUILDENV_BRANCH=2.4
SET BUILDENV_NAME=mixxx-deps-2.4-x64-windows-c9ebc36
SET BUILDENV_SHA256=551ffdcdf8c552eddddb425f61c934da00208dcb240685ec7e27c3c26ed4953e
)

IF "%~1"=="" (
REM In case of manual start by double click no arguments are specified: Default to COMMAND_setup
CALL :COMMAND_setup
Expand All @@ -39,15 +45,12 @@ ENDLOCAL & SET "MIXXX_VCPKG_ROOT=%MIXXX_VCPKG_ROOT%" & SET "VCPKG_DEFAULT_TRIPLE
EXIT /B 0

:COMMAND_name
CALL :READ_ENVNAME
IF DEFINED GITHUB_ENV (
ECHO BUILDENV_NAME=!RETVAL! >> !GITHUB_ENV!
ECHO BUILDENV_NAME=%BUILDENV_NAME% >> !GITHUB_ENV!
)
GOTO :EOF

:COMMAND_setup
CALL :READ_ENVNAME
SET BUILDENV_NAME=%RETVAL%
SET BUILDENV_PATH=%BUILDENV_BASEPATH%\%BUILDENV_NAME%

IF NOT EXIST "%BUILDENV_BASEPATH%" (
Expand All @@ -56,13 +59,19 @@ EXIT /B 0
)

IF NOT EXIST "%BUILDENV_PATH%" (
SET BUILDENV_URL=https://downloads.mixxx.org/dependencies/2.4/Windows/!BUILDENV_NAME!.zip
SET BUILDENV_URL=https://downloads.mixxx.org/dependencies/!BUILDENV_BRANCH!/Windows/!BUILDENV_NAME!.zip
IF NOT EXIST "!BUILDENV_PATH!.zip" (
ECHO ^Download prebuilt build environment from "!BUILDENV_URL!" to "!BUILDENV_PATH!.zip"...
REM TODO: The /DYNAMIC parameter is required because our server does not yet support HTTP range headers
BITSADMIN /transfer buildenvjob /download /priority normal /DYNAMIC !BUILDENV_URL! "!BUILDENV_PATH!.zip"
REM TODO: verify download using sha256sum?
ECHO ^Download complete.
certutil -hashfile "!BUILDENV_PATH!.zip" SHA256 | FIND /C "!BUILDENV_SHA256!"
IF errorlevel 1 (
ECHO ^ERROR: Download did not match expected SHA256 checksum!
certutil -hashfile "!BUILDENV_PATH!.zip" SHA256
echo ^Expected: "!BUILDENV_SHA256!"
EXIT /B 1
)
) else (
ECHO ^Using cached archive at "!BUILDENV_PATH!.zip".
)
Expand Down Expand Up @@ -148,15 +157,6 @@ EXIT /B 0
GOTO :EOF


:READ_ENVNAME
ECHO Reading name of prebuild environment from "%MIXXX_ROOT%\packaging\windows\build_environment"
SET /P BUILDENV_NAME=<"%MIXXX_ROOT%\packaging\windows\build_environment"
SET BUILDENV_NAME=!BUILDENV_NAME:PLATFORM=%PLATFORM%!
SET BUILDENV_NAME=!BUILDENV_NAME:CONFIGURATION=%CONFIGURATION%!
SET RETVAL=%BUILDENV_NAME%
ECHO Environment name: %RETVAL%
GOTO :EOF

:GENERATE_CMakeSettings_JSON
REM Generate CMakeSettings.json which is read by MS Visual Studio to determine the supported CMake build environments
SET CMakeSettings=%MIXXX_ROOT%\CMakeSettings.json
Expand All @@ -178,7 +178,9 @@ REM Generate CMakeSettings.json which is read by MS Visual Studio to determine t

>>"%CMakeSettings%" echo "configurations": [
SET configElementTermination=,
CALL :Configuration2CMakeSettings_JSON off Debug
IF NOT DEFINED BUILDENV_RELEASE (
CALL :Configuration2CMakeSettings_JSON off Debug
)
CALL :Configuration2CMakeSettings_JSON legacy RelWithDebInfo
CALL :Configuration2CMakeSettings_JSON portable RelWithDebInfo
SET configElementTermination=
Expand Down
2 changes: 2 additions & 0 deletions tools/windows_release_buildenv.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@ECHO OFF
set DEFINED BUILDENV_RELEASE=TRUE && call "%~dp0windows_buildenv.bat" %* & set DEFINED BUILDENV_RELEASE=
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
set DEFINED BUILDENV_RELEASE=TRUE && call "%~dp0windows_buildenv.bat" %* & set DEFINED BUILDENV_RELEASE=
set "BUILDENV_RELEASE=TRUE" && call "%~dp0windows_buildenv.bat" %* & set "BUILDENV_RELEASE="

This doesn't work for me. Are you sure, that CI used the release only buildenv?