build: Rework CI and move all bundling into new build target. (#6556)

* build: Rework CI and move all bundling into new build target.

* ci: Use "mingw" in msys2 release names for compatibility.

* ci: Use "osx" in macOS release names for compatibility.

* ci: Disable macOS upload.

Will be moved to a separate PR for canary merge.
This commit is contained in:
Steveice10 2023-06-26 17:42:00 -07:00 committed by GitHub
parent 2e479fcec5
commit 2d6aca4563
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
57 changed files with 614 additions and 967 deletions

View file

@ -5,7 +5,10 @@ export NDK_CCACHE=$(which ccache)
BUILD_FLAVOR=canary || BUILD_FLAVOR=canary ||
BUILD_FLAVOR=nightly BUILD_FLAVOR=nightly
ccache -s if [ ! -z "${ANDROID_KEYSTORE_B64}" ]; then
export ANDROID_KEYSTORE_FILE="${GITHUB_WORKSPACE}/ks.jks"
base64 --decode <<< "${ANDROID_KEYSTORE_B64}" > "${ANDROID_KEYSTORE_FILE}"
fi
cd src/android cd src/android
chmod +x ./gradlew chmod +x ./gradlew
@ -13,3 +16,7 @@ chmod +x ./gradlew
./gradlew bundle${BUILD_FLAVOR}Release ./gradlew bundle${BUILD_FLAVOR}Release
ccache -s ccache -s
if [ ! -z "${ANDROID_KEYSTORE_B64}" ]; then
rm "${ANDROID_KEYSTORE_FILE}"
fi

View file

@ -1,23 +0,0 @@
#!/bin/bash -ex
. ./.ci/common/pre-upload.sh
REV_NAME="citra-android-${GITDATE}-${GITREV}"
[ "${GITHUB_REPOSITORY}" = "citra-emu/citra-canary" ] &&
BUILD_FLAVOR=canary ||
BUILD_FLAVOR=nightly
cp src/android/app/build/outputs/apk/${BUILD_FLAVOR}/release/app-${BUILD_FLAVOR}-release.apk \
"artifacts/${REV_NAME}.apk"
cp src/android/app/build/outputs/bundle/${BUILD_FLAVOR}Release/app-${BUILD_FLAVOR}-release.aab \
"artifacts/${REV_NAME}.aab"
if [ ! -z "${ANDROID_KEYSTORE_B64}" ]
then
echo "Signing apk..."
base64 --decode <<< "${ANDROID_KEYSTORE_B64}" > ks.jks
apksigner sign --ks ks.jks \
--ks-key-alias "${ANDROID_KEY_ALIAS}" \
--ks-pass env:ANDROID_KEYSTORE_PASS "artifacts/${REV_NAME}.apk"
fi

View file

@ -1,28 +0,0 @@
#!/bin/bash -ex
# Copy documentation
cp license.txt "$REV_NAME"
cp README.md "$REV_NAME"
# Copy cross-platform scripting support
cp -r dist/scripting "$REV_NAME"
tar $COMPRESSION_FLAGS "$ARCHIVE_NAME" "$REV_NAME"
# Find out what release we are building
if [[ "$GITHUB_REF_NAME" =~ ^canary- ]] || [[ "$GITHUB_REF_NAME" =~ ^nightly- ]]; then
RELEASE_NAME=$(echo $GITHUB_REF_NAME | cut -d- -f1)
if [ "$NAME" = "linux-mingw" ]; then
RELEASE_NAME="${RELEASE_NAME}-mingw"
fi
else
RELEASE_NAME=head
fi
mv "$REV_NAME" $RELEASE_NAME
7z a "$REV_NAME.7z" $RELEASE_NAME
# move the compiled archive into the artifacts directory to be uploaded by travis releases
mv "$ARCHIVE_NAME" artifacts/
mv "$REV_NAME.7z" artifacts/

View file

@ -1,6 +0,0 @@
#!/bin/bash -ex
GITDATE="`git show -s --date=short --format='%ad' | sed 's/-//g'`"
GITREV="`git show -s --format='%h'`"
mkdir -p artifacts

View file

@ -1,3 +0,0 @@
#!/bin/bash -ex
mkdir -p "$HOME/.ccache"
docker run -v $(pwd):/citra -v "$HOME/.ccache":/root/.ccache citraemu/build-environments:linux-appimage /bin/bash -ex /citra/.ci/linux/docker.sh

View file

@ -1,24 +0,0 @@
#!/bin/bash
#Building Citra
mkdir build
cd build
cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=/usr/lib/ccache/gcc -DCMAKE_CXX_COMPILER=/usr/lib/ccache/g++ -DENABLE_QT_TRANSLATION=ON -DCITRA_ENABLE_COMPATIBILITY_REPORTING=${ENABLE_COMPATIBILITY_REPORTING:-"OFF"} -DENABLE_COMPATIBILITY_LIST_DOWNLOAD=ON -DUSE_DISCORD_PRESENCE=ON
ninja
ctest -VV -C Release
#Circumvent missing LibFuse in Docker, by extracting the AppImage
export APPIMAGE_EXTRACT_AND_RUN=1
#Building AppDir
DESTDIR="./AppDir" ninja install
mv ./AppDir/usr/local/bin ./AppDir/usr
mv ./AppDir/usr/local/share ./AppDir/usr
rm -rf ./AppDir/usr/local
QMAKE=/usr/lib/qt6/bin/qmake /linuxdeploy-x86_64.AppImage --appdir AppDir --plugin qt --plugin checkrt
sed -i 's/*XFCE*/*X-Cinnamon*|*XFCE*/g' ./AppDir/apprun-hooks/linuxdeploy-plugin-qt-hook.sh
sed -i '/export QT_QPA_PLATFORMTHEME=gtk3/a \ \ \ \ \ \ \ \ export GDK_BACKEND=x11' ./AppDir/apprun-hooks/linuxdeploy-plugin-qt-hook.sh
#Build AppImage
QMAKE=/usr/lib/qt6/bin/qmake /linuxdeploy-x86_64.AppImage --appdir AppDir --output appimage

View file

@ -1,5 +0,0 @@
#!/bin/bash -ex
. .ci/common/pre-upload.sh
REV_NAME="citra-linux-${GITDATE}-${GITREV}"
mv build/Citra*.AppImage "${GITHUB_WORKSPACE}"/artifacts/${REV_NAME}.AppImage

View file

@ -1,3 +0,0 @@
#!/bin/bash -ex
mkdir -p "$HOME/.ccache"
docker run -v $(pwd):/citra -v "$HOME/.ccache":/root/.ccache citraemu/build-environments:linux-clang-format /bin/bash -ex /citra/.ci/clang-format/docker.sh

View file

@ -1,4 +0,0 @@
#!/bin/bash -ex
# Run clang-format
./.ci/linux-clang-format/script.sh

View file

@ -1,3 +0,0 @@
#!/bin/bash -ex
mkdir -p "$HOME/.ccache"
docker run -v $(pwd):/citra -v "$HOME/.ccache":/root/.ccache citraemu/build-environments:linux-fresh /bin/bash -ex /citra/.ci/linux/docker.sh

View file

@ -1,7 +0,0 @@
#!/bin/bash -ex
mkdir build && cd build
cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=/usr/lib/ccache/gcc -DCMAKE_CXX_COMPILER=/usr/lib/ccache/g++ -DENABLE_QT_TRANSLATION=ON -DCITRA_ENABLE_COMPATIBILITY_REPORTING=${ENABLE_COMPATIBILITY_REPORTING:-"OFF"} -DENABLE_COMPATIBILITY_LIST_DOWNLOAD=ON -DUSE_DISCORD_PRESENCE=ON
ninja
ctest -VV -C Release

View file

@ -1,19 +0,0 @@
#!/bin/bash -ex
. .ci/common/pre-upload.sh
REV_NAME="citra-linux-${GITDATE}-${GITREV}"
ARCHIVE_NAME="${REV_NAME}.tar.xz"
COMPRESSION_FLAGS="-cJvf"
mkdir "$REV_NAME"
cp build/bin/Release/citra "$REV_NAME"
cp build/bin/Release/citra-room "$REV_NAME"
cp build/bin/Release/citra-qt "$REV_NAME"
# We need icons on Linux for .desktop entries
mkdir "$REV_NAME/dist"
cp dist/icon.png "$REV_NAME/dist/citra.png"
. .ci/common/post-upload.sh

View file

@ -1,3 +0,0 @@
#!/bin/bash -ex
mkdir -p "$HOME/.ccache"
docker run -v $(pwd):/citra -v "$HOME/.ccache":/root/.ccache citraemu/build-environments:linux-frozen /bin/bash -ex /citra/.ci/linux-frozen/docker.sh

View file

@ -1,15 +0,0 @@
#!/bin/bash -ex
mkdir -p ~/bin/gold
echo '#!/bin/bash' > ~/bin/gold/ld
echo 'gold "$@"' >> ~/bin/gold/ld
chmod a+x ~/bin/gold/ld
export CFLAGS="-B$HOME/bin/gold $CFLAGS"
export CXXFLAGS="-B$HOME/bin/gold $CXXFLAGS"
mkdir build && cd build
cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=/usr/lib/ccache/gcc -DCMAKE_CXX_COMPILER=/usr/lib/ccache/g++
ninja
ctest -VV -C Release

View file

@ -1,52 +0,0 @@
#!/usr/bin/python
import sys
import re
import subprocess
from launchpadlib.launchpad import Launchpad
if sys.version_info[0] > 2:
xrange = range
cachedir = '/.launchpadlib/cache/'
launchpad = Launchpad.login_anonymously(
'grab build info', 'production', cachedir, version='devel')
processed_packages = []
deb_file_list = []
def get_url(pkg, distro):
build_ref = launchpad.archives.getByReference(reference='ubuntu').getPublishedBinaries(
binary_name=pkg[0], distro_arch_series='https://api.launchpad.net/devel/ubuntu/' + distro + '/amd64', version=pkg[1], exact_match=True, order_by_date=True).entries[0]
build_link = build_ref['build_link']
deb_name = '{}_{}_{}.deb'.format(pkg[0], pkg[1], 'amd64' if build_ref['architecture_specific'] else 'all')
deb_link = build_link + '/+files/' + deb_name
return [deb_link, deb_name]
def list_dependencies(deb_file):
t = subprocess.check_output(
['bash', '-c', '(dpkg -I {} | grep -oP "^ Depends\: \K.*$") || true'.format(deb_file)])
deps = [i.strip() for i in t.split(',')]
equals_re = re.compile(r'^(.*) \(= (.*)\)$')
return [equals_re.sub(r'\1=\2', i).split('=') for i in filter(equals_re.match, deps)]
def get_package(pkg, distro):
if pkg in processed_packages:
return
print('Getting {}...'.format(pkg[0]))
url = get_url(pkg, distro)
subprocess.check_call(['wget', '--quiet', url[0], '-O', url[1]])
for dep in list_dependencies(url[1]):
get_package(dep, distro)
processed_packages.append(pkg)
deb_file_list.append('./' + url[1])
for i in xrange(1, len(sys.argv), 3):
get_package([sys.argv[i], sys.argv[i + 1]], sys.argv[i + 2])
subprocess.check_call(
['apt-get', 'install', '-y', '--force-yes'] + deb_file_list)

View file

@ -1,3 +0,0 @@
#!/bin/bash -ex
mkdir "$HOME/.ccache" || true
docker run -v $(pwd):/citra -v "$HOME/.ccache":/root/.ccache citraemu/build-environments:linux-mingw /bin/bash -ex /citra/.ci/linux-mingw/docker.sh

View file

@ -1,30 +0,0 @@
#!/bin/bash -ex
# override CI ccache size
mkdir -p "$HOME/.ccache/"
echo 'max_size = 3.0G' > "$HOME/.ccache/ccache.conf"
mkdir build && cd build
cmake .. -G Ninja -DCMAKE_TOOLCHAIN_FILE="$(pwd)/../CMakeModules/MinGWCross.cmake" -DCITRA_USE_CCACHE=ON -DCMAKE_BUILD_TYPE=Release -DENABLE_QT_TRANSLATION=ON -DCITRA_ENABLE_COMPATIBILITY_REPORTING=${ENABLE_COMPATIBILITY_REPORTING:-"OFF"} -DENABLE_COMPATIBILITY_LIST_DOWNLOAD=ON -DUSE_DISCORD_PRESENCE=ON -DENABLE_MF=ON -DCMAKE_NO_SYSTEM_FROM_IMPORTED=TRUE -DCOMPILE_WITH_DWARF=OFF
ninja
echo "Tests skipped"
#ctest -VV -C Release
ccache -s
echo 'Prepare binaries...'
cd ..
mkdir package
QT_PLATFORM_DLL_PATH='/usr/x86_64-w64-mingw32/lib/qt6/plugins/platforms/'
find build/ -name "citra*.exe" -exec cp {} 'package' \;
# copy Qt plugins
mkdir package/platforms
cp "${QT_PLATFORM_DLL_PATH}/qwindows.dll" package/platforms/
cp -rv "${QT_PLATFORM_DLL_PATH}/../multimedia/" package/
cp -rv "${QT_PLATFORM_DLL_PATH}/../imageformats/" package/
cp -rv "${QT_PLATFORM_DLL_PATH}/../styles/" package/
python3 .ci/linux-mingw/scan_dll.py package/*.exe package/imageformats/*.dll "package/"

View file

@ -1,122 +0,0 @@
try:
import lief
except ImportError:
import pefile
import sys
import re
import os
import queue
import shutil
# constant definitions
KNOWN_SYS_DLLS = ['WINMM.DLL', 'MSVCRT.DLL', 'VERSION.DLL', 'MPR.DLL',
'DWMAPI.DLL', 'UXTHEME.DLL', 'DNSAPI.DLL', 'IPHLPAPI.DLL']
# below is for Ubuntu 18.04 with specified PPA enabled, if you are using
# other distro or different repositories, change the following accordingly
DLL_PATH = [
'/usr/x86_64-w64-mingw32/bin/',
'/usr/x86_64-w64-mingw32/lib/',
'/usr/lib/gcc/x86_64-w64-mingw32/9.3-posix/'
]
missing = []
def parse_imports_lief(filename):
results = []
pe = lief.parse(filename)
for entry in pe.imports:
name = entry.name
if name.upper() not in KNOWN_SYS_DLLS and not re.match(string=name, pattern=r'.*32\.DLL'):
results.append(name)
return results
def parse_imports(file_name):
if globals().get('lief'):
return parse_imports_lief(file_name)
results = []
pe = pefile.PE(file_name, fast_load=True)
pe.parse_data_directories()
for entry in pe.DIRECTORY_ENTRY_IMPORT:
current = entry.dll.decode()
current_u = current.upper() # b/c Windows is often case insensitive
# here we filter out system dlls
# dll w/ names like *32.dll are likely to be system dlls
if current_u.upper() not in KNOWN_SYS_DLLS and not re.match(string=current_u, pattern=r'.*32\.DLL'):
results.append(current)
return results
def parse_imports_recursive(file_name, path_list=[]):
q = queue.Queue() # create a FIFO queue
# file_name can be a string or a list for the convience
if isinstance(file_name, str):
q.put(file_name)
elif isinstance(file_name, list):
for i in file_name:
q.put(i)
full_list = []
while q.qsize():
current = q.get_nowait()
print('> %s' % current)
deps = parse_imports(current)
# if this dll does not have any import, ignore it
if not deps:
continue
for dep in deps:
# the dependency already included in the list, skip
if dep in full_list:
continue
# find the requested dll in the provided paths
full_path = find_dll(dep)
if not full_path:
missing.append(dep)
continue
full_list.append(dep)
q.put(full_path)
path_list.append(full_path)
return full_list
def find_dll(name):
for path in DLL_PATH:
for root, _, files in os.walk(path):
for f in files:
if name.lower() == f.lower():
return os.path.join(root, f)
def deploy(name, dst, dry_run=False):
dlls_path = []
parse_imports_recursive(name, dlls_path)
for dll_entry in dlls_path:
if not dry_run:
shutil.copy(dll_entry, dst)
else:
print('[Dry-Run] Copy %s to %s' % (dll_entry, dst))
print('Deploy completed.')
return dlls_path
def main():
if len(sys.argv) < 3:
print('Usage: %s [files to examine ...] [target deploy directory]')
return 1
to_deploy = sys.argv[1:-1]
tgt_dir = sys.argv[-1]
if not os.path.isdir(tgt_dir):
print('%s is not a directory.' % tgt_dir)
return 1
print('Scanning dependencies...')
deploy(to_deploy, tgt_dir)
if missing:
print('Following DLLs are not found: %s' % ('\n'.join(missing)))
return 0
if __name__ == '__main__':
main()

View file

@ -1,13 +0,0 @@
#!/bin/bash -ex
. .ci/common/pre-upload.sh
REV_NAME="citra-windows-mingw-${GITDATE}-${GITREV}"
ARCHIVE_NAME="${REV_NAME}.tar.gz"
COMPRESSION_FLAGS="-czvf"
mkdir "$REV_NAME"
# get around the permission issues
cp -r package/* "$REV_NAME"
. .ci/common/post-upload.sh

20
.ci/linux.sh Executable file
View file

@ -0,0 +1,20 @@
#!/bin/sh -ex
mkdir build && cd build
cmake .. -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DENABLE_QT_TRANSLATION=ON \
-DCITRA_ENABLE_COMPATIBILITY_REPORTING=ON \
-DENABLE_COMPATIBILITY_LIST_DOWNLOAD=ON \
-DUSE_DISCORD_PRESENCE=ON
ninja
if [ "$TARGET" = "appimage" ]; then
ninja bundle
fi
ccache -s
ctest -VV -C Release

View file

@ -1,43 +1,37 @@
#!/bin/bash -ex #!/bin/bash -ex
. .ci/common/pre-upload.sh
REV_NAME="citra-osx-${GITDATE}-${GITREV}"
ARCHIVE_NAME="${REV_NAME}.tar.gz"
COMPRESSION_FLAGS="-czvf"
ARTIFACTS_LIST=($ARTIFACTS) ARTIFACTS_LIST=($ARTIFACTS)
BUNDLE_DIR=build/bundle
mkdir build
# Set up the base artifact to combine into. # Set up the base artifact to combine into.
BASE_ARTIFACT=${ARTIFACTS_LIST[0]} BASE_ARTIFACT=${ARTIFACTS_LIST[0]}
BASE_ARTIFACT_ARCH="${BASE_ARTIFACT##*-}" BASE_ARTIFACT_ARCH="${BASE_ARTIFACT##*-}"
tar xf $BASE_ARTIFACT/$REV_NAME.tar.gz -C $BASE_ARTIFACT mv $BASE_ARTIFACT $BUNDLE_DIR
mv $BASE_ARTIFACT/$REV_NAME $REV_NAME
# Executable binary paths that need to be combined. # Executable binary paths that need to be combined.
BIN_PATHS=(citra citra-room citra-qt.app/Contents/MacOS/citra-qt) BIN_PATHS=(citra citra-room citra-qt.app/Contents/MacOS/citra-qt)
# Dylib paths that need to be combined. # Dylib paths that need to be combined.
IFS=$'\n' IFS=$'\n'
DYLIB_PATHS=($(cd $REV_NAME && find . -name '*.dylib')) DYLIB_PATHS=($(cd $BUNDLE_DIR && find . -name '*.dylib'))
unset IFS unset IFS
# Combine all of the executable binaries and dylibs. # Combine all of the executable binaries and dylibs.
for OTHER_ARTIFACT in "${ARTIFACTS_LIST[@]:1}"; do for OTHER_ARTIFACT in "${ARTIFACTS_LIST[@]:1}"; do
OTHER_ARTIFACT_ARCH="${OTHER_ARTIFACT##*-}" OTHER_ARTIFACT_ARCH="${OTHER_ARTIFACT##*-}"
tar xf $OTHER_ARTIFACT/$REV_NAME.tar.gz -C $OTHER_ARTIFACT
for BIN_PATH in "${BIN_PATHS[@]}"; do for BIN_PATH in "${BIN_PATHS[@]}"; do
lipo -create -output $REV_NAME/$BIN_PATH $REV_NAME/$BIN_PATH $OTHER_ARTIFACT/$REV_NAME/$BIN_PATH lipo -create -output $BUNDLE_DIR/$BIN_PATH $BUNDLE_DIR/$BIN_PATH $OTHER_ARTIFACT/$BIN_PATH
done done
for DYLIB_PATH in "${DYLIB_PATHS[@]}"; do for DYLIB_PATH in "${DYLIB_PATHS[@]}"; do
# Only merge if the libraries do not have conflicting arches, otherwise it will fail. # Only merge if the libraries do not have conflicting arches, otherwise it will fail.
DYLIB_INFO=`file $REV_NAME/$DYLIB_PATH` DYLIB_INFO=`file $BUNDLE_DIR/$DYLIB_PATH`
OTHER_DYLIB_INFO=`file $OTHER_ARTIFACT/$REV_NAME/$DYLIB_PATH` OTHER_DYLIB_INFO=`file $OTHER_ARTIFACT/$DYLIB_PATH`
if ! [[ "$DYLIB_INFO" =~ "$OTHER_ARTIFACT_ARCH" ]] && ! [[ "$OTHER_DYLIB_INFO" =~ "$BASE_ARTIFACT_ARCH" ]]; then if ! [[ "$DYLIB_INFO" =~ "$OTHER_ARTIFACT_ARCH" ]] && ! [[ "$OTHER_DYLIB_INFO" =~ "$BASE_ARTIFACT_ARCH" ]]; then
lipo -create -output $REV_NAME/$DYLIB_PATH $REV_NAME/$DYLIB_PATH $OTHER_ARTIFACT/$REV_NAME/$DYLIB_PATH lipo -create -output $BUNDLE_DIR/$DYLIB_PATH $BUNDLE_DIR/$DYLIB_PATH $OTHER_ARTIFACT/$DYLIB_PATH
fi fi
done done
done done
@ -45,7 +39,5 @@ done
# Re-sign executables and bundles after combining. # Re-sign executables and bundles after combining.
APP_PATHS=(citra citra-room citra-qt.app) APP_PATHS=(citra citra-room citra-qt.app)
for APP_PATH in "${APP_PATHS[@]}"; do for APP_PATH in "${APP_PATHS[@]}"; do
codesign --deep -fs - $REV_NAME/$APP_PATH codesign --deep -fs - $BUNDLE_DIR/$APP_PATH
done done
. .ci/common/post-upload.sh

24
.ci/macos.sh Executable file
View file

@ -0,0 +1,24 @@
#!/bin/bash -ex
mkdir build && cd build
# TODO: LibreSSL ASM disabled due to platform detection issues in cross-compile build.
cmake .. -GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_OSX_ARCHITECTURES="$TARGET" \
-DCMAKE_OSX_DEPLOYMENT_TARGET="11.0" \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DENABLE_QT_TRANSLATION=ON \
-DCITRA_ENABLE_COMPATIBILITY_REPORTING=ON \
-DENABLE_COMPATIBILITY_LIST_DOWNLOAD=ON \
-DUSE_DISCORD_PRESENCE=ON \
-DENABLE_ASM=OFF
ninja
ninja bundle
ccache -s
CURRENT_ARCH=`arch`
if [ "$TARGET" = "$CURRENT_ARCH" ]; then
ctest -VV -C Release
fi

View file

@ -1,34 +0,0 @@
#!/bin/bash -ex
set -o pipefail
export PATH="/usr/local/opt/ccache/libexec:$PATH"
# ccache configurations
export CCACHE_CPP2=yes
export CCACHE_SLOPPINESS=time_macros
export CC="ccache clang"
export CXX="ccache clang++"
export OBJC="clang"
export ASM="clang"
ccache -s
mkdir build && cd build
# TODO: LibreSSL ASM disabled due to platform detection issues in build.
cmake .. -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_OSX_ARCHITECTURES="$TARGET_ARCH" \
-DENABLE_QT_TRANSLATION=ON \
-DCITRA_ENABLE_COMPATIBILITY_REPORTING=${ENABLE_COMPATIBILITY_REPORTING:-"OFF"} \
-DENABLE_COMPATIBILITY_LIST_DOWNLOAD=ON \
-DUSE_DISCORD_PRESENCE=ON \
-DENABLE_ASM=OFF \
-GNinja
ninja
ccache -s
CURRENT_ARCH=`arch`
if [ "$TARGET_ARCH" = "$CURRENT_ARCH" ]; then
ctest -VV -C Release
fi

View file

@ -1,3 +0,0 @@
#!/bin/sh -ex
brew install ccache glslang ninja || true

View file

@ -1,16 +0,0 @@
#!/bin/bash -ex
. .ci/common/pre-upload.sh
REV_NAME="citra-osx-${GITDATE}-${GITREV}"
ARCHIVE_NAME="${REV_NAME}.tar.gz"
COMPRESSION_FLAGS="-czvf"
mkdir "$REV_NAME"
cp -a build/bin/Release/citra "$REV_NAME"
cp -a build/bin/Release/libs "$REV_NAME"
cp -a build/bin/Release/citra-qt.app "$REV_NAME"
cp -a build/bin/Release/citra-room "$REV_NAME"
. .ci/common/post-upload.sh

48
.ci/pack.sh Executable file
View file

@ -0,0 +1,48 @@
#!/bin/bash -ex
GITDATE="`git show -s --date=short --format='%ad' | sed 's/-//g'`"
GITREV="`git show -s --format='%h'`"
REV_NAME="citra-${OS}-${TARGET}-${GITDATE}-${GITREV}"
# Find out what release we are building
if [[ "$GITHUB_REF_NAME" =~ ^canary- ]] || [[ "$GITHUB_REF_NAME" =~ ^nightly- ]]; then
RELEASE_NAME=$(echo $GITHUB_REF_NAME | cut -d- -f1)
# For compatibility with existing installs, use mingw/osx in the archive and target names.
if [ "$TARGET" = "msys2" ]; then
REV_NAME="citra-${OS}-mingw-${GITDATE}-${GITREV}"
RELEASE_NAME="${RELEASE_NAME}-mingw"
elif [ "$OS" = "macos" ]; then
REV_NAME="citra-osx-${TARGET}-${GITDATE}-${GITREV}"
fi
else
RELEASE_NAME=head
fi
mkdir -p artifacts
if [ -z "${UPLOAD_RAW}" ]; then
# Archive and upload the artifacts.
mkdir "$REV_NAME"
mv build/bundle/* "$REV_NAME"
if [ "$OS" = "windows" ]; then
ARCHIVE_NAME="${REV_NAME}.zip"
powershell Compress-Archive "$REV_NAME" "$ARCHIVE_NAME"
else
ARCHIVE_NAME="${REV_NAME}.tar.gz"
tar czvf "$ARCHIVE_NAME" "$REV_NAME"
fi
mv "$REV_NAME" $RELEASE_NAME
7z a "$REV_NAME.7z" $RELEASE_NAME
mv "$ARCHIVE_NAME" artifacts/
mv "$REV_NAME.7z" artifacts/
else
# Directly upload the raw artifacts, renamed with the revision.
for ARTIFACT in build/bundle/*; do
FILENAME=$(basename "$ARTIFACT")
EXTENSION="${FILENAME##*.}"
mv "$ARTIFACT" "artifacts/$REV_NAME.$EXTENSION"
done
fi

View file

@ -1,9 +1,13 @@
#!/bin/bash -ex #!/bin/bash -ex
. .ci/common/pre-upload.sh GITDATE="`git show -s --date=short --format='%ad' | sed 's/-//g'`"
GITREV="`git show -s --format='%h'`"
REV_NAME="citra-unified-source-${GITDATE}-${GITREV}" REV_NAME="citra-unified-source-${GITDATE}-${GITREV}"
COMPAT_LIST='dist/compatibility_list/compatibility_list.json' COMPAT_LIST='dist/compatibility_list/compatibility_list.json'
mkdir artifacts
pip3 install git-archive-all pip3 install git-archive-all
wget -q https://api.citra-emu.org/gamedb -O "${COMPAT_LIST}" wget -q https://api.citra-emu.org/gamedb -O "${COMPAT_LIST}"
git describe --abbrev=0 --always HEAD > GIT-COMMIT git describe --abbrev=0 --always HEAD > GIT-COMMIT

View file

@ -1,6 +1,4 @@
#!/bin/bash -e #!/bin/bash -ex
set -x
echo -e "\e[1m\e[33mBuild tools information:\e[0m" echo -e "\e[1m\e[33mBuild tools information:\e[0m"
cmake --version cmake --version

View file

@ -1,3 +0,0 @@
#!/bin/bash -e
docker run -e TRANSIFEX_API_TOKEN="${TRANSIFEX_API_TOKEN}" -v "$(pwd)":/citra citraemu/build-environments:linux-transifex /bin/sh -e /citra/.travis/transifex/docker.sh

View file

@ -1,20 +0,0 @@
#!/bin/sh -ex
mkdir build && cd build
cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-G Ninja \
-DCMAKE_TOOLCHAIN_FILE="$(pwd)/../CMakeModules/MSVCCache.cmake" \
-DCITRA_USE_CCACHE=ON \
-DENABLE_QT_TRANSLATION=ON \
-DCITRA_ENABLE_COMPATIBILITY_REPORTING=${ENABLE_COMPATIBILITY_REPORTING:-"OFF"} \
-DENABLE_COMPATIBILITY_LIST_DOWNLOAD=ON \
-DUSE_DISCORD_PRESENCE=ON \
-DENABLE_MF=ON \
-DOPENSSL_DLL_DIR="C:\Program Files\OpenSSL\bin"
ninja
# show the caching efficiency
buildcache -s
ctest -VV -C Release || echo "::error ::Test error occurred on Windows MSVC build"

View file

@ -1,10 +0,0 @@
#!/bin/sh -ex
BUILDCACHE_VERSION="0.22.3"
choco install wget ninja
# Install buildcache
wget "https://github.com/mbitsnbites/buildcache/releases/download/v${BUILDCACHE_VERSION}/buildcache-win-mingw.zip"
7z x 'buildcache-win-mingw.zip'
mv ./buildcache/bin/buildcache.exe "/c/ProgramData/chocolatey/bin"
rm -rf ./buildcache/

View file

@ -1,41 +0,0 @@
$GITDATE = $(git show -s --date=short --format='%ad') -replace "-", ""
$GITREV = $(git show -s --format='%h')
# Find out what release we are building
if ( $env:GITHUB_REF_NAME -like "*canary-*" -or $env:GITHUB_REF_NAME -like "*nightly-*" ) {
$RELEASE_NAME = ${env:GITHUB_REF_NAME}.split("-")[0]
$RELEASE_NAME = "${RELEASE_NAME}-msvc"
}
else {
$RELEASE_NAME = "head"
}
$MSVC_BUILD_ZIP = "citra-windows-msvc-$GITDATE-$GITREV.zip" -replace " ", ""
$MSVC_SEVENZIP = "citra-windows-msvc-$GITDATE-$GITREV.7z" -replace " ", ""
$BUILD_DIR = ".\build\bin\Release"
# Create artifact directories
mkdir $RELEASE_NAME
mkdir "artifacts"
echo "Starting to pack ${RELEASE_NAME}"
Copy-Item $BUILD_DIR\* -Destination $RELEASE_NAME -Recurse
Remove-Item $RELEASE_NAME\tests.* -ErrorAction ignore
Remove-Item $RELEASE_NAME\*.pdb -ErrorAction ignore
# Copy documentation
Copy-Item license.txt -Destination $RELEASE_NAME
Copy-Item README.md -Destination $RELEASE_NAME
# Copy cross-platform scripting support
Copy-Item dist\scripting -Destination $RELEASE_NAME -Recurse
# Build the final release artifacts
7z a -tzip $MSVC_BUILD_ZIP $RELEASE_NAME\*
7z a $MSVC_SEVENZIP $RELEASE_NAME
Copy-Item $MSVC_BUILD_ZIP -Destination "artifacts"
Copy-Item $MSVC_SEVENZIP -Destination "artifacts"

17
.ci/windows.sh Normal file
View file

@ -0,0 +1,17 @@
#!/bin/sh -ex
mkdir build && cd build
cmake .. -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DENABLE_QT_TRANSLATION=ON \
-DCITRA_ENABLE_COMPATIBILITY_REPORTING=ON \
-DENABLE_COMPATIBILITY_LIST_DOWNLOAD=ON \
-DUSE_DISCORD_PRESENCE=ON
ninja
ninja bundle
ccache -s
ctest -VV -C Release || echo "::error ::Test error occurred on Windows build"

View file

@ -20,41 +20,7 @@ jobs:
- name: Build - name: Build
env: env:
COMMIT_RANGE: ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }} COMMIT_RANGE: ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}
run: ./.ci/linux-clang-format/docker.sh run: ./.ci/clang-format.sh
build:
runs-on: ubuntu-latest
strategy:
matrix:
image: ["linux-appimage", "linux-fresh", "linux-frozen", "linux-mingw"]
container:
image: citraemu/build-environments:${{ matrix.image }}
options: -u 1001
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Set up cache
uses: actions/cache@v3
with:
path: ~/.ccache
key: ${{ runner.os }}-${{ matrix.image }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-${{ matrix.image }}-
- name: Build
run: ./.ci/${{ matrix.image }}/docker.sh
env:
ENABLE_COMPATIBILITY_REPORTING: "ON"
- name: Pack
run: ./.ci/${{ matrix.image }}/upload.sh
if: ${{ matrix.image == 'linux-appimage' || matrix.image == 'linux-mingw' }}
env:
NAME: ${{ matrix.image }}
- name: Upload
uses: actions/upload-artifact@v3
if: ${{ matrix.image == 'linux-appimage' || matrix.image == 'linux-mingw' }}
with:
name: ${{ matrix.image }}
path: artifacts/
source: source:
if: ${{ !github.head_ref }} if: ${{ !github.head_ref }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -63,17 +29,57 @@ jobs:
with: with:
submodules: recursive submodules: recursive
- name: Pack - name: Pack
run: ./.ci/source/build.sh run: ./.ci/source.sh
- name: Upload - name: Upload
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
with: with:
name: source name: source
path: artifacts/ path: artifacts/
linux:
runs-on: ubuntu-latest
strategy:
matrix:
target: ["appimage", "fresh"]
container:
image: citraemu/build-environments:linux-${{ matrix.target }}
options: -u 1001
env:
CCACHE_DIR: ${{ github.workspace }}/.ccache
OS: linux
TARGET: ${{ matrix.target }}
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Set up cache
uses: actions/cache@v3
with:
path: ${{ env.CCACHE_DIR }}
key: ${{ runner.os }}-${{ matrix.target }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-${{ matrix.target }}-
- name: Build
run: ./.ci/linux.sh
- name: Pack
run: ./.ci/pack.sh
if: ${{ matrix.target == 'appimage' }}
- name: Upload
uses: actions/upload-artifact@v3
if: ${{ matrix.target == 'appimage' }}
with:
name: ${{ env.OS }}-${{ env.TARGET }}
path: artifacts/
macos: macos:
runs-on: macos-latest runs-on: macos-latest
strategy: strategy:
matrix: matrix:
arch: ["x86_64", "arm64"] target: ["x86_64", "arm64"]
env:
CCACHE_CPP2: yes
CCACHE_SLOPPINESS: time_macros
CCACHE_DIR: ${{ github.workspace }}/.ccache
OS: macos
TARGET: ${{ matrix.target }}
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
with: with:
@ -81,59 +87,66 @@ jobs:
- name: Set up cache - name: Set up cache
uses: actions/cache@v3 uses: actions/cache@v3
with: with:
path: ~/Library/Caches/ccache path: ${{ env.CCACHE_DIR }}
key: ${{ runner.os }}-macos-${{ matrix.arch }}-${{ github.sha }} key: ${{ runner.os }}-${{ matrix.target }}-${{ github.sha }}
restore-keys: | restore-keys: |
${{ runner.os }}-macos-${{ matrix.arch }}- ${{ runner.os }}-${{ matrix.target }}-
- name: Install dependencies - name: Install tools
run: ./.ci/macos/deps.sh run: brew install ccache glslang ninja
- name: Build - name: Build
run: ./.ci/macos/build.sh run: ./.ci/macos.sh
env: - name: Prepare outputs for caching
MACOSX_DEPLOYMENT_TARGET: "11" run: mv build/bundle $OS-$TARGET
ENABLE_COMPATIBILITY_REPORTING: "ON" - name: Cache outputs for universal build
TARGET_ARCH: ${{ matrix.arch }} uses: actions/cache/save@v3
- name: Pack
run: ./.ci/macos/upload.sh
- name: Upload
uses: actions/upload-artifact@v3
with: with:
name: macos-${{ matrix.arch }} path: ${{ env.OS }}-${{ env.TARGET }}
path: artifacts/ key: ${{ runner.os }}-${{ matrix.target }}-${{ github.sha }}-${{ github.run_id }}-${{ github.run_attempt }}
macos-universal: macos-universal:
runs-on: macos-latest runs-on: macos-latest
needs: macos needs: macos
env:
OS: macos
TARGET: universal
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
with: with:
submodules: recursive submodules: recursive
- name: Download x86 build - name: Download x86_64 build from cache
uses: actions/download-artifact@master uses: actions/cache/restore@v3
with: with:
name: macos-x86_64 path: ${{ env.OS }}-x86_64
path: macos-x86_64/ key: ${{ runner.os }}-x86_64-${{ github.sha }}-${{ github.run_id }}-${{ github.run_attempt }}
- name: Download ARM64 build fail-on-cache-miss: true
uses: actions/download-artifact@master - name: Download ARM64 build from cache
uses: actions/cache/restore@v3
with: with:
name: macos-arm64 path: ${{ env.OS }}-arm64
path: macos-arm64/ key: ${{ runner.os }}-arm64-${{ github.sha }}-${{ github.run_id }}-${{ github.run_attempt }}
fail-on-cache-miss: true
- name: Create universal app - name: Create universal app
run: ./.ci/macos/universal.sh run: ./.ci/macos-universal.sh
env: env:
ARTIFACTS: macos-x86_64 macos-arm64 ARTIFACTS: ${{ env.OS }}-x86_64 ${{ env.OS }}-arm64
- name: Pack
run: ./.ci/pack.sh
# - name: Upload # - name: Upload
# uses: actions/upload-artifact@v3 # uses: actions/upload-artifact@v3
# with: # with:
# name: macos # name: ${{ env.OS }}-${{ env.TARGET }}
# path: artifacts/ # path: artifacts/
- name: Delete intermediate artifacts
uses: geekyeggo/delete-artifact@v2
with:
name: |
macos-x86_64
macos-arm64
windows: windows:
runs-on: windows-latest runs-on: windows-latest
strategy:
matrix:
target: ["msvc", "msys2"]
defaults:
run:
shell: ${{ (matrix.target == 'msys2' && 'msys2') || 'bash' }} {0}
env:
CCACHE_DIR: ${{ github.workspace }}/.ccache
OS: windows
TARGET: ${{ matrix.target }}
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
with: with:
@ -141,15 +154,26 @@ jobs:
- name: Set up cache - name: Set up cache
uses: actions/cache@v3 uses: actions/cache@v3
with: with:
path: ~/.buildcache path: ${{ env.CCACHE_DIR }}
key: ${{ runner.os }}-win-${{ github.sha }} key: ${{ runner.os }}-${{ matrix.target }}-${{ github.sha }}
restore-keys: | restore-keys: |
${{ runner.os }}-win- ${{ runner.os }}-${{ matrix.target }}-
- name: Install dependencies
run: ./.ci/windows-msvc/deps.sh
shell: bash
- name: Set up MSVC - name: Set up MSVC
uses: ilammy/msvc-dev-cmd@v1 uses: ilammy/msvc-dev-cmd@v1
if: ${{ matrix.target == 'msvc' }}
- name: Install MSVC extra tools
run: choco install ccache ninja wget
if: ${{ matrix.target == 'msvc' }}
- name: Set up MSYS2
uses: msys2/setup-msys2@v2
if: ${{ matrix.target == 'msys2' }}
with:
msystem: clang64
update: true
install: git make p7zip
pacboy: >-
toolchain:p ccache:p cmake:p ninja:p
qt6-base:p qt6-multimedia:p qt6-multimedia-wmf:p qt6-tools:p
- name: Setup Vulkan SDK - name: Setup Vulkan SDK
uses: humbletim/setup-vulkan-sdk@v1.2.0 uses: humbletim/setup-vulkan-sdk@v1.2.0
with: with:
@ -159,19 +183,19 @@ jobs:
- name: Test glslangValidator - name: Test glslangValidator
run: glslangValidator --version run: glslangValidator --version
- name: Build - name: Build
run: ./.ci/windows-msvc/build.sh run: ./.ci/windows.sh
shell: bash
env:
ENABLE_COMPATIBILITY_REPORTING: "ON"
- name: Pack - name: Pack
run: ./.ci/windows-msvc/upload.ps1 run: ./.ci/pack.sh
- name: Upload - name: Upload
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
with: with:
name: msvc name: ${{ env.OS }}-${{ env.TARGET }}
path: artifacts/ path: artifacts/
android: android:
runs-on: ubuntu-latest runs-on: ubuntu-latest
env:
OS: android
TARGET: universal
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
with: with:
@ -198,18 +222,21 @@ jobs:
sudo apt-get update -y sudo apt-get update -y
sudo apt-get install ccache glslang-dev glslang-tools apksigner -y sudo apt-get install ccache glslang-dev glslang-tools apksigner -y
- name: Build - name: Build
run: JAVA_HOME=$JAVA_HOME_17_X64 ./.ci/android/build.sh run: JAVA_HOME=$JAVA_HOME_17_X64 ./.ci/android.sh
- name: Copy and sign artifacts
env: env:
ANDROID_KEYSTORE_B64: ${{ secrets.ANDROID_KEYSTORE_B64 }} ANDROID_KEYSTORE_B64: ${{ secrets.ANDROID_KEYSTORE_B64 }}
ANDROID_KEY_ALIAS: ${{ secrets.ANDROID_KEY_ALIAS }} ANDROID_KEY_ALIAS: ${{ secrets.ANDROID_KEY_ALIAS }}
ANDROID_KEYSTORE_PASS: ${{ secrets.ANDROID_KEYSTORE_PASS }} ANDROID_KEYSTORE_PASS: ${{ secrets.ANDROID_KEYSTORE_PASS }}
run: ./.ci/android/upload.sh - name: Pack
run: ../../../.ci/pack.sh
working-directory: src/android/app
env:
UPLOAD_RAW: 1
- name: Upload - name: Upload
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
with: with:
name: android name: ${{ env.OS }}-${{ env.TARGET }}
path: artifacts/ path: src/android/app/artifacts/
transifex: transifex:
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: citraemu/build-environments:linux-transifex container: citraemu/build-environments:linux-transifex
@ -220,12 +247,12 @@ jobs:
submodules: recursive submodules: recursive
fetch-depth: 0 fetch-depth: 0
- name: Update Translation - name: Update Translation
run: ./.ci/transifex/docker.sh run: ./.ci/transifex.sh
env: env:
TX_TOKEN: ${{ secrets.TRANSIFEX_API_TOKEN }} TX_TOKEN: ${{ secrets.TRANSIFEX_API_TOKEN }}
release: release:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: [build, android, macos-universal, source, windows] needs: [windows, linux, macos-universal, android, source]
if: ${{ startsWith(github.ref, 'refs/tags/') }} if: ${{ startsWith(github.ref, 'refs/tags/') }}
steps: steps:
- uses: actions/download-artifact@v3 - uses: actions/download-artifact@v3

View file

@ -20,7 +20,11 @@ if (IOS)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE BOTH) set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE BOTH)
endif() endif()
option(ENABLE_LTO "Enable link time optimization" OFF) if (CMAKE_BUILD_TYPE STREQUAL Debug)
set(IS_DEBUG_BUILD ON)
else()
set(IS_DEBUG_BUILD OFF)
endif()
option(ENABLE_SDL2 "Enable using SDL2" ON) option(ENABLE_SDL2 "Enable using SDL2" ON)
CMAKE_DEPENDENT_OPTION(ENABLE_SDL2_FRONTEND "Enable the SDL2 frontend" ON "ENABLE_SDL2;NOT ANDROID AND NOT IOS" OFF) CMAKE_DEPENDENT_OPTION(ENABLE_SDL2_FRONTEND "Enable the SDL2 frontend" ON "ENABLE_SDL2;NOT ANDROID AND NOT IOS" OFF)
@ -30,15 +34,11 @@ option(USE_SYSTEM_SDL2 "Use the system SDL2 lib (instead of the bundled one)" OF
option(ENABLE_QT "Enable the Qt frontend" ON) option(ENABLE_QT "Enable the Qt frontend" ON)
option(ENABLE_QT_TRANSLATION "Enable translations for the Qt frontend" OFF) option(ENABLE_QT_TRANSLATION "Enable translations for the Qt frontend" OFF)
CMAKE_DEPENDENT_OPTION(ENABLE_QT_UPDATER "Enable built-in updater for the Qt frontend" ON "NOT IOS" OFF) CMAKE_DEPENDENT_OPTION(ENABLE_QT_UPDATER "Enable built-in updater for the Qt frontend" ON "NOT IOS" OFF)
CMAKE_DEPENDENT_OPTION(CITRA_USE_BUNDLED_QT "Download bundled Qt binaries" ON "ENABLE_QT;MSVC OR APPLE" OFF)
CMAKE_DEPENDENT_OPTION(ENABLE_TESTS "Enable generating tests executable" ON "NOT IOS" OFF) CMAKE_DEPENDENT_OPTION(ENABLE_TESTS "Enable generating tests executable" ON "NOT IOS" OFF)
CMAKE_DEPENDENT_OPTION(ENABLE_DEDICATED_ROOM "Enable generating dedicated room executable" ON "NOT ANDROID AND NOT IOS" OFF) CMAKE_DEPENDENT_OPTION(ENABLE_DEDICATED_ROOM "Enable generating dedicated room executable" ON "NOT ANDROID AND NOT IOS" OFF)
option(ENABLE_WEB_SERVICE "Enable web services (telemetry, etc.)" ON) option(ENABLE_WEB_SERVICE "Enable web services (telemetry, etc.)" ON)
if (MSVC)
set(OPENSSL_DLL_DIR "" CACHE PATH "Location of the Openssl dlls")
endif()
CMAKE_DEPENDENT_OPTION(ENABLE_CUBEB "Enables the cubeb audio backend" ON "NOT IOS" OFF) CMAKE_DEPENDENT_OPTION(ENABLE_CUBEB "Enables the cubeb audio backend" ON "NOT IOS" OFF)
option(ENABLE_OPENAL "Enables the OpenAL audio backend" ON) option(ENABLE_OPENAL "Enables the OpenAL audio backend" ON)
@ -47,30 +47,22 @@ CMAKE_DEPENDENT_OPTION(ENABLE_LIBUSB "Enable libusb for GameCube Adapter support
option(USE_DISCORD_PRESENCE "Enables Discord Rich Presence" OFF) option(USE_DISCORD_PRESENCE "Enables Discord Rich Presence" OFF)
option(CITRA_USE_PRECOMPILED_HEADERS "Use precompiled headers" ON)
CMAKE_DEPENDENT_OPTION(ENABLE_MF "Use Media Foundation decoder (preferred over FFmpeg)" ON "WIN32" OFF) CMAKE_DEPENDENT_OPTION(ENABLE_MF "Use Media Foundation decoder (preferred over FFmpeg)" ON "WIN32" OFF)
CMAKE_DEPENDENT_OPTION(ENABLE_AUDIOTOOLBOX "Use AudioToolbox decoder (preferred over FFmpeg)" ON "APPLE" OFF) CMAKE_DEPENDENT_OPTION(ENABLE_AUDIOTOOLBOX "Use AudioToolbox decoder (preferred over FFmpeg)" ON "APPLE" OFF)
CMAKE_DEPENDENT_OPTION(COMPILE_WITH_DWARF "Add DWARF debugging information" ON "MINGW" OFF) # Compile options
CMAKE_DEPENDENT_OPTION(COMPILE_WITH_DWARF "Add DWARF debugging information" ${IS_DEBUG_BUILD} "MINGW" OFF)
option(USE_SYSTEM_BOOST "Use the system Boost libs (instead of the bundled ones)" OFF) option(ENABLE_LTO "Enable link time optimization" OFF)
option(CITRA_USE_PRECOMPILED_HEADERS "Use precompiled headers" ON)
CMAKE_DEPENDENT_OPTION(CITRA_USE_BUNDLED_MOLTENVK "Download the bundled MoltenVK" ON "APPLE" OFF)
CMAKE_DEPENDENT_OPTION(CITRA_BUNDLE_LIBRARIES "Bundle dependent libraries with the output executables" ON "APPLE" OFF)
option(CITRA_WARNINGS_AS_ERRORS "Enable warnings as errors" ON) option(CITRA_WARNINGS_AS_ERRORS "Enable warnings as errors" ON)
if (CITRA_USE_PRECOMPILED_HEADERS) # System library options
if (MSVC AND CCACHE) CMAKE_DEPENDENT_OPTION(USE_SYSTEM_QT "Use the system Qt lib (instead of the bundled one)" OFF "ENABLE_QT;MSVC OR APPLE" ON)
# buildcache does not properly cache PCH files, leading to compilation errors. CMAKE_DEPENDENT_OPTION(USE_SYSTEM_MOLTENVK "Use the system MoltenVK lib (instead of the bundled one)" OFF "APPLE" OFF)
# See https://github.com/mbitsnbites/buildcache/discussions/230 option(USE_SYSTEM_SDL2 "Use the system SDL2 lib (instead of the bundled one)" OFF)
message(WARNING "Buildcache does not properly support Precompiled Headers. Disabling PCH") option(USE_SYSTEM_BOOST "Use the system Boost libs (instead of the bundled ones)" OFF)
set(CITRA_USE_PRECOMPILED_HEADERS OFF) option(USE_SYSTEM_OPENSSL "Use the system OpenSSL libs (instead of the bundled LibreSSL)" OFF)
endif()
endif()
if (CITRA_USE_PRECOMPILED_HEADERS) if (CITRA_USE_PRECOMPILED_HEADERS)
message(STATUS "Using Precompiled Headers.") message(STATUS "Using Precompiled Headers.")
set(CMAKE_PCH_INSTANTIATE_TEMPLATES ON) set(CMAKE_PCH_INSTANTIATE_TEMPLATES ON)
@ -203,8 +195,8 @@ set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED) find_package(Threads REQUIRED)
if (ENABLE_QT) if (ENABLE_QT)
if (CITRA_USE_BUNDLED_QT) if (NOT USE_SYSTEM_QT)
download_qt_external(6.5.0) download_qt(6.5.0)
endif() endif()
find_package(Qt6 REQUIRED COMPONENTS Widgets Multimedia Concurrent) find_package(Qt6 REQUIRED COMPONENTS Widgets Multimedia Concurrent)
@ -216,13 +208,6 @@ if (ENABLE_QT)
if (ENABLE_QT_TRANSLATION) if (ENABLE_QT_TRANSLATION)
find_package(Qt6 REQUIRED COMPONENTS LinguistTools) find_package(Qt6 REQUIRED COMPONENTS LinguistTools)
endif() endif()
if (NOT CITRA_USE_BUNDLED_QT)
# Make sure the Qt bin directory is in the prefix path for later use, such as in post-build scripts.
get_target_property(qmake_executable Qt6::qmake IMPORTED_LOCATION)
get_filename_component(qt_bin_dir "${qmake_executable}" DIRECTORY)
list(APPEND CMAKE_PREFIX_PATH ${qt_bin_dir})
endif()
endif() endif()
# Ensure libusb is properly configured (based on dolphin libusb include) # Ensure libusb is properly configured (based on dolphin libusb include)
@ -245,7 +230,7 @@ find_package(tsl-robin-map QUIET)
# ====================================== # ======================================
if (APPLE) if (APPLE)
if (CITRA_USE_BUNDLED_MOLTENVK) if (NOT USE_SYSTEM_MOLTENVK)
download_moltenvk() download_moltenvk()
endif() endif()
find_library(MOLTENVK_LIBRARY MoltenVK REQUIRED) find_library(MOLTENVK_LIBRARY MoltenVK REQUIRED)
@ -401,6 +386,14 @@ else()
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT citra) set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT citra)
endif() endif()
# Create target for outputting distributable bundles.
if (NOT ANDROID AND NOT IOS)
include(BundleTarget)
bundle_target(citra)
bundle_target(citra-qt)
bundle_target(citra-room)
endif()
# Installation instructions # Installation instructions
# ========================= # =========================
@ -409,7 +402,7 @@ endif()
# http://standards.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html # http://standards.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html
# http://standards.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-latest.html # http://standards.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-latest.html
if(ENABLE_QT AND UNIX AND NOT APPLE) if(ENABLE_QT AND UNIX AND NOT APPLE)
install(FILES "${PROJECT_SOURCE_DIR}/dist/citra.desktop" install(FILES "${PROJECT_SOURCE_DIR}/dist/citra-qt.desktop"
DESTINATION "${CMAKE_INSTALL_PREFIX}/share/applications") DESTINATION "${CMAKE_INSTALL_PREFIX}/share/applications")
install(FILES "${PROJECT_SOURCE_DIR}/dist/citra.svg" install(FILES "${PROJECT_SOURCE_DIR}/dist/citra.svg"
DESTINATION "${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/scalable/apps") DESTINATION "${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/scalable/apps")

View file

@ -12,7 +12,7 @@ endif()
list(APPEND CMAKE_MODULE_PATH "${BASE_DIR}/CMakeModules") list(APPEND CMAKE_MODULE_PATH "${BASE_DIR}/CMakeModules")
include(DownloadExternals) include(DownloadExternals)
download_qt_external(tools_ifw QT_PREFIX) download_qt(tools_ifw QT_PREFIX)
file(GLOB_RECURSE INSTALLER_BASE "${QT_PREFIX}/**/installerbase*") file(GLOB_RECURSE INSTALLER_BASE "${QT_PREFIX}/**/installerbase*")
file(GLOB_RECURSE BINARY_CREATOR "${QT_PREFIX}/**/binarycreator*") file(GLOB_RECURSE BINARY_CREATOR "${QT_PREFIX}/**/binarycreator*")

View file

@ -1,66 +0,0 @@
# 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)
# Bundling libraries can rewrite path information and break code signatures of system libraries.
# Perform an ad-hoc re-signing on the whole app bundle to fix this.
execute_process(COMMAND codesign --deep -fs - ${bundle_dir})
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()

View file

@ -0,0 +1,243 @@
if (BUNDLE_TARGET_EXECUTE)
# --- Bundling method logic ---
function(bundle_qt executable_path)
if (WIN32)
get_filename_component(executable_parent_dir "${executable_path}" DIRECTORY)
find_program(windeployqt_executable windeployqt6)
# Create a qt.conf file pointing to the app directory.
# This ensures Qt can find its plugins.
file(WRITE "${executable_parent_dir}/qt.conf" "[Paths]\nprefix = .")
message(STATUS "Executing windeployqt for executable ${executable_path}")
execute_process(COMMAND "${windeployqt_executable}" "${executable_path}"
--no-compiler-runtime --no-system-d3d-compiler --no-opengl-sw --no-translations
--plugindir "${executable_parent_dir}/plugins")
# Remove the FFmpeg multimedia plugin as we don't include FFmpeg.
# We want to use the Windows media plugin instead, which is also included.
file(REMOVE "${executable_parent_dir}/plugins/multimedia/ffmpegmediaplugin.dll")
elseif (APPLE)
get_filename_component(executable_name "${executable_path}" NAME_WE)
find_program(MACDEPLOYQT_EXECUTABLE macdeployqt6)
message(STATUS "Executing macdeployqt for executable ${executable_path}")
execute_process(
COMMAND "${MACDEPLOYQT_EXECUTABLE}"
"${executable_path}"
"-executable=${executable_path}/Contents/MacOS/${executable_name}"
-always-overwrite)
# Bundling libraries can rewrite path information and break code signatures of system libraries.
# Perform an ad-hoc re-signing on the whole app bundle to fix this.
execute_process(COMMAND codesign --deep -fs - "${executable_path}")
else()
message(FATAL_ERROR "Unsupported OS for Qt bundling.")
endif()
endfunction()
function(bundle_appimage bundle_dir executable_path source_path binary_path linuxdeploy_executable enable_qt)
get_filename_component(executable_name "${executable_path}" NAME_WE)
set(appdir_path "${binary_path}/AppDir-${executable_name}")
if (enable_qt)
# Find qmake to make sure the plugin uses the right version of Qt.
find_program(QMAKE_EXECUTABLE qmake6)
set(extra_linuxdeploy_env "QMAKE=${QMAKE_EXECUTABLE}")
set(extra_linuxdeploy_args --plugin qt)
endif()
message(STATUS "Creating AppDir for executable ${executable_path}")
execute_process(COMMAND ${CMAKE_COMMAND} -E env
${extra_linuxdeploy_env}
"${linuxdeploy_executable}"
${extra_linuxdeploy_args}
--plugin checkrt
--executable "${executable_path}"
--icon-file "${source_path}/dist/citra.svg"
--desktop-file "${source_path}/dist/${executable_name}.desktop"
--appdir "${appdir_path}")
if (enable_qt)
set(qt_hook_file "${appdir_path}/apprun-hooks/linuxdeploy-plugin-qt-hook.sh")
file(READ "${qt_hook_file}" qt_hook_contents)
# Add Cinnamon to list of DEs for GTK3 theming.
string(REPLACE
"*XFCE*"
"*X-Cinnamon*|*XFCE*"
qt_hook_contents "${qt_hook_contents}")
# Wayland backend crashes due to changed schemas in Gnome 40.
string(REPLACE
"export QT_QPA_PLATFORMTHEME=gtk3"
"export QT_QPA_PLATFORMTHEME=gtk3; export GDK_BACKEND=x11"
qt_hook_contents "${qt_hook_contents}")
file(WRITE "${qt_hook_file}" "${qt_hook_contents}")
endif()
message(STATUS "Creating AppImage for executable ${executable_path}")
execute_process(COMMAND ${CMAKE_COMMAND} -E env
"OUTPUT=${bundle_dir}/${executable_name}.AppImage"
"${linuxdeploy_executable}"
--output appimage
--appdir "${appdir_path}")
endfunction()
function(bundle_standalone executable_path original_executable_path bundle_library_paths)
get_filename_component(executable_parent_dir "${executable_path}" DIRECTORY)
# Resolve dependent library files if they were not passed in.
message(STATUS "Determining runtime dependencies of ${executable_path} using library paths ${bundle_library_paths}")
file(GET_RUNTIME_DEPENDENCIES
EXECUTABLES ${original_executable_path}
RESOLVED_DEPENDENCIES_VAR resolved_deps
UNRESOLVED_DEPENDENCIES_VAR unresolved_deps
DIRECTORIES ${bundle_library_paths}
POST_EXCLUDE_REGEXES ".*system32.*")
if (WIN32)
# Same directory since we don't have rpath.
set(lib_dir "${executable_parent_dir}")
else()
set(lib_dir "${executable_parent_dir}/libs")
endif()
# Copy files to bundled output.
if (resolved_deps)
file(MAKE_DIRECTORY ${lib_dir})
foreach (lib_file IN LISTS resolved_deps)
message(STATUS "Bundling library ${lib_file}")
# Use native copy to turn symlinks into normal files.
execute_process(COMMAND cp -L "${lib_file}" "${lib_dir}")
endforeach()
endif()
# 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()
endfunction()
# --- Root bundling logic ---
set(bundle_dir ${BINARY_PATH}/bundle)
file(MAKE_DIRECTORY ${bundle_dir})
# On Linux, always bundle an AppImage.
if (DEFINED LINUXDEPLOY)
bundle_appimage("${bundle_dir}" "${EXECUTABLE_PATH}" "${SOURCE_PATH}" "${BINARY_PATH}" "${LINUXDEPLOY}" ${BUNDLE_QT})
else()
message(STATUS "Copying base executable ${EXECUTABLE_PATH} to output directory ${bundle_dir}")
file(COPY ${EXECUTABLE_PATH} DESTINATION ${bundle_dir})
get_filename_component(bundled_executable_name "${EXECUTABLE_PATH}" NAME)
set(bundled_executable_path "${bundle_dir}/${bundled_executable_name}")
if (BUNDLE_QT)
bundle_qt("${bundled_executable_path}")
endif()
if (WIN32 OR NOT BUNDLE_QT)
bundle_standalone("${bundled_executable_path}" "${EXECUTABLE_PATH}" "${BUNDLE_LIBRARY_PATHS}")
endif()
endif()
else()
# --- Bundling target creation logic ---
# Downloads and extracts a linuxdeploy component.
function(download_linuxdeploy_component base_dir name executable_name)
set(executable_file "${base_dir}/${executable_name}")
if (NOT EXISTS "${executable_file}")
message(STATUS "Downloading ${executable_name}")
file(DOWNLOAD
"https://github.com/linuxdeploy/${name}/releases/download/continuous/${executable_name}"
"${executable_file}" SHOW_PROGRESS)
file(CHMOD "${executable_file}" PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE)
get_filename_component(executable_ext "${executable_file}" LAST_EXT)
if (executable_ext STREQUAL ".AppImage")
message(STATUS "Extracting ${executable_name}")
execute_process(
COMMAND "${executable_file}" --appimage-extract
WORKING_DIRECTORY "${base_dir}")
else()
message(STATUS "Copying ${executable_name}")
file(COPY "${executable_file}" DESTINATION "${base_dir}/squashfs-root/usr/bin/")
endif()
endif()
endfunction()
# Adds a target to the bundle target, packing in required libraries.
function(bundle_target target_name)
# Create base bundle target if it does not exist.
if (NOT TARGET bundle)
message(STATUS "Creating base bundle target")
add_custom_target(bundle)
add_custom_command(
TARGET bundle
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/license.txt" "${CMAKE_BINARY_DIR}/bundle/")
add_custom_command(
TARGET bundle
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/README.md" "${CMAKE_BINARY_DIR}/bundle/")
add_custom_command(
TARGET bundle
COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_SOURCE_DIR}/dist/scripting" "${CMAKE_BINARY_DIR}/bundle/scripting")
endif()
set(BUNDLE_EXECUTABLE_PATH "$<TARGET_FILE:${target_name}>")
if (target_name MATCHES ".*qt")
set(BUNDLE_QT ON)
if (APPLE)
# For Qt targets on Apple, expect an app bundle.
set(BUNDLE_EXECUTABLE_PATH "$<TARGET_BUNDLE_DIR:${target_name}>")
endif()
else()
set(BUNDLE_QT OFF)
endif()
# Build a list of library search paths from prefix paths.
foreach(prefix_path IN LISTS CMAKE_PREFIX_PATH CMAKE_SYSTEM_PREFIX_PATH)
if (WIN32)
list(APPEND BUNDLE_LIBRARY_PATHS "${prefix_path}/bin")
endif()
list(APPEND BUNDLE_LIBRARY_PATHS "${prefix_path}/lib")
endforeach()
foreach(library_path IN LISTS CMAKE_SYSTEM_LIBRARY_PATH)
list(APPEND BUNDLE_LIBRARY_PATHS "${library_path}")
endforeach()
# On Linux, prepare linuxdeploy and any required plugins.
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(LINUXDEPLOY_BASE "${CMAKE_BINARY_DIR}/externals/linuxdeploy")
# Download plugins first so they don't overwrite linuxdeploy's AppRun file.
download_linuxdeploy_component("${LINUXDEPLOY_BASE}" "linuxdeploy-plugin-qt" "linuxdeploy-plugin-qt-x86_64.AppImage")
download_linuxdeploy_component("${LINUXDEPLOY_BASE}" "linuxdeploy-plugin-checkrt" "linuxdeploy-plugin-checkrt-x86_64.sh")
download_linuxdeploy_component("${LINUXDEPLOY_BASE}" "linuxdeploy" "linuxdeploy-x86_64.AppImage")
set(EXTRA_BUNDLE_ARGS "-DLINUXDEPLOY=${LINUXDEPLOY_BASE}/squashfs-root/AppRun")
endif()
message(STATUS "Adding ${target_name} to bundle target")
add_custom_target(bundle-${target_name}
COMMAND ${CMAKE_COMMAND}
"-DCMAKE_PREFIX_PATH=\"${CMAKE_PREFIX_PATH}\""
"-DBUNDLE_TARGET_EXECUTE=1"
"-DTARGET=${target_name}"
"-DSOURCE_PATH=${CMAKE_SOURCE_DIR}"
"-DBINARY_PATH=${CMAKE_BINARY_DIR}"
"-DEXECUTABLE_PATH=${BUNDLE_EXECUTABLE_PATH}"
"-DBUNDLE_LIBRARY_PATHS=\"${BUNDLE_LIBRARY_PATHS}\""
"-DBUNDLE_QT=${BUNDLE_QT}"
${EXTRA_BUNDLE_ARGS}
-P "${CMAKE_SOURCE_DIR}/CMakeModules/BundleTarget.cmake"
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
DEPENDS ${target_name})
add_dependencies(bundle bundle-${target_name})
endfunction()
endif()

View file

@ -1,6 +0,0 @@
function(copy_citra_openssl_deps target_dir)
include(WindowsCopyFiles)
set(DLL_DEST "${CMAKE_BINARY_DIR}/bin/$<CONFIG>/")
windows_copy_files(${target_dir} ${OPENSSL_DLL_DIR} ${DLL_DEST} libcrypto-1_1-x64.dll)
windows_copy_files(${target_dir} ${OPENSSL_DLL_DIR} ${DLL_DEST} libssl-1_1-x64.dll)
endfunction(copy_citra_openssl_deps)

View file

@ -1,46 +0,0 @@
function(copy_citra_Qt6_deps target_dir)
include(WindowsCopyFiles)
set(DLL_DEST "${CMAKE_BINARY_DIR}/bin/$<CONFIG>/")
set(Qt6_DLL_DIR "${Qt6_DIR}/../../../bin")
set(Qt6_PLATFORMS_DIR "${Qt6_DIR}/../../../plugins/platforms/")
set(Qt6_MULTIMEDIA_DIR "${Qt6_DIR}/../../../plugins/multimedia/")
set(Qt6_STYLES_DIR "${Qt6_DIR}/../../../plugins/styles/")
set(Qt6_IMAGEFORMATS_DIR "${Qt6_DIR}/../../../plugins/imageformats/")
set(PLATFORMS ${DLL_DEST}plugins/platforms/)
set(MULTIMEDIA ${DLL_DEST}plugins/multimedia/)
set(STYLES ${DLL_DEST}plugins/styles/)
set(IMAGEFORMATS ${DLL_DEST}plugins/imageformats/)
windows_copy_files(${target_dir} ${Qt6_DLL_DIR} ${DLL_DEST}
icudt*.dll
icuin*.dll
icuuc*.dll
Qt6Core$<$<CONFIG:Debug>:d>.*
Qt6Gui$<$<CONFIG:Debug>:d>.*
Qt6Widgets$<$<CONFIG:Debug>:d>.*
Qt6Concurrent$<$<CONFIG:Debug>:d>.*
Qt6Multimedia$<$<CONFIG:Debug>:d>.*
Qt6Network$<$<CONFIG:Debug>:d>.*
)
windows_copy_files(citra-qt ${Qt6_PLATFORMS_DIR} ${PLATFORMS} qwindows$<$<CONFIG:Debug>:d>.*)
windows_copy_files(citra-qt ${Qt6_MULTIMEDIA_DIR} ${MULTIMEDIA}
windowsmediaplugin$<$<CONFIG:Debug>:d>.*
)
windows_copy_files(citra-qt ${Qt6_STYLES_DIR} ${STYLES} qwindowsvistastyle$<$<CONFIG:Debug>:d>.*)
windows_copy_files(${target_dir} ${Qt6_IMAGEFORMATS_DIR} ${IMAGEFORMATS}
qgif$<$<CONFIG:Debug>:d>.dll
qicns$<$<CONFIG:Debug>:d>.dll
qico$<$<CONFIG:Debug>:d>.dll
qjpeg$<$<CONFIG:Debug>:d>.dll
qsvg$<$<CONFIG:Debug>:d>.dll
qtga$<$<CONFIG:Debug>:d>.dll
qtiff$<$<CONFIG:Debug>:d>.dll
qwbmp$<$<CONFIG:Debug>:d>.dll
qwebp$<$<CONFIG:Debug>:d>.dll
)
# Create an empty qt.conf file. Qt will detect that this file exists, and use the folder that its in as the root folder.
# This way it'll look for plugins in the root/plugins/ folder
add_custom_command(TARGET citra-qt POST_BUILD
COMMAND ${CMAKE_COMMAND} -E touch ${DLL_DEST}qt.conf
)
endfunction(copy_citra_Qt6_deps)

View file

@ -1,60 +1,28 @@
# This function downloads a binary library package from our external repo.
# Params:
# remote_path: path to the file to download, relative to the remote repository root
# prefix_var: name of a variable which will be set with the path to the extracted contents
function(download_bundled_external remote_path lib_name prefix_var)
get_external_prefix(${lib_name} prefix)
if (NOT EXISTS "${prefix}")
message(STATUS "Downloading binaries for ${lib_name}...")
if (WIN32)
set(repo_base "ext-windows-bin/raw/master")
elseif (APPLE)
set(repo_base "ext-macos-bin/raw/main")
else()
message(FATAL_ERROR "Bundled libraries are unsupported for this OS.")
endif()
file(DOWNLOAD
https://github.com/citra-emu/${repo_base}/${remote_path}${lib_name}.7z
"${CMAKE_BINARY_DIR}/externals/${lib_name}.7z" SHOW_PROGRESS)
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xf "${CMAKE_BINARY_DIR}/externals/${lib_name}.7z"
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/externals")
endif()
# For packages that include the /usr/local prefix, include it in the prefix path.
if (EXISTS "${prefix}/usr/local")
set(prefix "${prefix}/usr/local")
endif()
message(STATUS "Using bundled binaries at ${prefix}")
set(${prefix_var} "${prefix}" PARENT_SCOPE)
endfunction()
# This function downloads Qt using aqt. # This function downloads Qt using aqt.
# Params: # Params:
# target: Qt dependency to install. Specify a version number to download Qt, or "tools_(name)" for a specific build tool. # target: Qt dependency to install. Specify a version number to download Qt, or "tools_(name)" for a specific build tool.
# prefix_var: Name of a variable which will be set with the path to the extracted contents. # prefix_var: Name of a variable which will be set with the path to the extracted contents.
function(download_qt_external target) function(download_qt target)
# Determine installation parameters for OS, architecture, and compiler # Determine installation parameters for OS, architecture, and compiler
if (WIN32) if (WIN32)
set(host "windows") set(host "windows")
set(type "desktop") set(type "desktop")
if (MINGW) if (MINGW)
set(arch_path "mingw81") set(arch "win64_mingw")
elseif ((MSVC_VERSION GREATER_EQUAL 1920 AND MSVC_VERSION LESS 1940) AND "x86_64" IN_LIST ARCHITECTURE) set(arch_path "mingw_64")
elseif (MSVC)
if ("arm64" IN_LIST ARCHITECTURE) if ("arm64" IN_LIST ARCHITECTURE)
set(arch_path "msvc2019_arm64") set(arch_path "msvc2019_arm64")
elseif ("x86_64" IN_LIST ARCHITECTURE) elseif ("x86_64" IN_LIST ARCHITECTURE)
set(arch_path "msvc2019_64") set(arch_path "msvc2019_64")
else() else()
message(FATAL_ERROR "Unsupported bundled Qt architecture. Disable CITRA_USE_BUNDLED_QT and provide your own.") message(FATAL_ERROR "Unsupported bundled Qt architecture. Enable USE_SYSTEM_QT and provide your own.")
endif()
else()
message(FATAL_ERROR "Unsupported bundled Qt toolchain. Disable CITRA_USE_BUNDLED_QT and provide your own.")
endif() endif()
set(arch "win64_${arch_path}") set(arch "win64_${arch_path}")
else()
message(FATAL_ERROR "Unsupported bundled Qt toolchain. Enable USE_SYSTEM_QT and provide your own.")
endif()
elseif (APPLE) elseif (APPLE)
set(host "mac") set(host "mac")
if (IOS) if (IOS)

View file

@ -1,12 +0,0 @@
# buildcache wrapper
OPTION(CITRA_USE_CCACHE "Use buildcache for compilation" OFF)
IF(CITRA_USE_CCACHE)
FIND_PROGRAM(CCACHE buildcache)
IF (CCACHE)
MESSAGE(STATUS "Using buildcache found in PATH")
SET_PROPERTY(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE})
SET_PROPERTY(GLOBAL PROPERTY RULE_LAUNCH_LINK ${CCACHE})
ELSE(CCACHE)
MESSAGE(WARNING "CITRA_USE_CCACHE enabled, but no buildcache executable found")
ENDIF(CCACHE)
ENDIF(CITRA_USE_CCACHE)

View file

@ -1,52 +0,0 @@
SET(MINGW_PREFIX /usr/x86_64-w64-mingw32/)
SET(CMAKE_SYSTEM_NAME Windows)
SET(CMAKE_SYSTEM_PROCESSOR x86_64)
SET(CMAKE_FIND_ROOT_PATH ${MINGW_PREFIX})
SET(SDL2_PATH ${MINGW_PREFIX})
SET(MINGW_TOOL_PREFIX ${CMAKE_SYSTEM_PROCESSOR}-w64-mingw32-)
# Specify the cross compiler
SET(CMAKE_C_COMPILER ${MINGW_TOOL_PREFIX}gcc)
SET(CMAKE_CXX_COMPILER ${MINGW_TOOL_PREFIX}g++)
SET(CMAKE_RC_COMPILER ${MINGW_TOOL_PREFIX}windres)
# Mingw tools
SET(STRIP ${MINGW_TOOL_PREFIX}strip)
SET(WINDRES ${MINGW_TOOL_PREFIX}windres)
SET(ENV{PKG_CONFIG} ${MINGW_TOOL_PREFIX}pkg-config)
# ccache wrapper
OPTION(CITRA_USE_CCACHE "Use ccache for compilation" OFF)
IF(CITRA_USE_CCACHE)
FIND_PROGRAM(CCACHE ccache)
IF (CCACHE)
MESSAGE(STATUS "Using ccache found in PATH")
SET_PROPERTY(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE})
SET_PROPERTY(GLOBAL PROPERTY RULE_LAUNCH_LINK ${CCACHE})
ELSE(CCACHE)
MESSAGE(WARNING "CITRA_USE_CCACHE enabled, but no ccache found")
ENDIF(CCACHE)
ENDIF(CITRA_USE_CCACHE)
# Search for programs in the build host directories
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# Echo modified cmake vars to screen for debugging purposes
IF(NOT DEFINED ENV{MINGW_DEBUG_INFO})
MESSAGE("")
MESSAGE("Custom cmake vars: (blank = system default)")
MESSAGE("-----------------------------------------")
MESSAGE("* CMAKE_C_COMPILER : ${CMAKE_C_COMPILER}")
MESSAGE("* CMAKE_CXX_COMPILER : ${CMAKE_CXX_COMPILER}")
MESSAGE("* CMAKE_RC_COMPILER : ${CMAKE_RC_COMPILER}")
MESSAGE("* WINDRES : ${WINDRES}")
MESSAGE("* ENV{PKG_CONFIG} : $ENV{PKG_CONFIG}")
MESSAGE("* STRIP : ${STRIP}")
MESSAGE("* CITRA_USE_CCACHE : ${CITRA_USE_CCACHE}")
MESSAGE("")
# So that the debug info only appears once
SET(ENV{MINGW_DEBUG_INFO} SHOWN)
ENDIF()

15
dist/citra-qt.desktop vendored Normal file
View file

@ -0,0 +1,15 @@
[Desktop Entry]
Version=1.0
Type=Application
Name=Citra
GenericName=3DS Emulator
GenericName[fr]=Émulateur 3DS
Comment=Nintendo 3DS video game console emulator
Comment[fr]=Émulateur de console de jeu Nintendo 3DS
Icon=citra
TryExec=citra-qt
Exec=citra-qt %f
Categories=Game;Emulator;Qt;
MimeType=application/x-ctr-3dsx;application/x-ctr-cci;application/x-ctr-cia;application/x-ctr-cxi;
Keywords=3DS;Nintendo;
PrefersNonDefaultGPU=true

10
dist/citra-room.desktop vendored Normal file
View file

@ -0,0 +1,10 @@
[Desktop Entry]
Version=1.0
Type=Application
Name=Citra Room
Comment=Multiplayer room host for Citra
Icon=citra
TryExec=citra-room
Exec=citra-room %f
Categories=Game;Emulator;
Keywords=3DS;Nintendo

6
dist/citra.desktop vendored
View file

@ -7,9 +7,9 @@ GenericName[fr]=Émulateur 3DS
Comment=Nintendo 3DS video game console emulator Comment=Nintendo 3DS video game console emulator
Comment[fr]=Émulateur de console de jeu Nintendo 3DS Comment[fr]=Émulateur de console de jeu Nintendo 3DS
Icon=citra Icon=citra
TryExec=citra-qt TryExec=citra
Exec=citra-qt %f Exec=citra %f
Categories=Game;Emulator;Qt; Categories=Game;Emulator;
MimeType=application/x-ctr-3dsx;application/x-ctr-cci;application/x-ctr-cia;application/x-ctr-cxi; MimeType=application/x-ctr-3dsx;application/x-ctr-cci;application/x-ctr-cia;application/x-ctr-cxi;
Keywords=3DS;Nintendo; Keywords=3DS;Nintendo;
PrefersNonDefaultGPU=true PrefersNonDefaultGPU=true

View file

@ -156,6 +156,7 @@ target_include_directories(enet INTERFACE ./enet/include)
if (ENABLE_CUBEB) if (ENABLE_CUBEB)
set(BUILD_TESTS OFF CACHE BOOL "") set(BUILD_TESTS OFF CACHE BOOL "")
set(BUILD_TOOLS OFF CACHE BOOL "") set(BUILD_TOOLS OFF CACHE BOOL "")
set(BUNDLE_SPEEX ON CACHE BOOL "")
add_subdirectory(cubeb EXCLUDE_FROM_ALL) add_subdirectory(cubeb EXCLUDE_FROM_ALL)
endif() endif()
@ -170,10 +171,14 @@ add_library(json-headers INTERFACE)
target_include_directories(json-headers INTERFACE ./json) target_include_directories(json-headers INTERFACE ./json)
if (ENABLE_WEB_SERVICE) if (ENABLE_WEB_SERVICE)
if (USE_SYSTEM_OPENSSL)
find_package(OpenSSL 1.1) find_package(OpenSSL 1.1)
if (OPENSSL_FOUND) if (OPENSSL_FOUND)
set(OPENSSL_LIBRARIES OpenSSL::SSL OpenSSL::Crypto) set(OPENSSL_LIBRARIES OpenSSL::SSL OpenSSL::Crypto)
else() endif()
endif()
if (NOT OPENSSL_FOUND)
# LibreSSL # LibreSSL
set(LIBRESSL_SKIP_INSTALL ON CACHE BOOL "") set(LIBRESSL_SKIP_INSTALL ON CACHE BOOL "")
set(OPENSSLDIR "/etc/ssl/") set(OPENSSLDIR "/etc/ssl/")

View file

@ -1,28 +0,0 @@
# Copyright 2016 Citra Emulator Project
# Licensed under GPLv2 or any later version
# Refer to the license.txt file included.
# This file provides the function windows_copy_files.
# This is only valid on Windows.
# Include guard
if(__windows_copy_files)
return()
endif()
set(__windows_copy_files YES)
# Any number of files to copy from SOURCE_DIR to DEST_DIR can be specified after DEST_DIR.
# This copying happens post-build.
function(windows_copy_files TARGET SOURCE_DIR DEST_DIR)
# windows commandline expects the / to be \ so switch them
string(REPLACE "/" "\\\\" SOURCE_DIR ${SOURCE_DIR})
string(REPLACE "/" "\\\\" DEST_DIR ${DEST_DIR})
# /NJH /NJS /NDL /NFL /NC /NS /NP - Silence any output
# cmake adds an extra check for command success which doesn't work too well with robocopy
# so trick it into thinking the command was successful with the || cmd /c "exit /b 0"
add_custom_command(TARGET ${TARGET} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${DEST_DIR}
COMMAND robocopy ${SOURCE_DIR} ${DEST_DIR} ${ARGN} /NJH /NJS /NDL /NFL /NC /NS /NP || cmd /c "exit /b 0"
)
endfunction()

View file

@ -233,6 +233,12 @@ using socket_t = int;
#undef X509_EXTENSIONS #undef X509_EXTENSIONS
#undef PKCS7_SIGNER_INFO #undef PKCS7_SIGNER_INFO
// libressl will warn without this, which becomes an error.
#undef OCSP_REQUEST
#undef OCSP_RESPONSE
#undef PKCS7_ISSUER_AND_SERIAL
#undef __WINCRYPT_H__
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma comment(lib, "crypt32.lib") #pragma comment(lib, "crypt32.lib")
#pragma comment(lib, "cryptui.lib") #pragma comment(lib, "cryptui.lib")

View file

@ -110,28 +110,21 @@ else()
add_compile_options("-stdlib=libc++") add_compile_options("-stdlib=libc++")
endif() endif()
# Set file offset size to 64 bits.
#
# On modern Unixes, this is typically already the case. The lone exception is
# glibc, which may default to 32 bits. glibc allows this to be configured
# by setting _FILE_OFFSET_BITS.
if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR MINGW)
add_definitions(-D_FILE_OFFSET_BITS=64)
endif()
if (MINGW) if (MINGW)
add_definitions(-DMINGW_HAS_SECURE_API) add_definitions(-DMINGW_HAS_SECURE_API)
if (COMPILE_WITH_DWARF) if (COMPILE_WITH_DWARF)
add_compile_options("-gdwarf") add_compile_options("-gdwarf")
endif() endif()
if (MINGW_STATIC_BUILD)
add_definitions(-DQT_STATICPLUGIN)
add_compile_options("-static")
endif()
endif() endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR MINGW) if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR MINGW)
# Set file offset size to 64 bits.
#
# On modern Unixes, this is typically already the case. The lone exception is
# glibc, which may default to 32 bits. glibc allows this to be configured
# by setting _FILE_OFFSET_BITS.
add_definitions(-D_FILE_OFFSET_BITS=64)
# GNU ar: Create thin archive files. # GNU ar: Create thin archive files.
# Requires binutils-2.19 or later. # Requires binutils-2.19 or later.
set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> qcTP <TARGET> <LINK_FLAGS> <OBJECTS>") set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> qcTP <TARGET> <LINK_FLAGS> <OBJECTS>")

