mirror of
				https://github.com/RetroDECK/Duckstation.git
				synced 2025-04-10 19:15:14 +00:00 
			
		
		
		
	Build: Add Mac dependencies and fix packaging
This commit is contained in:
		
							parent
							
								
									a899ca88f2
								
							
						
					
					
						commit
						0006c54c46
					
				
							
								
								
									
										84
									
								
								.github/workflows/rolling-release.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										84
									
								
								.github/workflows/rolling-release.yml
									
									
									
									
										vendored
									
									
								
							|  | @ -310,46 +310,51 @@ jobs: | |||
| #        name: "linux-x64-appimage-qt-zsync" | ||||
| #        path: "build/duckstation-qt-x64.AppImage.zsync" | ||||
| 
 | ||||
| # Disabled until we switch to macdeployqt | ||||
| #  macos-build: | ||||
| #    runs-on: macos-11 | ||||
| #    steps: | ||||
| #    - uses: actions/checkout@v2.3.1 | ||||
| #      with: | ||||
| #        fetch-depth: 0 | ||||
| # | ||||
| #    - name: Install packages | ||||
| #      shell: bash | ||||
| #      run: | | ||||
| #        brew install qt6 sdl2 curl ninja | ||||
| # | ||||
| #    - name: Clone mac externals | ||||
| #      shell: bash | ||||
| #      run: | | ||||
| #        git clone https://github.com/stenzek/duckstation-ext-mac.git dep/mac | ||||
| # | ||||
| #    - name: Compile and zip .app | ||||
| #      shell: bash | ||||
| #      run: | | ||||
| #        mkdir build | ||||
| #        cd build | ||||
| #        ls -lh /usr/local/opt | ||||
| #        export MACOSX_DEPLOYMENT_TARGET=10.14 | ||||
| #        cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_NOGUI_FRONTEND=OFF -DBUILD_QT_FRONTEND=ON -DUSE_SDL2=ON -DQt6_DIR=/usr/local/opt/qt@6/lib/cmake/Qt6 -G Ninja .. | ||||
| #        cmake --build . --parallel | ||||
| #        cd bin | ||||
| #        zip -r duckstation-mac-release.zip DuckStation.app/ | ||||
| # | ||||
| #    - name: Upload macOS .app | ||||
| #      uses: actions/upload-artifact@v1 | ||||
| #      with: | ||||
| #        name: "macos-x64" | ||||
| #        path: "build/bin/duckstation-mac-release.zip" | ||||
| 
 | ||||
|   macos-build: | ||||
|     runs-on: macos-11 | ||||
|     steps: | ||||
|     - uses: actions/checkout@v2.3.1 | ||||
|       with: | ||||
|         fetch-depth: 0 | ||||
| 
 | ||||
|     - name: Install packages | ||||
|       shell: bash | ||||
|       run: | | ||||
|         brew install curl ninja | ||||
| 
 | ||||
|     - name: Cache Dependencies | ||||
|       id: cache-deps-mac | ||||
|       uses: actions/cache@v3 | ||||
|       with: | ||||
|         path: ~/deps | ||||
|         key: deps-mac ${{ hashFiles('scripts/build-dependencies-mac.sh') }} | ||||
| 
 | ||||
|     - name: Build Dependencies | ||||
|       if: steps.cache-deps-mac.outputs.cache-hit != 'true' | ||||
|       run: scripts/build-dependencies-mac.sh | ||||
| 
 | ||||
|     - name: Compile and zip .app | ||||
|       shell: bash | ||||
|       run: | | ||||
|         mkdir build | ||||
|         cd build | ||||
|         export MACOSX_DEPLOYMENT_TARGET=10.14 | ||||
|         cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_NOGUI_FRONTEND=OFF -DBUILD_QT_FRONTEND=ON -DUSE_SDL2=ON -DCMAKE_PREFIX_PATH=$HOME/deps -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON -G Ninja .. | ||||
|         cmake --build . --parallel | ||||
|         cd bin | ||||
|         zip -r duckstation-mac-release.zip DuckStation.app/ | ||||
| 
 | ||||
