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

Provide automatic macOS releases with Apple Silicon support #14839

Merged
merged 9 commits into from
Sep 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 38 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ on:
- master
# For testing.
- actions
tags:
- "v*.*.*"
paths-ignore:
- '*.{txt,md}'
- 'Tools/**'
Expand Down Expand Up @@ -165,7 +167,7 @@ jobs:
extra: test
cc: clang
cxx: clang++
args: ./b.sh --headless
args: ./b.sh --headless --fat --no-png --no-sdl2
- os: macos-latest
extra: ios
cc: clang
Expand All @@ -178,6 +180,12 @@ jobs:
with:
submodules: recursive

- name: Fetch tags for macOS releases
if: runner.os == 'macOS'
# This is required for git describe --always to work for git-version.cpp.
run: |
git fetch --deepen=15000 --tags || exit 0

- name: Cache Qt
uses: actions/cache@v1
if: matrix.extra == 'qt'
Expand Down Expand Up @@ -205,10 +213,11 @@ jobs:
sudo apt-get update -y -qq
sudo apt-get install libsdl2-dev libgl1-mesa-dev libglu1-mesa-dev

- name: Install macOS dependencies
if: runner.os == 'macOS' && matrix.extra != 'ios'
- name: Create macOS git-version.cpp for tagged release
if: startsWith(github.ref, 'refs/tags/') && runner.os == 'macOS' && matrix.extra == 'test'
run: |
brew install sdl2
echo "const char *PPSSPP_GIT_VERSION = \"${GITHUB_REF##*/}\";" > git-version.cpp
echo "#define PPSSPP_GIT_VERSION_NO_UPDATE 1" >> git-version.cpp

- name: Execute build
env:
Expand All @@ -224,7 +233,12 @@ jobs:
if [ -e build*/$BUILD_CONFIGURATION/PPSSPPSDL ]; then
cp build*/$BUILD_CONFIGURATION/PPSSPPSDL ppsspp/
elif [ -e build*/PPSSPPSDL.app ]; then
cp -r build*/PPSSPPSDL.app ppsspp/
cp -a build*/PPSSPPSDL.app ppsspp/
# GitHub Actions zipping kills symlinks and permissions.
cd ppsspp
zip -qry PPSSPPSDL.zip PPSSPPSDL.app
rm -rf PPSSPPSDL.app
cd -
elif [ -e build*/PPSSPPSDL ]; then
cp build*/PPSSPPSDL ppsspp/
cp -r assets ppsspp/assets
Expand All @@ -242,6 +256,24 @@ jobs:
name: ${{ matrix.os }} build
path: ppsspp/

