Skip to content

Commit

Permalink
Update .ci/build-mac-arm64.sh
Browse files Browse the repository at this point in the history
update

Update ci

Update build-mac.sh
update to be in-align with my other pr

Update build-mac-arm64.sh

update it to have the git submodule change and molten vk version specified

remove && as its not needed

update ci for mac

- add back moltenvk to install from 3rdparty
- update my build-mac script to be on par with  my other pr
- update deploy script to use install_name tool to change the rpath for libs installed with brew and that are set to use system libs

Update build-mac-arm64.sh

Update build-mac-arm64.sh

deploy-mac: move codesign to be after

fix warnings and codesign the executable

Co-Authored-By: UltraHDR <108294295+UltraHDR@users.noreply.github.com>
  • Loading branch information
DarthMDev and UltraHDR committed Jul 4, 2023
1 parent 006aeb9 commit 7d6c442
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 53 deletions.
41 changes: 15 additions & 26 deletions .ci/build-mac-arm64.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/bin/sh -ex

brew update
brew install -f --overwrite nasm ninja git p7zip create-dmg ccache pipenv llvm@16 sdl2 glew cmake molten-vk vulkan-headers faudio qt@5 ffmpeg
brew install -f --overwrite nasm ninja git p7zip create-dmg ccache pipenv llvm@16 sdl2 glew cmake faudio qt@5 ffmpeg@6 molten-vk@1.2.4 vulkan-headers

brew link -f llvm@16


Expand All @@ -10,41 +12,28 @@ export CC=clang

export BREW_PATH;
BREW_PATH="$(brew --prefix)"
export BREW_BIN="/opt/homebrew/bin"
export BREW_BIN="$BREW_PATH/bin"
export BREW_SBIN="$BREW_PATH/sbin"
export CMAKE_EXTRA_OPTS='-DLLVM_TARGETS_TO_BUILD=AArch64;ARM'
export PATH="$(brew --prefix llvm@16)/bin:$BREW_BIN:$BREW_SBIN:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Library/Apple/usr/bin:$PATH"

export PATH
PATH="$(brew --prefix llvm@16)/bin:$BREW_BIN:$BREW_SBIN:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Library/Apple/usr/bin:$PATH"
export LDFLAGS="-L$BREW_PATH/lib -Wl,-rpath,$BREW_PATH/lib"
export CPPFLAGS="-I$BREW_PATH/include"
export LIBRARY_PATH="$BREW_PATH/lib"
export LD_LIBRARY_PATH="$BREW_PATH/lib"
export Qt5_DIR="$(brew --prefix qt@5)/lib/cmake/Qt5"
export Qt5_DIR
Qt5_DIR="$(brew --prefix qt@5)/lib/cmake/Qt5"

export VULKAN_SDK
VULKAN_SDK="$(brew --prefix molten-vk)"
ln -s "$VULKAN_SDK/lib/libMoltenVK.dylib" "$VULKAN_SDK/lib/libvulkan.dylib"
export VK_ICD_FILENAMES="$VULKAN_SDK/share/vulkan/icd.d/MoltenVK_icd.json"
export LLVM_DIR
LLVM_DIR="$(brew --prefix llvm@16)"
git submodule update --init ./3rdparty/asmjit && \
git submodule update --init ./3rdparty/cubeb && \
git submodule update --init ./3rdparty/curl && \
git submodule update --init ./3rdparty/flatbuffers && \
git submodule update --init ./3rdparty/glslang && \
git submodule update --init ./3rdparty/GPUOpen && \
git submodule update --init ./3rdparty/hidapi && \
git submodule update --init ./3rdparty/libpng && \
git submodule update --init ./3rdparty/libsdl-org && \
git submodule update --init ./3rdparty/libusb && \
git submodule update --init ./3rdparty/miniupnp && \
git submodule update --init ./3rdparty/pine && \
git submodule update --init ./3rdparty/pugixml && \
git submodule update --init ./3rdparty/rtmidi && \
git submodule update --init ./3rdparty/SoundTouch && \
git submodule update --init ./3rdparty/SPIRV && \
git submodule update --init ./3rdparty/stblib && \
git submodule update --init ./3rdparty/wolfssl && \
git submodule update --init ./3rdparty/xxHash && \
git submodule update --init ./3rdparty/yaml-cpp

# exclude FAudio, SPIRV, moltenvk and LLVM from submodule update
git submodule -q update --init --depth=1 --jobs=8 $(awk '/path/ && !/FAudio/ && !/MoltenVK && !/llvm/ && !/SPIRV/ { print $3 }' .gitmodules)