|     - name: Upload macOS .app | ||||
|       uses: actions/upload-artifact@v1 | ||||
|       with: | ||||
|         name: "macos" | ||||
|         path: "build/bin/duckstation-mac-release.zip" | ||||
| 
 | ||||
| 
 | ||||
|   create-release: | ||||
|     #needs: [windows-build, windows-arm64-build, linux-build, windows-uwp-build] | ||||
|     needs: [windows-build, windows-arm64-build, linux-build] | ||||
|     needs: [windows-build, windows-arm64-build, linux-build, macos-build] | ||||
|     runs-on: "ubuntu-20.04" | ||||
|     if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev' | ||||
|     steps: | ||||
|  | @ -388,6 +393,11 @@ jobs: | |||
| #        with: | ||||
| #          name: "linux-x64-appimage-qt-zsync" | ||||
| 
 | ||||
|       - name: Download MacOS Artifact | ||||
|         uses: actions/download-artifact@v1 | ||||
|         with: | ||||
|           name: "macos" | ||||
| 
 | ||||
|       - name: Create preview release | ||||
|         if: github.ref == 'refs/heads/master' | ||||
|         uses: "marvinpinto/action-automatic-releases@latest" | ||||
|  | @ -402,6 +412,7 @@ jobs: | |||
|             windows-arm64/duckstation-windows-arm64-release.zip | ||||
|             windows-arm64/duckstation-windows-arm64-release-symbols.zip | ||||
|             linux-x64-appimage-qt/DuckStation-x64.AppImage | ||||
|             macos/duckstation-mac-release.zip | ||||
| #            linux-x64-appimage-qt/duckstation-qt-x64.AppImage | ||||
| #            linux-x64-appimage-qt-zsync/duckstation-qt-x64.AppImage.zsync | ||||
| #            windows-uwp/duckstation-uwp.appx | ||||
|  | @ -423,6 +434,7 @@ jobs: | |||
|             windows-arm64/duckstation-windows-arm64-release.zip | ||||
|             windows-arm64/duckstation-windows-arm64-release-symbols.zip | ||||
|             linux-x64-appimage-qt/DuckStation-x64.AppImage | ||||
|             macos/duckstation-mac-release.zip | ||||
| #            linux-x64-appimage-qt/duckstation-qt-x64.AppImage | ||||
| #            linux-x64-appimage-qt-zsync/duckstation-qt-x64.AppImage.zsync | ||||
| #            windows-uwp/duckstation-uwp.appx | ||||
|  |  | |||
							
								
								
									
										122
									
								
								scripts/build-dependencies-mac.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										122
									
								
								scripts/build-dependencies-mac.sh
									
									
									
									
									
										Executable file
									
								
							|  | @ -0,0 +1,122 @@ | |||
| #!/bin/bash | ||||
| 
 | ||||
| set -e | ||||
| 
 | ||||
| export MACOSX_DEPLOYMENT_TARGET=10.14 | ||||
| INSTALLDIR="$HOME/deps" | ||||
| NPROCS="$(getconf _NPROCESSORS_ONLN)" | ||||
| SDL=SDL2-2.0.22 | ||||
| QT=6.3.1 | ||||
| MOLTENVK=1.1.10 | ||||
| CURL=7.84.0 | ||||
| 
 | ||||
| mkdir deps-build | ||||
| cd deps-build | ||||
| 
 | ||||
| export PKG_CONFIG_PATH="$INSTALLDIR/lib/pkgconfig:$PKG_CONFIG_PATH" | ||||
| export LDFLAGS="-L$INSTALLDIR/lib -dead_strip $LDFLAGS" | ||||
| export CFLAGS="-I$INSTALLDIR/include -Os $CFLAGS" | ||||
| export CXXFLAGS="-I$INSTALLDIR/include -Os $CXXFLAGS" | ||||
| 
 | ||||