- name: Create macOS release
if: startsWith(github.ref, 'refs/tags/') && runner.os == 'macOS' && matrix.extra == 'test'
run: |
cd ppsspp || exit 1
mv PPSSPPSDL.zip PPSSPPSDL-macOS-${GITHUB_REF##*/}.zip || exit 1

- name: Upload macOS release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/') && runner.os == 'macOS' && matrix.extra == 'test'
with:
files: ppsspp/*.zip
body: >
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not really a fan of creating releases with generic messages for each release. That's exactly the terrible practice Android apps have started using, and I hate it there too.

-[Unknown]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, it feels natural to me to edit the release message afterwards with e.g. a changelog manually. This code is just a convenience message to have something before this happens. There is no restriction to the amount of edits, so I feel there is no big issue in leaving it as is, especially since there is no good place to source the release message automatically anyway. Correct me if you think I am wrong.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Well, I don't think anyone will edit them, but okay. Honestly, I'd prefer the release notes were just the version again like now:
https://github.com/hrydgard/ppsspp/releases

Rather than a message that repeats for every single release. Those are not "release notes", those are a description (this repo already has one of those.)

-[Unknown]

PPSSPP is a cross-platform PSP emulator.
Visit PPSSPP [official website](https://ppsspp.org)
for a [full changelog](https://ppsspp.org/index.html#news)
as well as the [downloads section](https://ppsspp.org/downloads.html)
for other platforms.

test:
strategy:
fail-fast: false
Expand Down Expand Up @@ -271,7 +303,7 @@ jobs:
- name: Install macOS dependencies
if: runner.os == 'macOS'
run: |
brew install sdl2
git submodule update --init SDL/macOS

- name: Download build
uses: actions/download-artifact@v2
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@
[submodule "zstd"]
path = ext/zstd
url = https://github.com/facebook/zstd.git
[submodule "SDL/macOS"]
path = SDL/macOS
url = https://github.com/hrydgard/ppsspp-mac-sdl
26 changes: 21 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,15 @@ endif()

# Detect CPU from CMAKE configuration. Toolchains should set this up
if(CMAKE_SYSTEM_PROCESSOR)
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "^aarch64")
if(CMAKE_OSX_ARCHITECTURES)
if("${CMAKE_OSX_ARCHITECTURES}" MATCHES ".*86.*")
set(X86_DEVICE ON)
set(X86_64_DEVICE ON)
endif()
if("${CMAKE_OSX_ARCHITECTURES}" MATCHES "arm64")
set(ARM64 ON)
endif()
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "^aarch64")
set(ARM64 ON)
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "^arm64")
# M1 Mac
Expand Down Expand Up @@ -94,10 +102,14 @@ if(ANDROID OR WIN32 OR (UNIX AND NOT ARM_NO_VULKAN))
endif()

list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)
if(NOT ((ARM64 AND MACOSX) OR IOS))
if(NOT IOS)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/sdl)
endif()

if(MACOSX AND NOT USE_SYSTEM_LIBSDL2)
set(SDL2_LIBRARY ${CMAKE_SOURCE_DIR}/SDL/macOS/SDL2.framework)
endif()

include(ccache)
include(GNUInstallDirs)

Expand Down Expand Up @@ -139,6 +151,8 @@ option(USE_MINIUPNPC "Build with miniUPnPc support" ON)
option(USE_SYSTEM_SNAPPY "Dynamically link against system snappy" ${USE_SYSTEM_SNAPPY})
option(USE_SYSTEM_FFMPEG "Dynamically link against system FFMPEG" ${USE_SYSTEM_FFMPEG})
option(USE_SYSTEM_LIBZIP "Dynamically link against system libzip" ${USE_SYSTEM_LIBZIP})
option(USE_SYSTEM_LIBSDL2 "Dynamically link against system SDL2" ON)
option(USE_SYSTEM_LIBPNG "Dynamically link against system libpng" ON)
option(USE_ASAN "Use address sanitizer" OFF)
option(USE_UBSAN "Use undefined behaviour sanitizer" OFF)

Expand Down Expand Up @@ -959,7 +973,9 @@ else()
set(PNG_REQUIRED_VERSION 1.6)
endif()

if(USE_SYSTEM_LIBPNG)
find_package(PNG ${PNG_REQUIRED_VERSION})
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can this be indented?

-[Unknown]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this one is finding "system" libpng, which on macOS can come from a package manager, such as brew or MacPorts. Doing this will result in linking to a library that does not come with macOS and is thus broken.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I just mean mechanically, the find_package(PNG ${PNG_REQUIRED_VERSION}) should have a tab character before it.

-[Unknown]

endif()
if(PNG_FOUND)
include_directories(${PNG_INCLUDE_DIRS})
else()
Expand Down Expand Up @@ -2317,10 +2333,10 @@ if(TargetBin)
endif()

if(IOS)
add_executable(${TargetBin} MACOSX_BUNDLE ${ICON_PATH_ABS} ${NativeAssets} ${SHADER_FILES} ${FLASH0_FILES} ${LANG_FILES} ${NativeAppSource} "ios/Settings.bundle" "ios/Launch Screen.storyboard" "MoltenVK/iOS/Frameworks")
add_executable(${TargetBin} MACOSX_BUNDLE ${ICON_PATH_ABS} ${NativeAssets} ${SHADER_FILES} ${FLASH0_FILES} ${LANG_FILES} ${NativeAppSource} "ios/Settings.bundle" "ios/Launch Screen.storyboard" "ext/vulkan/iOS/Frameworks")
else()
add_executable(${TargetBin} MACOSX_BUNDLE ${ICON_PATH_ABS} ${NativeAssets} ${SHADER_FILES} ${FLASH0_FILES} ${LANG_FILES} ${NativeAppSource})
file(INSTALL "${CMAKE_SOURCE_DIR}/MoltenVK/macOS/Frameworks/libMoltenVK.dylib" DESTINATION "${CMAKE_BINARY_DIR}/PPSSPPSDL.app/Contents/Frameworks/")
file(INSTALL "${CMAKE_SOURCE_DIR}/ext/vulkan/macOS/Frameworks/libMoltenVK.dylib" DESTINATION "${CMAKE_BINARY_DIR}/PPSSPPSDL.app/Contents/Frameworks/")
if(TARGET SDL2::SDL2 AND NOT USING_QT_UI)
add_custom_command(TARGET ${TargetBin} POST_BUILD COMMAND /bin/bash "${CMAKE_SOURCE_DIR}/SDL/macbundle.sh" "${CMAKE_BINARY_DIR}/PPSSPPSDL.app")
elseif(USING_QT_UI)
Expand Down Expand Up @@ -2379,7 +2395,7 @@ if(IOS)
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/ios/PPSSPP-Info.plist"
RESOURCE "ios/Launch Screen.storyboard"
RESOURCE "ios/Settings.bundle"
RESOURCE "MoltenVK/iOS/Frameworks"
RESOURCE "ext/vulkan/iOS/Frameworks"
XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET ${DEPLOYMENT_TARGET}
XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY "iPhone/iPad"
XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC YES
Expand Down
Binary file removed MoltenVK/macOS/Frameworks/libMoltenVK.dylib
Binary file not shown.
1 change: 1 addition & 0 deletions SDL/macOS
Submodule macOS added at f19a1d
41 changes: 28 additions & 13 deletions SDL/macbundle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,36 @@ if [ ! -f "${PPSSPPSDL}" ]; then
fi

SDL=$(otool -L "${PPSSPPSDL}" | grep -v @executable_path | grep -Eo /.+libSDL.+dylib)
if [ "${SDL}" = "" ]; then
echo "SDL is already bundled/unused."
exit 0
fi
if [ "${SDL}" != "" ]; then
if [ ! -f "${SDL}" ]; then
echo "Cannot locate SDL: ${SDL}!"
exit 0
fi

if [ ! -f "${SDL}" ]; then
echo "Cannot locate SDL: ${SDL}!"
exit 0
fi
echo "Installing SDL from ${SDL}..."

echo "Installing SDL from ${SDL}..."
SDLNAME=$(basename "${SDL}")
mkdir -p "${PPSSPP}/Contents/Frameworks" || exit 0
cp -r "$SDL" "${PPSSPP}/Contents/Frameworks" || exit 0
install_name_tool -change "${SDL}" "@executable_path/../Frameworks/${SDLNAME}" "${PPSSPPSDL}" || exit 0
elif [ "$(otool -L "${PPSSPPSDL}" | grep @rpath/SDL)" != "" ]; then
cd "$(dirname "$0")"
RPATH="$(pwd)/macOS"
cd -
SDL="${RPATH}/SDL2.framework"
if [ ! -d "${SDL}" ]; then
echo "Cannot locate SDL.framework: ${SDL}!"
exit 0
fi

SDLNAME=$(basename "${SDL}")
mkdir -p "${PPSSPP}/Contents/Frameworks" || exit 0
cp -r "$SDL" "${PPSSPP}/Contents/Frameworks" || exit 0
install_name_tool -change "${SDL}" "@executable_path/../Frameworks/${SDLNAME}" "${PPSSPPSDL}" || exit 0
rm -rf "${PPSSPP}/Contents/Frameworks/SDL2.framework" || exit 0
mkdir -p "${PPSSPP}/Contents/Frameworks" || exit 0
cp -a "$SDL" "${PPSSPP}/Contents/Frameworks" || exit 0
install_name_tool -rpath "${RPATH}" "@executable_path/../Frameworks" "${PPSSPPSDL}" || echo "Already patched."
fi

GIT_VERSION_LINE=$(grep "PPSSPP_GIT_VERSION = " "$(dirname "${0}")/../git-version.cpp")
echo "Setting version to ${GIT_VERSION_LINE}..."
Copy link
Contributor Author

@vit9696 vit9696 Sep 13, 2021

Choose a reason for hiding this comment

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

I am worried about the version string in the builds. Currently there seem to be 2 bugs:

  1. The generated version string only has the commit hash and not the version number (1.2.3). See this print from the log.
  2. How can I make sure there is no commit suffix in the tagged releases? I.e. I have the 1.2.3 version name alone if it is a tagged build.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe fixed (1) in https://github.com/vit9696/ppsspp/commit/ed046aebf5608869fd49fb55204715b01bc5620b. I am not sure what route shall I take to fix (2). Is it alright to make git-version.cpp with PPSSPP_GIT_VERSION_NO_UPDATE set to 1 in one of the CI stages for tagged commits?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess that's fine, as long as it has the right values. I would think you'd need to fetch tags, i.e. git fetch --tags or more ideally git fetch <remote> 'refs/tags/*:refs/tags/* to be able to have git describe fetch the right thing. That would probably fetch less and be faster.

-[Unknown]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried that, but it did not work for me. I believe the reason is that we not only need to fetch the tags, but also connect tags to the history, otherwise one would get ge1cb1c9a6 instead of v1.11.3-1350-ge1cb1c9a6 for intermediate releases. I changed the code to only fetch history on macOS, however, which should improve the situation quite a bit.

SHORT_VERSION_MATCH='.*"v([0-9\.]+(-[0-9]+)?).*";'
LONG_VERSION_MATCH='.*"v(.*)";'
if [[ "${GIT_VERSION_LINE}" =~ ^${SHORT_VERSION_MATCH}$ ]]; then
Expand All @@ -36,3 +48,6 @@ else
plutil -replace CFBundleShortVersionString -string "" ${PPSSPP}/Contents/Info.plist
plutil -replace CFBundleVersion -string "" ${PPSSPP}/Contents/Info.plist
fi

# AdHoc codesign is required for Apple Silicon.
codesign -fs - --deep "${PPSSPP}" || exit 1
12 changes: 9 additions & 3 deletions b.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,21 @@ do
--ios-xcode) CMAKE_ARGS="-DCMAKE_TOOLCHAIN_FILE=cmake/Toolchains/ios.cmake -DIOS_PLATFORM=OS -GXcode ${CMAKE_ARGS}"
TARGET_OS=iOS-xcode
;;
--fat) CMAKE_ARGS="-DCMAKE_OSX_ARCHITECTURES=arm64;x86_64 ${CMAKE_ARGS}"
;;
--no-png) CMAKE_ARGS="-DUSE_SYSTEM_LIBPNG=OFF ${CMAKE_ARGS}"
;;
--no-sdl2) CMAKE_ARGS="-DUSE_SYSTEM_LIBSDL2=OFF ${CMAKE_ARGS}"
;;
--rpi-armv6)
CMAKE_ARGS="-DCMAKE_TOOLCHAIN_FILE=cmake/Toolchains/raspberry.armv6.cmake ${CMAKE_ARGS}"
;;
--rpi)
CMAKE_ARGS="-DCMAKE_TOOLCHAIN_FILE=cmake/Toolchains/raspberry.armv7.cmake ${CMAKE_ARGS}"
;;
--rpi64)
CMAKE_ARGS="-DCMAKE_TOOLCHAIN_FILE=cmake/Toolchains/raspberry.armv8.cmake ${CMAKE_ARGS}"
;;
--rpi64)
CMAKE_ARGS="-DCMAKE_TOOLCHAIN_FILE=cmake/Toolchains/raspberry.armv8.cmake ${CMAKE_ARGS}"
;;
--android) CMAKE_ARGS="-DCMAKE_TOOLCHAIN_FILE=android/android.toolchain.cmake ${CMAKE_ARGS}"
TARGET_OS=Android
PACKAGE=1
Expand Down
Binary file not shown.
Binary file added ext/vulkan/macOS/Frameworks/libMoltenVK.dylib
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VULKAN RELEASE 1.2.154.0 MACOS LICENSE SUMMARY
VULKAN RELEASE 1.2.162.0 MACOS LICENSE SUMMARY
================================================================================

List of Open Source Licenses in use by SDK components:
Expand All @@ -10,6 +10,7 @@ List of Open Source Licenses in use by SDK components:
LGPL-3.0
LLVM
MIT
Qt
Qt2
Unlicensed
glslangPreprocesssor
Expand All @@ -23,6 +24,7 @@ List of copyrights in use by SDK components:
<< Copyright 2016-2020 LunarG Inc.
<string>Copyright (c) 2018 The Khronos Group Inc. LunarG Inc. All rights reserved.<string>
Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2020 Free Software Foundation,
Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
Copyright (C) 2011 Thiago Macieira <thiago@kde.org>
Copyright (C) 2012 Giuseppe D'Angelo <dangelog@gmail.com>.
Expand Down Expand Up @@ -81,7 +83,6 @@ List of copyrights in use by SDK components:
Copyright (c) 2013 The Khronos Group Inc.
Copyright (c) 2014-2016 The Khronos Group Inc.
Copyright (c) 2014-2017 The Khronos Group Inc.
Copyright (c) 2014-2018 The Khronos Group Inc.
Copyright (c) 2014-2019 LunarG, Inc.
Copyright (c) 2014-2019 The Khronos Group Inc.
Copyright (c) 2014-2019 Valve Corporation
Expand Down Expand Up @@ -112,7 +113,6 @@ List of copyrights in use by SDK components:
Copyright (c) 2015-2017 Valve Corporation
Copyright (c) 2015-2017, 2019 Google Inc.
Copyright (c) 2015-2017, 2019 LunarG, Inc.
Copyright (c) 2015-2017, 2019 The Khronos Group Inc.
Copyright (c) 2015-2017, 2019 Valve Corporation
Copyright (c) 2015-2017, 2019-2020 LunarG, Inc.
Copyright (c) 2015-2017, 2019-2020 The Khronos Group Inc.
Expand Down Expand Up @@ -204,7 +204,7 @@ List of copyrights in use by SDK components:
Modifications Copyright (C) 2020 Advanced Micro Devices, Inc. All rights
Modifications Copyright (C) 2020 Advanced Micro Devices, Inc. All rights reserved.
copyright (c) 2014 joseph werle <joseph.werle@gmail.com>
label->setText(QApplication::translate("dlgAbout", "Copyright 2020 LunarG, Inc.", nullptr));
label->setText(QApplication::translate("dialog_about", "Copyright 2020 LunarG, Inc.", nullptr));

The full text of each license is listed below.

Expand Down Expand Up @@ -429,6 +429,24 @@ The above copyright notice and this permission notice shall be included in all c

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

================================================================================
Qt
--------------------------------------------------------------------------------

LunarG’s SDK incorporates the following Qt 5.13 modules and add-ons: Qt Core, Qt GUI, Qt Widgets and Qt WebEngine.

Information on the general Qt 5.13 license is available at this link: https://doc.qt.io/qt-5/licensing.html

Information on the overall Qt Core license and third party modules contained in Qt Core are available at this link: https://doc.qt.io/qt-5/qtcore-index.html

Information on the overall Qt GUI license and third party modules contained in Qt GUI are available at this link: https://doc.qt.io/qt-5/qtgui-index.html

Information on the overall Qt Widgets license is available at this link: https://doc.qt.io/qt-5/qtwidgets-index.html

Information on the overall Qt WebEngine license and third party modules contained in Qt WebEngine are available at this link: https://doc.qt.io/qt-5/qtwebengine-licensing.html



================================================================================
Qt2
--------------------------------------------------------------------------------
Expand Down