forked from arkhamsaiyan/citra-canary
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: Improvements to bundled libraries support. (#6435)
- Loading branch information
Steveice10
authored
Apr 28, 2023
1 parent
30bf654
commit ea64926
Showing
21 changed files
with
255 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,13 @@ | ||
#!/bin/sh -ex | ||
|
||
brew install ccache ninja || true | ||
pip3 install macpack | ||
|
||
export FFMPEG_VER=5.1 | ||
export QT_VER=5.15.8 | ||
|
||
mkdir tmp | ||
cd tmp/ | ||
|
||
# install FFMPEG | ||
wget https://github.com/SachinVin/ext-macos-bin/raw/main/ffmpeg/ffmpeg-${FFMPEG_VER}.7z | ||
7z x ffmpeg-${FFMPEG_VER}.7z | ||
cp -rv $(pwd)/ffmpeg-${FFMPEG_VER}/* / | ||
|
||
# install Qt | ||
wget https://github.com/SachinVin/ext-macos-bin/raw/main/qt/qt-${QT_VER}.7z | ||
wget https://github.com/citra-emu/ext-macos-bin/raw/main/qt/qt-${QT_VER}.7z | ||
7z x qt-${QT_VER}.7z | ||
sudo cp -rv $(pwd)/qt-${QT_VER}/* /usr/local/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Bundles libraries with an output executable. | ||
# Parameters: | ||
# - TYPE: "qt" or "standalone". The type of app to bundle. | ||
# - "qt" uses windeployqt/macdeployqt to bundle Qt and other libraries. | ||
# - "standalone" copies dependent libraries to a "libs" folder alongside the executable file. | ||
# - EXECUTABLE_PATH: Path to the executable binary. | ||
|
||
# TODO: This does not really work fully for Windows yet, some libraries are missing from the output. | ||
# TODO: Leaving a basic framework of Windows support here to be iterated on in the future. | ||
if (WIN32) | ||
message(FATAL_ERROR "Advanced library bundling is not yet supported for Windows.") | ||
endif() | ||
|
||
if ("${TYPE}" STREQUAL "qt") | ||
get_filename_component(executable_dir ${EXECUTABLE_PATH} DIRECTORY) | ||
|
||
# Bundle dependencies using appropriate Qt tool. | ||
if (WIN32) | ||
find_program(WINDEPLOYQT_EXECUTABLE windeployqt) | ||
execute_process(COMMAND ${WINDEPLOYQT_EXECUTABLE} ${EXECUTABLE_PATH} | ||
--no-compiler-runtime --no-system-d3d-compiler --no-opengl-sw --no-translations | ||
--plugindir "${executable_dir}/plugins") | ||
elseif (APPLE) | ||
get_filename_component(contents_dir ${executable_dir} DIRECTORY) | ||
get_filename_component(bundle_dir ${contents_dir} DIRECTORY) | ||
|
||
find_program(MACDEPLOYQT_EXECUTABLE macdeployqt) | ||
execute_process(COMMAND ${MACDEPLOYQT_EXECUTABLE} ${bundle_dir} -executable=${EXECUTABLE_PATH} -always-overwrite) | ||
else() | ||
message(FATAL_ERROR "Unsupported OS for Qt-based library bundling.") | ||
endif() | ||
else() | ||
# Resolve dependent library files. | ||
file(GET_RUNTIME_DEPENDENCIES | ||
EXECUTABLES ${EXECUTABLE_PATH} | ||
RESOLVED_DEPENDENCIES_VAR resolved_deps | ||
UNRESOLVED_DEPENDENCIES_VAR unresolved_deps | ||
POST_EXCLUDE_REGEXES ".*system32/.*\\.dll") | ||
|
||
# Determine libraries directory. | ||
get_filename_component(executable_dir ${EXECUTABLE_PATH} DIRECTORY) | ||
if (WIN32) | ||
# Same directory since we don't have rpath. | ||
set(lib_dir ${executable_dir}) | ||
else() | ||
set(lib_dir ${executable_dir}/libs) | ||
endif() | ||
|
||
# Copy library files to bundled output. | ||
file(MAKE_DIRECTORY ${lib_dir}) | ||
foreach (lib_file ${resolved_deps}) | ||
# Use native copy to turn symlinks into normal files. | ||
execute_process(COMMAND cp -L ${lib_file} ${lib_dir}) | ||
endforeach() | ||
|
||
# Add libs directory to executable rpath where applicable. | ||
if (APPLE) | ||
execute_process(COMMAND install_name_tool -add_rpath "@loader_path/libs" ${EXECUTABLE_PATH}) | ||
elseif (UNIX) | ||
execute_process(COMMAND patchelf --set-rpath '$ORIGIN/../libs' ${EXECUTABLE_PATH}) | ||
endif() | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.