| cat > SHASUMS <<EOF | ||||
| fe7cbf3127882e3fc7259a75a0cb585620272c51745d3852ab9dd87960697f2e  $SDL.tar.gz | ||||
| fac11c2501195c9ce042103685c7778e35484562e6c084963a22072dd0a602e0  v$MOLTENVK.tar.gz | ||||
| 3c6893d38d054d4e378267166858698899e9d87258e8ff1419d020c395384535  curl-$CURL.tar.gz | ||||
| 0a64421d9c2469c2c48490a032ab91d547017c9cc171f3f8070bc31888f24e03  qtbase-everywhere-src-$QT.tar.xz | ||||
| 7b19f418e6f7b8e23344082dd04440aacf5da23c5a73980ba22ae4eba4f87df7  qtsvg-everywhere-src-$QT.tar.xz | ||||
| c412750f2aa3beb93fce5f30517c607f55daaeb7d0407af206a8adf917e126c1  qttools-everywhere-src-$QT.tar.xz | ||||
| d7bdd55e2908ded901dcc262157100af2a490bf04d31e32995f6d91d78dfdb97  qttranslations-everywhere-src-$QT.tar.xz | ||||
| EOF | ||||
| 
 | ||||
| curl -L \ | ||||
| 	-O "https://libsdl.org/release/$SDL.tar.gz" \ | ||||
|         -O "https://github.com/KhronosGroup/MoltenVK/archive/refs/tags/v$MOLTENVK.tar.gz" \ | ||||
|         -O "https://curl.se/download/curl-$CURL.tar.gz" \ | ||||
| 	-O "https://download.qt.io/official_releases/qt/${QT%.*}/$QT/submodules/qtbase-everywhere-src-$QT.tar.xz" \ | ||||
| 	-O "https://download.qt.io/official_releases/qt/${QT%.*}/$QT/submodules/qtsvg-everywhere-src-$QT.tar.xz" \ | ||||
| 	-O "https://download.qt.io/official_releases/qt/${QT%.*}/$QT/submodules/qttools-everywhere-src-$QT.tar.xz" \ | ||||
| 	-O "https://download.qt.io/official_releases/qt/${QT%.*}/$QT/submodules/qttranslations-everywhere-src-$QT.tar.xz" | ||||
| 
 | ||||
| shasum -a 256 --check SHASUMS | ||||
| 
 | ||||
| echo "Installing SDL..." | ||||
| tar xf "$SDL.tar.gz" | ||||
| cd "$SDL" | ||||
| ./configure --prefix "$INSTALLDIR" --without-x | ||||
| make "-j$NPROCS" | ||||
| make install | ||||
| cd .. | ||||
| 
 | ||||
| echo "Installing curl..." | ||||
| tar xf "curl-$CURL.tar.gz" | ||||
| cd "curl-$CURL" | ||||
| ./configure --prefix "$INSTALLDIR" --with-secure-transport | ||||
| make "-j$NPROCS" | ||||
| make install | ||||
| cd .. | ||||
| 
 | ||||
| echo "Installing MoltenVK..." | ||||
| tar xf "v$MOLTENVK.tar.gz" | ||||
| cd "MoltenVK-${MOLTENVK}" | ||||
| ./fetchDependencies --macos | ||||
| make macos | ||||
| cp Package/Latest/MoltenVK/dylib/macOS/libMoltenVK.dylib $HOME/deps/lib/ | ||||
| cd .. | ||||
| 
 | ||||
| echo "Installing Qt Base..." | ||||
| tar xf "qtbase-everywhere-src-$QT.tar.xz" | ||||
| cd "qtbase-everywhere-src-$QT" | ||||
| mkdir build | ||||
| cd build | ||||
| cmake -G Ninja -DCMAKE_PREFIX_PATH="$INSTALLDIR" -DCMAKE_INSTALL_PREFIX="$INSTALLDIR" -DCMAKE_BUILD_TYPE=Release -DFEATURE_optimize_size=ON -DFEATURE_dbus=OFF -DFEATURE_framework=OFF -DFEATURE_icu=OFF -DFEATURE_opengl=OFF -DFEATURE_printsupport=OFF -DFEATURE_sql=OFF .. | ||||
| cmake --build . --parallel | ||||
| cmake --install . | ||||
| cd ../../ | ||||
| 
 | ||||
