Skip to content

Commit

Permalink
Add native build for Apple M1 / M2 (arm64) architecture (#755)
Browse files Browse the repository at this point in the history
  • Loading branch information
awawa-dev committed Feb 2, 2024
1 parent d04527b commit 8656c10
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 7 deletions.
77 changes: 74 additions & 3 deletions .github/workflows/push-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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 🆕)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)

Expand All @@ -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
Expand Down
54 changes: 52 additions & 2 deletions cmake/Dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 8656c10

Please sign in to comment.