# 3rdparty fixes
sed -i '' "s/extern const double NSAppKitVersionNumber;/const double NSAppKitVersionNumber = 1343;/g" 3rdparty/hidapi/hidapi/mac/hid.c
Expand All @@ -58,9 +47,9 @@ mkdir build && cd build || exit 1
-DLLVM_INCLUDE_UTILS=OFF -DLLVM_USE_PERF=OFF -DLLVM_ENABLE_Z3_SOLVER=OFF \
-DUSE_NATIVE_INSTRUCTIONS=OFF \
-DUSE_SYSTEM_FAUDIO=ON \
-DUSE_SYSTEM_MVK=ON \
-DUSE_SYSTEM_MVK=OFF \
-DUSE_SYSTEM_SDL=ON \
-DUSE_SYSTEM_FFMPEG=ON \
-DUSE_SYSTEM_FFMPEG=OFF \
-DPNG_ARM_NEON=on \
$CMAKE_EXTRA_OPTS \
-DLLVM_TARGET_ARCH="AArch64;ARM" -DCMAKE_OSX_ARCHITECTURES=arm64 \
Expand Down
35 changes: 10 additions & 25 deletions .ci/build-mac.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#!/bin/sh -ex

brew install -f --overwrite nasm ninja git p7zip create-dmg ccache pipenv

#/usr/sbin/softwareupdate --install-rosetta --agree-to-license
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
arch -x86_64 /usr/local/bin/brew update
arch -x86_64 /usr/local/bin/brew install -f --overwrite llvm@16 sdl2 glew cmake molten-vk vulkan-headers faudio
arch -x86_64 /usr/local/bin/brew install -f --overwrite llvm@16 sdl2 glew cmake faudio moltenvk@1.2.4 vulkan-headers
arch -x86_64 /usr/local/bin/brew link -f llvm@16

#export MACOSX_DEPLOYMENT_TARGET=12.0
export CXX=clang++
export CC=clang
Expand All @@ -19,6 +22,7 @@ export CMAKE_EXTRA_OPTS='-DLLVM_TARGETS_TO_BUILD=X86'

export WORKDIR;
WORKDIR="$(pwd)"

# Get Qt
git clone https://github.com/engnr/qt-downloader.git
cd qt-downloader
Expand All @@ -28,41 +32,23 @@ git checkout f52efee0f18668c6d6de2dec0234b8c4bc54c597
cd ..

export Qt5_DIR="$WORKDIR/qt-downloader/5.15.2/clang_64/lib/cmake/Qt5"


export SDL2_DIR="$BREW_X64_PATH/opt/sdl2/lib/cmake/SDL2"

export PATH="$BREW_X64_PATH/opt/llvm@16/bin:$WORKDIR/qt-downloader/5.15.2/clang_64/bin:$BREW_BIN:$BREW_SBIN:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Library/Apple/usr/bin:$PATH"
export LDFLAGS="-L$BREW_X64_PATH/lib -Wl,-rpath,$BREW_X64_PATH/lib"
export CPPFLAGS="-I$BREW_X64_PATH/include -msse -msse2 -mcx16 -no-pie"
export LIBRARY_PATH="$BREW_X64_PATH/lib"
export LD_LIBRARY_PATH="$BREW_X64_PATH/lib"

export VULKAN_SDK
VULKAN_SDK="$BREW_X64_PATH/opt/molten-vk"
ln -s "$VULKAN_SDK/lib/libMoltenVK.dylib" "$VULKAN_SDK/lib/libvulkan.dylib"
export VK_ICD_FILENAMES="$VULKAN_SDK/share/vulkan/icd.d/MoltenVK_icd.json"

export LLVM_DIR
LLVM_DIR="BREW_X64_PATH/opt/llvm@16"
git submodule update --init ./3rdparty/asmjit && \
git submodule update --init ./3rdparty/cubeb && \
git submodule update --init ./3rdparty/curl && \
git submodule update --init ./3rdparty/ffmpeg && \
git submodule update --init ./3rdparty/flatbuffers && \
git submodule update --init ./3rdparty/glslang && \
git submodule update --init ./3rdparty/GPUOpen && \
git submodule update --init ./3rdparty/hidapi && \
git submodule update --init ./3rdparty/libpng && \
git submodule update --init ./3rdparty/libusb && \
git submodule update --init ./3rdparty/miniupnp && \
git submodule update --init ./3rdparty/pine && \
git submodule update --init ./3rdparty/pugixml && \
git submodule update --init ./3rdparty/rtmidi && \
git submodule update --init ./3rdparty/SoundTouch && \
git submodule update --init ./3rdparty/SPIRV && \
git submodule update --init ./3rdparty/stblib && \
git submodule update --init ./3rdparty/wolfssl && \
git submodule update --init ./3rdparty/xxHash && \
git submodule update --init ./3rdparty/yaml-cpp
# exclude FAudio, SPIRV, moltenvk and LLVM from submodule update
git submodule -q update --init --depth=1 --jobs=8 $(awk '/path/ && !/FAudio/ && !/MoltenVK && !/llvm/ && !/SPIRV/ { print $3 }' .gitmodules)