| echo "Installing Qt SVG..." | ||||
| tar xf "qtsvg-everywhere-src-$QT.tar.xz" | ||||
| cd "qtsvg-everywhere-src-$QT" | ||||
| mkdir build | ||||
| cd build | ||||
| cmake -G Ninja -DCMAKE_PREFIX_PATH="$INSTALLDIR" -DCMAKE_INSTALL_PREFIX="$INSTALLDIR" -DCMAKE_BUILD_TYPE=MinSizeRel .. | ||||
| cmake --build . --parallel | ||||
| cmake --install . | ||||
| cd ../../ | ||||
| 
 | ||||
| echo "Installing Qt Tools..." | ||||
| tar xf "qttools-everywhere-src-$QT.tar.xz" | ||||
| cd "qttools-everywhere-src-$QT" | ||||
| # Linguist relies on a library in the Designer target, which takes 5-7 minutes to build on the CI | ||||
| # Avoid it by not building Linguist, since we only need the tools that come with it | ||||
| patch -u src/linguist/CMakeLists.txt <<EOF | ||||
| --- src/linguist/CMakeLists.txt | ||||
| +++ src/linguist/CMakeLists.txt | ||||
| @@ -14,7 +14,7 @@ | ||||
|  add_subdirectory(lrelease-pro) | ||||
|  add_subdirectory(lupdate) | ||||
|  add_subdirectory(lupdate-pro) | ||||
| -if(QT_FEATURE_process AND QT_FEATURE_pushbutton AND QT_FEATURE_toolbutton AND TARGET Qt::Widgets AND NOT no-png) | ||||
| +if(QT_FEATURE_process AND QT_FEATURE_pushbutton AND QT_FEATURE_toolbutton AND TARGET Qt::Widgets AND TARGET Qt::PrintSupport AND NOT no-png) | ||||
|      add_subdirectory(linguist) | ||||
|  endif() | ||||
| EOF | ||||
| mkdir build | ||||
| cd build | ||||
| cmake -G Ninja -DCMAKE_PREFIX_PATH="$INSTALLDIR" -DCMAKE_INSTALL_PREFIX="$INSTALLDIR" -DCMAKE_BUILD_TYPE=Release -DFEATURE_assistant=OFF -DFEATURE_clang=OFF -DFEATURE_designer=OFF -DFEATURE_kmap2qmap=OFF -DFEATURE_pixeltool=OFF -DFEATURE_pkg_config=OFF -DFEATURE_qev=OFF -DFEATURE_qtattributionsscanner=OFF -DFEATURE_qtdiag=OFF -DFEATURE_qtplugininfo=OFF .. | ||||
| cmake --build . --parallel | ||||
| cmake --install . | ||||
| cd ../../ | ||||
| 
 | ||||
| echo "Installing Qt Translations..." | ||||
| tar xf "qttranslations-everywhere-src-$QT.tar.xz" | ||||
| cd "qttranslations-everywhere-src-$QT" | ||||
| mkdir build | ||||
| cd build | ||||
| cmake -G Ninja -DCMAKE_PREFIX_PATH="$INSTALLDIR" -DCMAKE_INSTALL_PREFIX="$INSTALLDIR" -DCMAKE_BUILD_TYPE=Release .. | ||||
| cmake --build . --parallel | ||||
| cmake --install . | ||||
| cd ../../ | ||||
| 
 | ||||
| echo "Cleaning up..." | ||||
| cd .. | ||||
| rm -fr deps-build | ||||
|  | @ -30,6 +30,7 @@ | |||
| #include <mach/mach_time.h> | ||||
| #include <mach/semaphore.h> | ||||
| #include <mach/task.h> | ||||
| #else | ||||
| #include <pthread_np.h> | ||||
| #endif | ||||
| #endif | ||||
|  | @ -382,7 +383,7 @@ void* Threading::Thread::ThreadProc(void* param) | |||
| 
 | ||||