View file

@ -38,13 +38,16 @@ android {
ndk.abiFilters abiFilter ndk.abiFilters abiFilter
} }
def keystoreFile = System.getenv('ANDROID_KEYSTORE_FILE')
if (keystoreFile != null) {
signingConfigs { signingConfigs {
//release { release {
// storeFile file('') storeFile file(keystoreFile)
// storePassword System.getenv('ANDROID_KEYPASS') storePassword System.getenv('ANDROID_KEYSTORE_PASS')
// keyAlias = 'key0' keyAlias System.getenv('ANDROID_KEY_ALIAS')
// keyPassword System.getenv('ANDROID_KEYPASS') keyPassword System.getenv('ANDROID_KEYSTORE_PASS')
//} }
}
} }
applicationVariants.all { variant -> applicationVariants.all { variant ->
@ -56,7 +59,7 @@ android {
// Signed by release key, allowing for upload to Play Store. // Signed by release key, allowing for upload to Play Store.
release { release {
signingConfig signingConfigs.debug signingConfig keystoreFile != null ? signingConfigs.release : signingConfigs.debug
} }
// builds a release build that doesn't need signing // builds a release build that doesn't need signing
@ -107,8 +110,7 @@ android {
cmake { cmake {
arguments "-DENABLE_QT=0", // Don't use QT arguments "-DENABLE_QT=0", // Don't use QT
"-DENABLE_SDL2=0", // Don't use SDL "-DENABLE_SDL2=0", // Don't use SDL
"-DANDROID_ARM_NEON=true", // cryptopp requires Neon to work "-DANDROID_ARM_NEON=true" // cryptopp requires Neon to work
"-DBUNDLE_SPEEX=ON"
abiFilters abiFilter abiFilters abiFilter
} }
@ -168,3 +170,23 @@ def getVersion() {
return versionName return versionName
} }
// Add task to each variant for copying output APKs to bundle directory.
android.applicationVariants.all { variant ->
def capitalizedName = variant.name.capitalize()
def copyTask = tasks.register("copyBundle${capitalizedName}") {
doLast {
project.copy {
from variant.outputs[0].outputFile.parentFile
include '*.apk'
into layout.buildDirectory.dir("bundle")
}
project.copy {
from layout.buildDirectory.dir("outputs/bundle/${variant.name}")
include '*.aab'
into layout.buildDirectory.dir("bundle")
}
}
}
tasks.named("bundle${capitalizedName}").get().configure { finalizedBy copyTask }
}

View file

@ -30,7 +30,7 @@ void ReportError(std::string msg, HRESULT hr) {
unique_mfptr<IMFTransform> MFDecoderInit(GUID audio_format) { unique_mfptr<IMFTransform> MFDecoderInit(GUID audio_format) {
HRESULT hr = S_OK; HRESULT hr = S_OK;
MFT_REGISTER_TYPE_INFO reg = {0}; MFT_REGISTER_TYPE_INFO reg{};
GUID category = MFT_CATEGORY_AUDIO_DECODER; GUID category = MFT_CATEGORY_AUDIO_DECODER;
IMFActivate** activate; IMFActivate** activate;
unique_mfptr<IMFTransform> transform; unique_mfptr<IMFTransform> transform;

View file

@ -29,22 +29,6 @@ if(UNIX AND NOT APPLE)
install(TARGETS citra RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/bin") install(TARGETS citra RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/bin")
endif() endif()
if (MSVC AND ENABLE_WEB_SERVICE AND OPENSSL_DLL_DIR)
include(CopyCitraOpensslDeps)
copy_citra_openssl_deps(citra)
endif()
if (CITRA_USE_PRECOMPILED_HEADERS) if (CITRA_USE_PRECOMPILED_HEADERS)
target_precompile_headers(citra PRIVATE precompiled_headers.h) target_precompile_headers(citra PRIVATE precompiled_headers.h)
endif() endif()
if (CITRA_BUNDLE_LIBRARIES)
add_custom_command(TARGET citra
POST_BUILD
COMMAND ${CMAKE_COMMAND}
-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}
-DTYPE=standalone
-DEXECUTABLE_PATH=$<TARGET_FILE:citra>
-P ${CMAKE_SOURCE_DIR}/CMakeModules/BundleLibraries.cmake
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
endif()

View file

@ -290,22 +290,6 @@ elseif(WIN32)
endif() endif()
endif() endif()
if (CITRA_BUNDLE_LIBRARIES)
if (APPLE)
set(BUNDLE_DIR "$<TARGET_BUNDLE_DIR:citra-qt>")
endif()
add_custom_command(TARGET citra-qt
POST_BUILD
COMMAND ${CMAKE_COMMAND}
-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}
-DTYPE=qt
-DEXECUTABLE_PATH=$<TARGET_FILE:citra-qt>
-DBUNDLE_PATH=${BUNDLE_DIR}
-P ${CMAKE_SOURCE_DIR}/CMakeModules/BundleLibraries.cmake
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
endif()
create_target_directory_groups(citra-qt) create_target_directory_groups(citra-qt)
target_link_libraries(citra-qt PRIVATE audio_core citra_common citra_core input_common network video_core) target_link_libraries(citra-qt PRIVATE audio_core citra_common citra_core input_common network video_core)
@ -360,15 +344,6 @@ if(UNIX AND NOT APPLE)
install(TARGETS citra-qt RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/bin") install(TARGETS citra-qt RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/bin")
endif() endif()
if (MSVC)
include(CopyCitraQt6Deps)
copy_citra_Qt6_deps(citra-qt)
if (ENABLE_WEB_SERVICE AND OPENSSL_DLL_DIR)
include(CopyCitraOpensslDeps)
copy_citra_openssl_deps(citra-qt)
endif()
endif()
if (NOT APPLE) if (NOT APPLE)
target_compile_definitions(citra-qt PRIVATE HAS_OPENGL) target_compile_definitions(citra-qt PRIVATE HAS_OPENGL)
endif() endif()

View file

@ -44,7 +44,7 @@ void PrintColoredMessage(const Entry& entry) {
return; return;
} }
CONSOLE_SCREEN_BUFFER_INFO original_info = {0}; CONSOLE_SCREEN_BUFFER_INFO original_info{};
GetConsoleScreenBufferInfo(console_handle, &original_info); GetConsoleScreenBufferInfo(console_handle, &original_info);
WORD color = 0; WORD color = 0;

View file

@ -12,10 +12,6 @@ target_link_libraries(citra-room PRIVATE citra_common network)
if (ENABLE_WEB_SERVICE) if (ENABLE_WEB_SERVICE)
target_compile_definitions(citra-room PRIVATE -DENABLE_WEB_SERVICE) target_compile_definitions(citra-room PRIVATE -DENABLE_WEB_SERVICE)
target_link_libraries(citra-room PRIVATE web_service) target_link_libraries(citra-room PRIVATE web_service)
if (MSVC AND OPENSSL_DLL_DIR)
include(CopyCitraOpensslDeps)
copy_citra_openssl_deps(citra-room)
endif()
endif() endif()
target_link_libraries(citra-room PRIVATE cryptopp) target_link_libraries(citra-room PRIVATE cryptopp)