# 3rdparty fixes
sed -i '' "s/extern const double NSAppKitVersionNumber;/const double NSAppKitVersionNumber = 1343;/g" 3rdparty/hidapi/hidapi/mac/hid.c
Expand All @@ -85,10 +71,9 @@ mkdir build && cd build || exit 1
"$BREW_PATH/bin/ninja"; build_status=$?;

cd ..
export BUILDING_FOR="X64"
{ [ "$CI_HAS_ARTIFACTS" = "true" ];
} && SHOULD_DEPLOY="true" || SHOULD_DEPLOY="false"

if [ "$build_status" -eq 0 ] && [ "$SHOULD_DEPLOY" = "true" ]; then
.ci/deploy-mac.sh
fi
fi
26 changes: 24 additions & 2 deletions .ci/deploy-mac.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,33 @@ cd bin
mkdir "rpcs3.app/Contents/lib/"

# check if we are on ARM or x86_64
if [ $BUILDING_FOR = "arm64" ]; then
if [ "$BUILDING_FOR" = "arm64" ]; then
cp "/opt/homebrew/opt/llvm@16/lib/c++/libc++abi.1.0.dylib" "rpcs3.app/Contents/lib/libc++abi.1.dylib"
# copy avfilter and avdevice as they are missing
cp "/opt/homebrew/opt/ffmpeg/lib/libavfilter.7.dylib" "rpcs3.app/Contents/Frameworks/libavfilter.7.dylib"
cp "/opt/homebrew/opt/ffmpeg/lib/libavdevice.60.dylib" "rpcs3.app/Contents/Frameworks/libavdevice.60.dylib"

# we have ffmpeg libs bundled in the app bundle in rpcs3.app/Contents/Frameworks , now we need to change the rpath to point to it
# this is needed because we are using a homebrewed ffmpeg for arm64, and the rpath points to the system ffmpeg
# for example we want to point to rpcs3.app/Contents/Frameworks/libavcodec.60.dylib
install_name_tool -change "/opt/homebrew/opt/ffmpeg/lib/libavcodec.60.dylib" "@executable_path/../Frameworks/libavcodec.60.dylib" "rpcs3.app/Contents/MacOS/rpcs3"
install_name_tool -change "/opt/homebrew/opt/ffmpeg/lib/libavdevice.60.dylib" "@executable_path/../Frameworks/libavdevice.60.dylib" "rpcs3.app/Contents/MacOS/rpcs3"
install_name_tool -change "/opt/homebrew/opt/ffmpeg/lib/libavfilter.7.dylib" "@executable_path/../Frameworks/libavfilter.7.dylib" "rpcs3.app/Contents/MacOS/rpcs3"
install_name_tool -change "/opt/homebrew/opt/ffmpeg/lib/libavformat.60.dylib" "@executable_path/../Frameworks/libavformat.60.dylib" "rpcs3.app/Contents/MacOS/rpcs3"
install_name_tool -change "/opt/homebrew/opt/ffmpeg/lib/libavutil.58.dylib" "@executable_path/../Frameworks/libavutil.58.dylib" "rpcs3.app/Contents/MacOS/rpcs3"
install_name_tool -change "/opt/homebrew/opt/ffmpeg/lib/libswresample.4.dylib" "@executable_path/../Frameworks/libswresample.4.dylib" "rpcs3.app/Contents/MacOS/rpcs3"
install_name_tool -change "/opt/homebrew/opt/ffmpeg/lib/libswscale.7.dylib" "@executable_path/../Frameworks/libswscale.7.dylib" "rpcs3.app/Contents/MacOS/rpcs3"

# do the same for sdl2
install_name_tool -change "/opt/homebrew/opt/sdl2/lib/libSDL2-2.0.0.dylib" "@executable_path/../Frameworks/libSDL2-2.0.0.dylib" "rpcs3.app/Contents/MacOS/rpcs3"

# now faudio
install_name_tool -change "/opt/homebrew/opt/faudio/lib/libFAudio.0.dylib" "@executable_path/../Frameworks/libFAudio.0.dylib" "rpcs3.app/Contents/MacOS/rpcs3"


else
cp "/usr/local/opt/llvm@16/lib/c++/libc++abi.1.0.dylib" "rpcs3.app/Contents/lib/libc++abi.1.dylib"
fi

rm -rf "rpcs3.app/Contents/Frameworks/QtPdf.framework" \
"rpcs3.app/Contents/Frameworks/QtQml.framework" \
"rpcs3.app/Contents/Frameworks/QtQmlModels.framework" \
Expand All @@ -33,6 +52,9 @@ rm -rf "rpcs3.app/Contents/Frameworks/QtPdf.framework" \
"rpcs3.app/Contents/Plugins/virtualkeyboard" \
"rpcs3.app/Contents/Resources/git"


# codesign it
codesign --force --deep --sign - "rpcs3.app/Contents/MacOS/rpcs3"
# Need to do this rename hack due to case insensitive filesystem
mv rpcs3.app RPCS3_.app
mv RPCS3_.app RPCS3.app
Expand Down

0 comments on commit 7d6c442

Please sign in to comment.