| bool Threading::Thread::Start(EntryPoint func) | ||||
| { | ||||
|   pxAssertRel(!m_native_handle, "Can't start an already-started thread"); | ||||
|   AssertMsg(!m_native_handle, "Can't start an already-started thread"); | ||||
| 
 | ||||
|   std::unique_ptr<EntryPoint> func_clone(std::make_unique<EntryPoint>(std::move(func))); | ||||
| 
 | ||||
|  | @ -550,6 +551,8 @@ void Threading::SetNameOfCurrentThread(const char* name) | |||
|   // Extract of manpage: "The name can be up to 16 bytes long, and should be
 | ||||
|   //						null-terminated if it contains fewer bytes."
 | ||||
|   prctl(PR_SET_NAME, name, 0, 0, 0); | ||||
| #elif defined(__APPLE__) | ||||
|   pthread_setname_np(name); | ||||
| #else | ||||
|   pthread_set_name_np(pthread_self(), name); | ||||
| #endif | ||||
|  |  | |||
|  | @ -196,34 +196,31 @@ if(APPLE) | |||
|     MACOSX_BUNDLE true | ||||
|     MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist.in | ||||
|     OUTPUT_NAME DuckStation | ||||
|     ) | ||||
|   ) | ||||
| 
 | ||||
