From 8656c107169a7af3be5f2d0d840e220988270f77 Mon Sep 17 00:00:00 2001 From: Awawa <69086569+awawa-dev@users.noreply.github.com> Date: Fri, 2 Feb 2024 02:01:00 +0100 Subject: [PATCH] Add native build for Apple M1 / M2 (arm64) architecture (#755) --- .github/workflows/push-master.yml | 77 +++++++++++++++++++++++++++++-- CHANGELOG.md | 1 + README.md | 4 +- cmake/Dependencies.cmake | 54 +++++++++++++++++++++- 4 files changed, 129 insertions(+), 7 deletions(-) diff --git a/.github/workflows/push-master.yml b/.github/workflows/push-master.yml index 2355a1fed..abb4f3316 100644 --- a/.github/workflows/push-master.yml +++ b/.github/workflows/push-master.yml @@ -129,12 +129,83 @@ jobs: deploy/Hyper*.rpm ###################### -####### macOS ######## +### macOS (arm64) #### +###################### + + macOS_arm64: + name: macOS (arm64) + runs-on: macos-14 + env: + QT_VERSION: "6" + steps: + # Checkout + - uses: actions/checkout@v3 + with: + submodules: true + + # Generate cache id + - name: Prepare ccache timestamp + if: env.USE_CACHE == '1' + id: ccache_cache_timestamp + shell: cmake -P {0} + run: | + string(TIMESTAMP current_date "%Y-%m-%d-%H-%M-%S" UTC) + file(APPEND "$ENV{GITHUB_OUTPUT}" "timestamp=${current_date}") + + # Download cache + - name: ccache cache files + if: ( env.USE_CACHE == '1' ) + uses: actions/cache@v3 + with: + path: .ccache + key: macOS-ccache-${{ steps.ccache_cache_timestamp.outputs.timestamp }} + restore-keys: macOS-ccache- + + # Install deps + - name: Install deps + shell: bash + run: brew install qt@${{ env.QT_VERSION }} xz ccache zstd webp jpeg-turbo || true + + # Set env + - name: Set QT5 env + if: ( env.QT_VERSION == '5' ) + shell: bash + run: | + export Qt5_DIR=`brew --prefix qt5`; + echo "Qt5_DIR=$Qt5_DIR" >> $GITHUB_ENV + + # Build process + - name: Build packages + env: + PLATFORM: osx + USE_CCACHE: ${{ env.USE_CACHE }} + RESET_CACHE: ${{ env.RESET_CACHE }} + shell: bash + run: ./.ci/ci_build.sh + + # Upload artifacts (only on tagged commit) + - name: Upload artifacts + if: startsWith(github.event.ref, 'refs/tags') && github.event_name != 'pull_request' + uses: actions/upload-artifact@v3 + with: + path: build/Hyper*.dmg + + # Upload artifacts from commit + - name: Upload artifacts from commit + if: (startsWith(github.event.ref, 'refs/tags') != true) && github.event_name != 'pull_request' + uses: actions/upload-artifact@v3 + with: + name: Apple_macOS_arm64_DMG_installer + path: build/Hyper*.dmg + + +###################### +##### macOS (x86) #### ###################### macOS: name: macOS - runs-on: macos-12 + runs-on: macos-13 env: QT_VERSION: "5" steps: @@ -292,7 +363,7 @@ jobs: publish: name: Publish Releases if: startsWith(github.event.ref, 'refs/tags') && github.event_name != 'pull_request' - needs: [Linux, windows, macOS] + needs: [Linux, windows, macOS, macOS_arm64] runs-on: ubuntu-22.04 permissions: contents: write diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ac19c330..b69b04838 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ - Fix verbose command line option #737 (v20 beta2 🆕) +- Add native build for Apple M1 / M2 (arm64) architecture #973 (v20 beta2 🆕) - New features: disable LEDs/components on startup #737 (v20 beta2 🆕) - New features: stop processing when user has locked the system #737 (v20 beta2 🆕) - Force HyperSerial detection #732 Thanks @alex-013 (v20 beta2 🆕) diff --git a/README.md b/README.md index c61c203c3..4cdad1245 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ## About -Open source ambient lighting implementation for television and music sets based on the video and audio streams analysis. Focused on stability while ensuring performance and quality. Single and multi-threaded video processing optimization for **Windows**, **macOS** and **Linux x64 & ARM** (Raspberry Pi and others). +Open source ambient lighting implementation for television and music sets based on the video and audio streams analysis. Focused on stability while ensuring performance and quality. Single and multi-threaded video processing optimization for **Windows**, **macOS** (x64/arm64: M1, M2) and **Linux x64 & ARM** (Raspberry Pi and others). ![v20](https://github.com/awawa-dev/HyperHDR/assets/69086569/9bc7999d-1515-4a96-ba5e-8a732cf7d8a4) @@ -14,7 +14,7 @@ Open source ambient lighting implementation for television and music sets based * Video post-processing filter to eliminate LED flickering * Modern interface using Bootstrap 5 and SVG icons * Provides vital informations about your OS condition: CPU & RAM usage, CPU temperature, undervoltage detection, internal components performance including USB grabber and LED devices -* Support for USB grabbers under Linux, Windows 10, macOS (x64/M1) +* Support for USB grabbers under Linux, Windows 10, macOS * Pipewire/Portal hardware-accelerated screen capturer for Linux/Wayland * DirectX screen grabber with pixel and vertex shader processing acceleration for Windows 10/11 * DirectX screen grabber supports native Windows HDR modes like DXGI_FORMAT_R16G16B16A16_FLOAT diff --git a/cmake/Dependencies.cmake b/cmake/Dependencies.cmake index 5cadda42f..d3e310ee2 100644 --- a/cmake/Dependencies.cmake +++ b/cmake/Dependencies.cmake @@ -30,10 +30,11 @@ macro(DeployApple TARGET) install(CODE "set(MYQT_PLUGINS_DIR \"${MYQT_PLUGINS_DIR}\")" COMPONENT "HyperHDR") install(CODE "set(MY_DEPENDENCY_PATHS \"${TARGET_FILE}\")" COMPONENT "HyperHDR") install(CODE "set(MY_SYSTEM_LIBS_SKIP \"${SYSTEM_LIBS_SKIP}\")" COMPONENT "HyperHDR") + install(CODE "set(Scope_Qt_VERSION ${Qt_VERSION})" COMPONENT "HyperHDR") install(CODE [[ #OpenSSL - if(EXISTS "/usr/local/opt/openssl@1.1/lib" AND IS_DIRECTORY "/usr/local/opt/openssl@1.1/lib") - message( STATUS "Including OpenSSL libraries") + if(Scope_Qt_VERSION EQUAL 5 AND EXISTS "/usr/local/opt/openssl@1.1/lib" AND IS_DIRECTORY "/usr/local/opt/openssl@1.1/lib") + message("Including OpenSSL@1.1 libraries") file(GLOB filesSSL "/usr/local/opt/openssl@1.1/lib/*") foreach(openssl_lib ${filesSSL}) string(FIND ${openssl_lib} "dylib" _indexSSL) @@ -51,6 +52,31 @@ macro(DeployApple TARGET) ) endif() endforeach() + elseif(NOT (Scope_Qt_VERSION EQUAL 5) AND EXISTS "/opt/homebrew/opt/openssl/lib" AND IS_DIRECTORY "/opt/homebrew/opt/openssl/lib") + if (EXISTS "/opt/homebrew/opt/openssl/lib/libssl.3.dylib") + message("Including OpenSSL@3 libraries") + elseif (EXISTS "/opt/homebrew/opt/openssl/lib/libssl.dylib") + message("Including OpenSSL@1.1 libraries") + else() + message(WARNING "Including unknown version of OpenSSL libraries") + endif() + file(GLOB filesSSL "/opt/homebrew/opt/openssl/lib/*") + foreach(openssl_lib ${filesSSL}) + string(FIND ${openssl_lib} "dylib" _indexSSL) + if (${_indexSSL} GREATER -1) + file(INSTALL + DESTINATION "${CMAKE_INSTALL_PREFIX}/hyperhdr.app/Contents/Frameworks" + TYPE SHARED_LIBRARY + FILES "${openssl_lib}" + ) + else() + file(INSTALL + DESTINATION "${CMAKE_INSTALL_PREFIX}/hyperhdr.app/Contents/lib" + TYPE SHARED_LIBRARY + FILES "${openssl_lib}" + ) + endif() + endforeach() else() message( WARNING "OpenSSL NOT found (https instance will not work)") endif() @@ -131,6 +157,30 @@ macro(DeployApple TARGET) include(BundleUtilities) fixup_bundle("${CMAKE_INSTALL_PREFIX}/hyperhdr.app" "${MYQT_PLUGINS}" "${CMAKE_INSTALL_PREFIX}/hyperhdr.app/Contents/lib") + + EXECUTE_PROCESS( COMMAND uname -m COMMAND tr -d '\n' OUTPUT_VARIABLE OS_ARCHITECTURE ) + message( "Detected architecture: '${OS_ARCHITECTURE}'") + if(OS_ARCHITECTURE STREQUAL "arm64") + file(GLOB libSignFramework "${CMAKE_INSTALL_PREFIX}/hyperhdr.app/Contents/Frameworks/*.dylib") + list (APPEND libSignFramework "${CMAKE_INSTALL_PREFIX}/hyperhdr.app/Contents/MacOS/hyperhdr") + foreach(PLUGIN "platforms" "sqldrivers" "imageformats") + file(GLOB libPlugins "${CMAKE_INSTALL_PREFIX}/hyperhdr.app/Contents/plugins/${PLUGIN}/*.dylib") + list (APPEND libSignFramework ${libPlugins}) + endforeach() + list (APPEND libSignFramework "${CMAKE_INSTALL_PREFIX}/hyperhdr.app/Contents/Frameworks/QtCore.framework/Versions/A/QtCore") + list (APPEND libSignFramework "${CMAKE_INSTALL_PREFIX}/hyperhdr.app/Contents/Frameworks/QtDBus.framework/Versions/A/QtDBus") + list (APPEND libSignFramework "${CMAKE_INSTALL_PREFIX}/hyperhdr.app/Contents/Frameworks/QtGui.framework/Versions/A/QtGui") + list (APPEND libSignFramework "${CMAKE_INSTALL_PREFIX}/hyperhdr.app/Contents/Frameworks/QtSql.framework/Versions/A/QtSql") + list (APPEND libSignFramework "${CMAKE_INSTALL_PREFIX}/hyperhdr.app/Contents/Frameworks/QtNetwork.framework/Versions/A/QtNetwork") + list (APPEND libSignFramework "${CMAKE_INSTALL_PREFIX}/hyperhdr.app/Contents/Frameworks/QtPdf.framework/Versions/A/QtPdf") + list (APPEND libSignFramework "${CMAKE_INSTALL_PREFIX}/hyperhdr.app/Contents/Frameworks/QtSvg.framework/Versions/A/QtSvg") + list (APPEND libSignFramework "${CMAKE_INSTALL_PREFIX}/hyperhdr.app/Contents/Frameworks/QtSerialPort.framework/Versions/A/QtSerialPort") + list (APPEND libSignFramework "${CMAKE_INSTALL_PREFIX}/hyperhdr.app/Contents/Frameworks/QtWidgets.framework/Versions/A/QtWidgets") + foreach(_fileToSign ${libSignFramework}) + message("Fixing: ${_fileToSign}") + execute_process(COMMAND bash -c "codesign --force -s - ${_fileToSign}") + endforeach() + endif() file(REMOVE_RECURSE "${CMAKE_INSTALL_PREFIX}/hyperhdr.app/Contents/lib") file(REMOVE_RECURSE "${CMAKE_INSTALL_PREFIX}/share")