VERY experimental Nintendo Switch 2 emulator
C++
travis: Split build scripts for different platforms
MerryMageb66add01f88d
diff --git a/.travis-build.sh b/.travis-build.shdeleted file mode 100755index fc5a5f8b2a..0000000000--- a/.travis-build.sh+++ /dev/null@@ -1,59 +0,0 @@-#!/bin/bash--set -e-set -x--if grep -nr '\s$' src *.yml *.txt *.md Doxyfile .gitignore .gitmodules .travis* dist/*.desktop \- dist/*.svg dist/*.xml; then- echo Trailing whitespace found, aborting- exit 1-fi--# Only run clang-format on Linux because we don't have 4.0 on OS X images-if [ "$TRAVIS_OS_NAME" = "linux" ]; then- # Default clang-format points to default 3.5 version one- CLANG_FORMAT=clang-format-3.9- $CLANG_FORMAT --version-- if [ "$TRAVIS_EVENT_TYPE" = "pull_request" ]; then- # Get list of every file modified in this pull request- files_to_lint="$(git diff --name-only --diff-filter=ACMRTUXB $TRAVIS_COMMIT_RANGE | grep '^src/[^.]*[.]\(cpp\|h\)$' || true)"- else- # Check everything for branch pushes- files_to_lint="$(find src/ -name '*.cpp' -or -name '*.h')"- fi-- # Turn off tracing for this because it's too verbose- set +x-- for f in $files_to_lint; do- d=$(diff -u "$f" <($CLANG_FORMAT "$f") || true)- if ! [ -z "$d" ]; then- echo "!!! $f not compliant to coding style, here is the fix:"- echo "$d"- fail=1- fi- done-- set -x-- if [ "$fail" = 1 ]; then- exit 1- fi-fi--#if OS is linux or is not set-if [ "$TRAVIS_OS_NAME" = "linux" -o -z "$TRAVIS_OS_NAME" ]; then- docker run -v $(pwd):/citra ubuntu:16.04 /bin/bash /citra/.travis-build-docker.sh-elif [ "$TRAVIS_OS_NAME" = "osx" ]; then- set -o pipefail-- export MACOSX_DEPLOYMENT_TARGET=10.9- export Qt5_DIR=$(brew --prefix)/opt/qt5-- mkdir build && cd build- cmake .. -DUSE_SYSTEM_CURL=ON -DCMAKE_OSX_ARCHITECTURES="x86_64;x86_64h" -DCMAKE_BUILD_TYPE=Release- make -j4-- ctest -VV -C Release-fidiff --git a/.travis-deps.sh b/.travis-deps.shdeleted file mode 100755index 0cee68041b..0000000000--- a/.travis-deps.sh+++ /dev/null@@ -1,12 +0,0 @@-#!/bin/sh--set -e-set -x--#if OS is linux or is not set-if [ "$TRAVIS_OS_NAME" = "linux" -o -z "$TRAVIS_OS_NAME" ]; then- docker pull ubuntu:16.04-elif [ "$TRAVIS_OS_NAME" = "osx" ]; then- brew update- brew install qt5 sdl2 dylibbundler p7zip-fidiff --git a/.travis-upload.sh b/.travis-upload.shdeleted file mode 100755index edf195f7d5..0000000000--- a/.travis-upload.sh+++ /dev/null@@ -1,139 +0,0 @@-GITDATE="`git show -s --date=short --format='%ad' | sed 's/-//g'`"-GITREV="`git show -s --format='%h'`"-mkdir -p artifacts--if [ "$TRAVIS_OS_NAME" = "linux" -o -z "$TRAVIS_OS_NAME" ]; then- REV_NAME="citra-linux-${GITDATE}-${GITREV}"- ARCHIVE_NAME="${REV_NAME}.tar.xz"- COMPRESSION_FLAGS="-cJvf"- mkdir "$REV_NAME"-- cp build/src/citra/citra "$REV_NAME"- cp build/src/citra_qt/citra-qt "$REV_NAME"-elif [ "$TRAVIS_OS_NAME" = "osx" ]; then- REV_NAME="citra-osx-${GITDATE}-${GITREV}"- ARCHIVE_NAME="${REV_NAME}.tar.gz"- COMPRESSION_FLAGS="-czvf"- mkdir "$REV_NAME"-- cp build/src/citra/citra "$REV_NAME"- cp -r build/src/citra_qt/citra-qt.app "$REV_NAME"-- # move qt libs into app bundle for deployment- $(brew --prefix)/opt/qt5/bin/macdeployqt "${REV_NAME}/citra-qt.app"-- # move SDL2 libs into folder for deployment- dylibbundler -b -x "${REV_NAME}/citra" -cd -d "${REV_NAME}/libs" -p "@executable_path/libs/"-- # Make the changes to make the citra-qt app standalone (i.e. not dependent on the current brew installation).- # To do this, the absolute references to each and every QT framework must be re-written to point to the local frameworks- # (in the Contents/Frameworks folder).- # The "install_name_tool" is used to do so.-- # Coreutils is a hack to coerce Homebrew to point to the absolute Cellar path (symlink dereferenced). i.e:- # ls -l /usr/local/opt/qt5:: /usr/local/opt/qt5 -> ../Cellar/qt5/5.6.1-1- # grealpath ../Cellar/qt5/5.6.1-1:: /usr/local/Cellar/qt5/5.6.1-1- brew install coreutils-- REV_NAME_ALT=$REV_NAME/- # grealpath is located in coreutils, there is no "realpath" for OS X :(- QT_BREWS_PATH=$(grealpath "$(brew --prefix qt5)")- BREW_PATH=$(brew --prefix)- QT_VERSION_NUM=5-- $BREW_PATH/opt/qt5/bin/macdeployqt "${REV_NAME_ALT}citra-qt.app" \- -executable="${REV_NAME_ALT}citra-qt.app/Contents/MacOS/citra-qt"-- # These are the files that macdeployqt packed into Contents/Frameworks/ - we don't want those, so we replace them.- declare -a macos_libs=("QtCore" "QtWidgets" "QtGui" "QtOpenGL" "QtPrintSupport")-- for macos_lib in "${macos_libs[@]}"- do- SC_FRAMEWORK_PART=$macos_lib.framework/Versions/$QT_VERSION_NUM/$macos_lib- # Replace macdeployqt versions of the Frameworks with our own (from /usr/local/opt/qt5/lib/)- cp "$BREW_PATH/opt/qt5/lib/$SC_FRAMEWORK_PART" "${REV_NAME_ALT}citra-qt.app/Contents/Frameworks/$SC_FRAMEWORK_PART"-- # Replace references within the embedded Framework files with "internal" versions.- for macos_lib2 in "${macos_libs[@]}"- do- # Since brew references both the non-symlinked and symlink paths of QT5, it needs to be duplicated.- # /usr/local/Cellar/qt5/5.6.1-1/lib and /usr/local/opt/qt5/lib both resolve to the same files.- # So the two lines below are effectively duplicates when resolved as a path, but as strings, they aren't.- RM_FRAMEWORK_PART=$macos_lib2.framework/Versions/$QT_VERSION_NUM/$macos_lib2- install_name_tool -change \- $QT_BREWS_PATH/lib/$RM_FRAMEWORK_PART \- @executable_path/../Frameworks/$RM_FRAMEWORK_PART \- "${REV_NAME_ALT}citra-qt.app/Contents/Frameworks/$SC_FRAMEWORK_PART"- install_name_tool -change \- "$BREW_PATH/opt/qt5/lib/$RM_FRAMEWORK_PART" \- @executable_path/../Frameworks/$RM_FRAMEWORK_PART \- "${REV_NAME_ALT}citra-qt.app/Contents/Frameworks/$SC_FRAMEWORK_PART"- done- done-- # Handles `This application failed to start because it could not find or load the Qt platform plugin "cocoa"`- # Which manifests itself as:- # "Exception Type: EXC_CRASH (SIGABRT) | Exception Codes: 0x0000000000000000, 0x0000000000000000 | Exception Note: EXC_CORPSE_NOTIFY"- # There may be more dylibs needed to be fixed...- declare -a macos_plugins=("Plugins/platforms/libqcocoa.dylib")-- for macos_lib in "${macos_plugins[@]}"- do- install_name_tool -id @executable_path/../$macos_lib "${REV_NAME_ALT}citra-qt.app/Contents/$macos_lib"- for macos_lib2 in "${macos_libs[@]}"- do- RM_FRAMEWORK_PART=$macos_lib2.framework/Versions/$QT_VERSION_NUM/$macos_lib2- install_name_tool -change \- $QT_BREWS_PATH/lib/$RM_FRAMEWORK_PART \- @executable_path/../Frameworks/$RM_FRAMEWORK_PART \- "${REV_NAME_ALT}citra-qt.app/Contents/$macos_lib"- install_name_tool -change \- "$BREW_PATH/opt/qt5/lib/$RM_FRAMEWORK_PART" \- @executable_path/../Frameworks/$RM_FRAMEWORK_PART \- "${REV_NAME_ALT}citra-qt.app/Contents/$macos_lib"- done- done-- for macos_lib in "${macos_libs[@]}"- do- # Debugging info for Travis-CI- otool -L "${REV_NAME_ALT}citra-qt.app/Contents/Frameworks/$macos_lib.framework/Versions/$QT_VERSION_NUM/$macos_lib"- done-- # Make the citra-qt.app application launch a debugging terminal.- # Store away the actual binary- mv ${REV_NAME_ALT}citra-qt.app/Contents/MacOS/citra-qt ${REV_NAME_ALT}citra-qt.app/Contents/MacOS/citra-qt-bin-- cat > ${REV_NAME_ALT}citra-qt.app/Contents/MacOS/citra-qt <<EOL-#!/usr/bin/env bash-cd "\`dirname "\$0"\`"-chmod +x citra-qt-bin-open citra-qt-bin --args "\$@"-EOL- # Content that will serve as the launching script for citra (within the .app folder)-- # Make the launching script executable- chmod +x ${REV_NAME_ALT}citra-qt.app/Contents/MacOS/citra-qt--fi--# Copy documentation-cp license.txt "$REV_NAME"-cp README.md "$REV_NAME"--tar $COMPRESSION_FLAGS "$ARCHIVE_NAME" "$REV_NAME"--# Find out what release we are building-if [ -z $TRAVIS_TAG ]; then- RELEASE_NAME=head-else- RELEASE_NAME=$(echo $TRAVIS_TAG | cut -d- -f1)-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/diff --git a/.travis.yml b/.travis.ymlindex b92d7f2362..8bad23208a 100644--- a/.travis.yml+++ b/.travis.yml@@ -2,24 +2,32 @@ language: cppmatrix:include:- os: linux+ env: NAME="linux build"sudo: requireddist: trusty+ services: docker+ addons:+ apt:+ packages:+ - p7zip-full+ install: "./.travis/linux/deps.sh"+ script: "./.travis/linux/build.sh"+ after_success: "./.travis/linux/upload.sh"- os: osx+ env: NAME="macos build"sudo: falseosx_image: xcode7.3--services:- - docker--addons:- apt:- packages:- - clang-format-3.9- - p7zip-full--install: "./.travis-deps.sh"-script: "./.travis-build.sh"-after_success: "./.travis-upload.sh"+ install: "./.travis/macos/deps.sh"+ script: "./.travis/macos/build.sh"+ after_success: "./.travis/macos/upload.sh"+ - os: linux+ env: NAME="clang-format"+ dist: trusty+ addons:+ apt:+ packages:+ - clang-format-3.9+ script: "./.travis/clang-format/script.sh"deploy:provider: releasesdiff --git a/.travis/clang-format/script.sh b/.travis/clang-format/script.shnew file mode 100755index 0000000000..80a0f47e52--- /dev/null+++ b/.travis/clang-format/script.sh@@ -0,0 +1,37 @@+#!/bin/bash -ex++if grep -nr '\s$' src *.yml *.txt *.md Doxyfile .gitignore .gitmodules .travis* dist/*.desktop \+ dist/*.svg dist/*.xml; then+ echo Trailing whitespace found, aborting+ exit 1+fi++# Default clang-format points to default 3.5 version one+CLANG_FORMAT=clang-format-3.9+$CLANG_FORMAT --version++if [ "$TRAVIS_EVENT_TYPE" = "pull_request" ]; then+ # Get list of every file modified in this pull request+ files_to_lint="$(git diff --name-only --diff-filter=ACMRTUXB $TRAVIS_COMMIT_RANGE | grep '^src/[^.]*[.]\(cpp\|h\)$' || true)"+else+ # Check everything for branch pushes+ files_to_lint="$(find src/ -name '*.cpp' -or -name '*.h')"+fi++# Turn off tracing for this because it's too verbose+set +x++for f in $files_to_lint; do+ d=$(diff -u "$f" <($CLANG_FORMAT "$f") || true)+ if ! [ -z "$d" ]; then+ echo "!!! $f not compliant to coding style, here is the fix:"+ echo "$d"+ fail=1+ fi+done++set -x++if [ "$fail" = 1 ]; then+ exit 1+fidiff --git a/.travis/common/post-upload.sh b/.travis/common/post-upload.shnew file mode 100755index 0000000000..90deaaec8f--- /dev/null+++ b/.travis/common/post-upload.sh@@ -0,0 +1,22 @@+#!/bin/bash -ex++# Copy documentation+cp license.txt "$REV_NAME"+cp README.md "$REV_NAME"++tar $COMPRESSION_FLAGS "$ARCHIVE_NAME" "$REV_NAME"++# Find out what release we are building+if [ -z $TRAVIS_TAG ]; then+ RELEASE_NAME=head+else+ RELEASE_NAME=$(echo $TRAVIS_TAG | cut -d- -f1)+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/diff --git a/.travis/common/pre-upload.sh b/.travis/common/pre-upload.shnew file mode 100755index 0000000000..3c2fc79a2c--- /dev/null+++ b/.travis/common/pre-upload.sh@@ -0,0 +1,6 @@+#!/bin/bash -ex++GITDATE="`git show -s --date=short --format='%ad' | sed 's/-//g'`"+GITREV="`git show -s --format='%h'`"++mkdir -p artifactsdiff --git a/.travis/linux/build.sh b/.travis/linux/build.shnew file mode 100755index 0000000000..98433d1845--- /dev/null+++ b/.travis/linux/build.sh@@ -0,0 +1,3 @@+#!/bin/bash -ex++docker run -v $(pwd):/citra ubuntu:16.04 /bin/bash /citra/.travis/linux/docker.shdiff --git a/.travis/linux/deps.sh b/.travis/linux/deps.shnew file mode 100755index 0000000000..be3f6bece4--- /dev/null+++ b/.travis/linux/deps.sh@@ -0,0 +1,3 @@+#!/bin/sh -ex++docker pull ubuntu:16.04diff --git a/.travis-build-docker.sh b/.travis/linux/docker.shold mode 100644new mode 100755similarity index 94%rename from .travis-build-docker.shrename to .travis/linux/docker.shindex 01249ace00..e27af5600c--- a/.travis-build-docker.sh+++ b/.travis/linux/docker.sh@@ -1,7 +1,4 @@-#!/bin/sh--set -e-set -x+#!/bin/bash -excd /citradiff --git a/.travis/linux/upload.sh b/.travis/linux/upload.shnew file mode 100755index 0000000000..dd265e0fd5--- /dev/null+++ b/.travis/linux/upload.sh@@ -0,0 +1,14 @@+#!/bin/bash -ex++. .travis/common/pre-upload.sh++REV_NAME="citra-linux-${GITDATE}-${GITREV}"+ARCHIVE_NAME="${REV_NAME}.tar.xz"+COMPRESSION_FLAGS="-cJvf"++mkdir "$REV_NAME"++cp build/src/citra/citra "$REV_NAME"+cp build/src/citra_qt/citra-qt "$REV_NAME"++. .travis/common/post-upload.shdiff --git a/.travis/macos/build.sh b/.travis/macos/build.shnew file mode 100755index 0000000000..c957cdf21b--- /dev/null+++ b/.travis/macos/build.sh@@ -0,0 +1,12 @@+#!/bin/bash -ex++set -o pipefail++export MACOSX_DEPLOYMENT_TARGET=10.9+export Qt5_DIR=$(brew --prefix)/opt/qt5++mkdir build && cd build+cmake .. -DUSE_SYSTEM_CURL=ON -DCMAKE_OSX_ARCHITECTURES="x86_64;x86_64h" -DCMAKE_BUILD_TYPE=Release+make -j4++ctest -VV -C Releasediff --git a/.travis/macos/deps.sh b/.travis/macos/deps.shnew file mode 100755index 0000000000..30ec99b620--- /dev/null+++ b/.travis/macos/deps.sh@@ -0,0 +1,4 @@+#!/bin/sh -ex++brew update+brew install qt5 sdl2 dylibbundler p7zipdiff --git a/.travis/macos/upload.sh b/.travis/macos/upload.shnew file mode 100755index 0000000000..19c80fdf0a--- /dev/null+++ b/.travis/macos/upload.sh@@ -0,0 +1,110 @@+#!/bin/bash -ex++. .travis/common/pre-upload.sh++REV_NAME="citra-osx-${GITDATE}-${GITREV}"+ARCHIVE_NAME="${REV_NAME}.tar.gz"+COMPRESSION_FLAGS="-czvf"++mkdir "$REV_NAME"++cp build/src/citra/citra "$REV_NAME"+cp -r build/src/citra_qt/citra-qt.app "$REV_NAME"++# move qt libs into app bundle for deployment+$(brew --prefix)/opt/qt5/bin/macdeployqt "${REV_NAME}/citra-qt.app"++# move SDL2 libs into folder for deployment+dylibbundler -b -x "${REV_NAME}/citra" -cd -d "${REV_NAME}/libs" -p "@executable_path/libs/"++# Make the changes to make the citra-qt app standalone (i.e. not dependent on the current brew installation).+# To do this, the absolute references to each and every QT framework must be re-written to point to the local frameworks+# (in the Contents/Frameworks folder).+# The "install_name_tool" is used to do so.++# Coreutils is a hack to coerce Homebrew to point to the absolute Cellar path (symlink dereferenced). i.e:+# ls -l /usr/local/opt/qt5:: /usr/local/opt/qt5 -> ../Cellar/qt5/5.6.1-1+# grealpath ../Cellar/qt5/5.6.1-1:: /usr/local/Cellar/qt5/5.6.1-1+brew install coreutils || brew upgrade coreutils || true++REV_NAME_ALT=$REV_NAME/+# grealpath is located in coreutils, there is no "realpath" for OS X :(+QT_BREWS_PATH=$(grealpath "$(brew --prefix qt5)")+BREW_PATH=$(brew --prefix)+QT_VERSION_NUM=5++$BREW_PATH/opt/qt5/bin/macdeployqt "${REV_NAME_ALT}citra-qt.app" \+ -executable="${REV_NAME_ALT}citra-qt.app/Contents/MacOS/citra-qt"++# These are the files that macdeployqt packed into Contents/Frameworks/ - we don't want those, so we replace them.+declare -a macos_libs=("QtCore" "QtWidgets" "QtGui" "QtOpenGL" "QtPrintSupport")++for macos_lib in "${macos_libs[@]}"+do+ SC_FRAMEWORK_PART=$macos_lib.framework/Versions/$QT_VERSION_NUM/$macos_lib+ # Replace macdeployqt versions of the Frameworks with our own (from /usr/local/opt/qt5/lib/)+ cp "$BREW_PATH/opt/qt5/lib/$SC_FRAMEWORK_PART" "${REV_NAME_ALT}citra-qt.app/Contents/Frameworks/$SC_FRAMEWORK_PART"++ # Replace references within the embedded Framework files with "internal" versions.+ for macos_lib2 in "${macos_libs[@]}"+ do+ # Since brew references both the non-symlinked and symlink paths of QT5, it needs to be duplicated.+ # /usr/local/Cellar/qt5/5.6.1-1/lib and /usr/local/opt/qt5/lib both resolve to the same files.+ # So the two lines below are effectively duplicates when resolved as a path, but as strings, they aren't.+ RM_FRAMEWORK_PART=$macos_lib2.framework/Versions/$QT_VERSION_NUM/$macos_lib2+ install_name_tool -change \+ $QT_BREWS_PATH/lib/$RM_FRAMEWORK_PART \+ @executable_path/../Frameworks/$RM_FRAMEWORK_PART \+ "${REV_NAME_ALT}citra-qt.app/Contents/Frameworks/$SC_FRAMEWORK_PART"+ install_name_tool -change \+ "$BREW_PATH/opt/qt5/lib/$RM_FRAMEWORK_PART" \+ @executable_path/../Frameworks/$RM_FRAMEWORK_PART \+ "${REV_NAME_ALT}citra-qt.app/Contents/Frameworks/$SC_FRAMEWORK_PART"+ done+done++# Handles `This application failed to start because it could not find or load the Qt platform plugin "cocoa"`+# Which manifests itself as:+# "Exception Type: EXC_CRASH (SIGABRT) | Exception Codes: 0x0000000000000000, 0x0000000000000000 | Exception Note: EXC_CORPSE_NOTIFY"+# There may be more dylibs needed to be fixed...+declare -a macos_plugins=("Plugins/platforms/libqcocoa.dylib")++for macos_lib in "${macos_plugins[@]}"+do+ install_name_tool -id @executable_path/../$macos_lib "${REV_NAME_ALT}citra-qt.app/Contents/$macos_lib"+ for macos_lib2 in "${macos_libs[@]}"+ do+ RM_FRAMEWORK_PART=$macos_lib2.framework/Versions/$QT_VERSION_NUM/$macos_lib2+ install_name_tool -change \+ $QT_BREWS_PATH/lib/$RM_FRAMEWORK_PART \+ @executable_path/../Frameworks/$RM_FRAMEWORK_PART \+ "${REV_NAME_ALT}citra-qt.app/Contents/$macos_lib"+ install_name_tool -change \+ "$BREW_PATH/opt/qt5/lib/$RM_FRAMEWORK_PART" \+ @executable_path/../Frameworks/$RM_FRAMEWORK_PART \+ "${REV_NAME_ALT}citra-qt.app/Contents/$macos_lib"+ done+done++for macos_lib in "${macos_libs[@]}"+do+ # Debugging info for Travis-CI+ otool -L "${REV_NAME_ALT}citra-qt.app/Contents/Frameworks/$macos_lib.framework/Versions/$QT_VERSION_NUM/$macos_lib"+done++# Make the citra-qt.app application launch a debugging terminal.+# Store away the actual binary+mv ${REV_NAME_ALT}citra-qt.app/Contents/MacOS/citra-qt ${REV_NAME_ALT}citra-qt.app/Contents/MacOS/citra-qt-bin++cat > ${REV_NAME_ALT}citra-qt.app/Contents/MacOS/citra-qt <<EOL+#!/usr/bin/env bash+cd "\`dirname "\$0"\`"+chmod +x citra-qt-bin+open citra-qt-bin --args "\$@"+EOL+# Content that will serve as the launching script for citra (within the .app folder)++# Make the launching script executable+chmod +x ${REV_NAME_ALT}citra-qt.app/Contents/MacOS/citra-qt++. .travis/common/post-upload.sh