|   # Copy qt.conf into the bundle | ||||
|   target_sources(duckstation-qt PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/qt.conf") | ||||
|   set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/qt.conf" PROPERTIES MACOSX_PACKAGE_LOCATION Resources) | ||||
|   # Use macdeployqt to inject Qt into the bundle. | ||||
|   get_target_property(MOC_EXECUTABLE_LOCATION Qt6::moc IMPORTED_LOCATION) | ||||
|   get_filename_component(QT_BINARY_DIRECTORY "${MOC_EXECUTABLE_LOCATION}" DIRECTORY) | ||||
|   find_program(MACDEPLOYQT_EXE macdeployqt HINTS "${QT_BINARY_DIRECTORY}") | ||||
|   add_custom_target(duckstation-postprocess-bundle ALL | ||||
|     COMMAND "${MACDEPLOYQT_EXE}" "${BUNDLE_PATH}" | ||||
|   ) | ||||
|   add_dependencies(duckstation-postprocess-bundle duckstation-qt) | ||||
| 
 | ||||
|   # Copy icon into the bundle | ||||
|   target_sources(duckstation-qt PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/DuckStation.icns") | ||||
|   set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/DuckStation.icns" PROPERTIES MACOSX_PACKAGE_LOCATION Resources) | ||||
| 
 | ||||
|   # Copy Qt plugins into the bundle | ||||
|   get_target_property(qtcocoa_location Qt6::QCocoaIntegrationPlugin LOCATION) | ||||
|   target_sources(duckstation-qt PRIVATE "${qtcocoa_location}") | ||||
|   set_source_files_properties("${qtcocoa_location}" PROPERTIES MACOSX_PACKAGE_LOCATION MacOS/platforms) | ||||
| 
 | ||||
|   get_target_property(qtmacstyle_location Qt6::QMacStylePlugin LOCATION) | ||||
|   target_sources(duckstation-qt PRIVATE "${qtmacstyle_location}") | ||||
|   set_source_files_properties("${qtmacstyle_location}" PROPERTIES MACOSX_PACKAGE_LOCATION MacOS/styles) | ||||
| 
 | ||||
|   # Copy resources into the bundle | ||||
|   set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/data") | ||||
|   file(GLOB_RECURSE resources RELATIVE "${CMAKE_SOURCE_DIR}/data" "${CMAKE_SOURCE_DIR}/data/*") | ||||
|   set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/data/resources") | ||||
|   file(GLOB_RECURSE resources RELATIVE "${CMAKE_SOURCE_DIR}/data/resources" "${CMAKE_SOURCE_DIR}/data/resources/*") | ||||
|   foreach(res ${resources}) | ||||
|     target_sources(duckstation-qt PRIVATE "${CMAKE_SOURCE_DIR}/data/${res}") | ||||
|     message(STATUS "Resource: ${res}") | ||||
|     target_sources(duckstation-qt PRIVATE "${CMAKE_SOURCE_DIR}/data/resources/${res}") | ||||
|     get_filename_component(resdir "${res}" DIRECTORY) | ||||
|     set_source_files_properties("${CMAKE_SOURCE_DIR}/data/${res}" PROPERTIES | ||||
|       MACOSX_PACKAGE_LOCATION "MacOS/${resdir}") | ||||
|     source_group("Resources" FILES "${CMAKE_SOURCE_DIR}/data/${res}") | ||||
|     set_source_files_properties("${CMAKE_SOURCE_DIR}/data/resources/${res}" PROPERTIES | ||||
|       MACOSX_PACKAGE_LOCATION "Resources/${resdir}") | ||||
|     source_group("Resources" FILES "${CMAKE_SOURCE_DIR}/data/resources/${res}") | ||||
|   endforeach() | ||||
| 
 | ||||
|   # Copy translations into the bundle | ||||
|  | @ -233,16 +230,17 @@ if(APPLE) | |||
|                      COMMAND cp ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/translations/*.qm $<TARGET_FILE_DIR:duckstation-qt>/translations) | ||||
| 
 | ||||
|   # Copy MoltenVK into the bundle | ||||
|   target_sources(duckstation-qt PRIVATE "${CMAKE_SOURCE_DIR}/dep/mac/MoltenVK/libvulkan.dylib") | ||||
|   set_source_files_properties("${CMAKE_SOURCE_DIR}/dep/mac/MoltenVK/libvulkan.dylib" PROPERTIES MACOSX_PACKAGE_LOCATION Frameworks) | ||||
| 
 | ||||
|   # Update library references to make the bundle portable | ||||
|   include(DolphinPostprocessBundle) | ||||
|   dolphin_postprocess_bundle(duckstation-qt) | ||||
|   # Fix rpath | ||||
|   add_custom_command(TARGET duckstation-qt | ||||
|     POST_BUILD COMMAND | ||||
|     ${CMAKE_INSTALL_NAME_TOOL} -add_rpath "@executable_path/../Frameworks/" | ||||
|     $<TARGET_FILE:duckstation-qt>) | ||||
|   unset(MOLTENVK_PATH CACHE) | ||||
|   find_file(MOLTENVK_PATH NAMES | ||||
|     libMoltenVK.dylib | ||||
|     lib/libMoltenVK.dylib | ||||
|   ) | ||||
|   if (MOLTENVK_PATH) | ||||
|     target_sources(duckstation-qt PRIVATE "${MOLTENVK_PATH}") | ||||
|     set_source_files_properties("${MOLTENVK_PATH}" PROPERTIES MACOSX_PACKAGE_LOCATION Frameworks) | ||||
|     message(STATUS "Using MoltenVK from ${MOLTENVK_PATH}") | ||||
|   else() | ||||
|     message(WARNING "MoltenVK not found in path, it will depend on the target system having it.") | ||||
|   endif() | ||||
| endif() | ||||
| 
 | ||||
|  |  | |||
|  | @ -34,6 +34,7 @@ | |||
| #include "util/ini_settings_interface.h" | ||||
| #include <atomic> | ||||
| #include <bitset> | ||||
| #include <unordered_map> | ||||
| #include <thread> | ||||
| Log_SetChannel(FullscreenUI); | ||||
| 
 | ||||
|  |  | |||
|  | @ -18,6 +18,7 @@ | |||
| #include <array> | ||||
| #include <cctype> | ||||
| #include <ctime> | ||||
| #include <unordered_map> | ||||
| #include <string_view> | ||||
| #include <tinyxml2.h> | ||||
| #include <utility> | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue
	
	 Connor McLaughlin
						Connor McLaughlin