Fix switch hacks (#4530)

This commit is contained in:
Dave Murphy 2021-05-14 16:45:52 +01:00 committed by GitHub
parent 08a97f7ae5
commit f938ef38b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 20 additions and 130 deletions

View File

@ -16,46 +16,22 @@ jobs:
container:
image: 'devkitpro/devkita64'
steps:
- name: Install git
run: |
echo "deb http://ftp.debian.org/debian stretch-backports main" | sudo tee /etc/apt/sources.list.d/stretch-backports.list
sudo apt update
sudo apt install -t stretch-backports git -y
- name: Checkout code
uses: actions/checkout@v2
with:
# We need 0 so we get all commits for mtime!
fetch-depth: 0
path: "./stk-code"
- name: Checkout OpenAL
uses: actions/checkout@v2
with:
fetch-depth: 0
path: "./stk-code/lib/openal"
repository: "kcat/openal-soft"
- name: Checkout Harfbuzz
uses: actions/checkout@v2
with:
fetch-depth: 0
path: "./stk-code/lib/harfbuzz"
repository: "harfbuzz/harfbuzz"
- name: Grab assets
run: |
sudo apt update
sudo apt install unzip zip -y
wget -q https://github.com/supertuxkart/stk-assets-mobile/releases/download/git/stk-assets-full.zip
unzip -q stk-assets-full.zip -d stk-assets
rm stk-assets-full.zip
- name: Restore modified date
run: |
sudo apt install -y git-restore-mtime
cd stk-code
git restore-mtime .
cd lib/openal
git restore-mtime .
cd ../../lib/harfbuzz
git restore-mtime .
cd ../../..
cd ..
# Env setup!
- name: Configure packaging name for git master branch
@ -108,8 +84,6 @@ jobs:
stk-code/cmake_build/*.cmake
stk-code/cmake_build/*.txt
stk-code/lib/openal/cmake_build
stk-code/lib/harfbuzz/cmake_build
# Make sure PRs can't overwrite!
key: switch-${{ github.ref }}-${{ github.run_number }}
restore-keys: |
@ -124,7 +98,6 @@ jobs:
${{ env.cache_9 }}
- name: Run build script
run: |
cp -v stk-code/switch/pkgbuild-scripts/* "$DEVKITPRO/"
cd stk-code/switch
PROJECT_VERSION="${{ env.release_tag }}" ./make.sh
- name: Create release

View File

@ -19,7 +19,11 @@ if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "STKRelease")
endif()
option(USE_SWITCH "Build targetting switch" OFF)
option(USE_SWITCH "Build targeting switch" OFF)
if(NINTENDO_SWITCH)
set(USE_SWITCH ON)
endif()
if(WIN32)
option(USE_DIRECTX "Build DirectX 9 driver (requires DirectX SDK)" OFF)
@ -44,6 +48,10 @@ CMAKE_DEPENDENT_OPTION(USE_WIIUSE "Support for wiimote input devices" ON
"NOT SERVER_ONLY;NOT CYGWIN;NOT USE_SWITCH;NOT MSVC" OFF)
CMAKE_DEPENDENT_OPTION(USE_DNS_C "Build bundled dns resolver" OFF "NOT CYGWIN;NOT USE_SWITCH" ON)
if((UNIX AND NOT APPLE) OR NINTENDO_SWITCH)
include(FindPkgConfig)
endif()
if(APPLE AND NOT IOS)
if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "arm")
set(ARCHFLAGS "arm64")
@ -378,13 +386,7 @@ if (NOT SERVER_ONLY)
SET(SHEENBIDI_LIBRARY sheenbidi)
# Freetype
if (USE_SWITCH)
SET(FREETYPE_INCLUDE_DIRS /opt/devkitpro/portlibs/switch/include/freetype2)
find_library(FREETYPE_LIBRARIES freetype libfreetype REQUIRED)
SET(FREETYPE_FOUND YES)
else()
find_package(Freetype)
endif()
find_package(Freetype)
if(FREETYPE_FOUND)
include_directories(${FREETYPE_INCLUDE_DIRS})
else()

View File

@ -20,10 +20,7 @@ elseif(APPLE)
include_directories(/Library/Frameworks/FreeType.Framework/Versions/2.4/unix/include)
set(FREETYPE_FOUND 1)
set(FREETYPE_LIBRARIES ${FREETYPE_LIBRARY})
elseif(UNIX)
include(FindPkgConfig)
pkg_check_modules(FREETYPE freetype2)
else()
set(FREETYPE_FOUND 0)
pkg_check_modules(FREETYPE freetype2)
endif()

View File

@ -10,6 +10,10 @@
# OggVorbis library list
if((UNIX AND NOT APPLE) OR NINTENDO_SWITCH)
pkg_check_modules(OGGVORBIS vorbisfile)
else()
find_path(OGGVORBIS_OGG_INCLUDE_DIR NAMES ogg/ogg.h PATHS "${PROJECT_SOURCE_DIR}/${DEPENDENCIES}/include")
find_path(OGGVORBIS_VORBIS_INCLUDE_DIR NAMES vorbis/vorbisfile.h PATHS "${PROJECT_SOURCE_DIR}/${DEPENDENCIES}/include")
find_library(OGGVORBIS_OGG_LIBRARY NAMES ogg Ogg libogg PATHS "${PROJECT_SOURCE_DIR}/${DEPENDENCIES}/lib")
@ -30,3 +34,4 @@ list(REMOVE_DUPLICATES OGGVORBIS_INCLUDE_DIRS)
list(REMOVE_DUPLICATES OGGVORBIS_LIBRARIES)
mark_as_advanced(OGGVORBIS_OGG_INCLUDE_DIR OGGVORBIS_VORBIS_INCLUDE_DIR)
mark_as_advanced(OGGVORBIS_OGG_LIBRARY OGGVORBIS_VORBIS_LIBRARY OGGVORBIS_VORBISFILE_LIBRARY OGGVORBIS_VORBISENC_LIBRARY)
endif()

View File

@ -2,92 +2,9 @@
OLD_PWD="$(pwd)"
# Mac can prefix tool names with 'dkp-'
if which dkp-pacman &>/dev/null; then
PACMAN=dkp-pacman
elif which pacman &>/dev/null; then
PACMAN=pacman
else
echo "Couldn't find pacman in PATH! Is it installed?"
echo "Please see https://devkitpro.org/wiki/devkitPro_pacman#Installing_devkitPro_Pacman for instructions to install it!"
exit 1
fi
# GH Actions adds manually (hack!)
OPTIONAL=""
if [ ! -f "$DEVKITPRO/switch.cmake" ]; then
echo "pkgbuild-helpers not installed!"
OPTIONAL="devkitpro-pkgbuild-helpers"
fi
# Install deps. --needed means don't reinstall if already installed
sudo $PACMAN -S --needed \
devkit-env \
devkitA64 \
general-tools \
\
$OPTIONAL \
switch-curl switch-mbedtls \
switch-freetype switch-libfribidi \
switch-libogg switch-libvorbis \
switch-libjpeg-turbo switch-libpng \
switch-zlib switch-bzip2 \
switch-physfs \
switch-pkg-config \
switch-sdl2 switch-mesa switch-libdrm_nouveau \
libnx \
switch-tools # elf2nro
# Users of MSYS2 or Arch Linux will already have Pacman installed but may not have the DKP repos on their system:
if [ $? -ne 0 ]; then
echo "Failed to install packages! Did you add the repositories?"
echo "Please see https://devkitpro.org/wiki/devkitPro_pacman#Customising_Existing_Pacman_Install for instructions!"
exit 1
fi
# Unclear why this isn't in lib path
if [ ! -f "${DEVKITPRO}/portlibs/switch/lib/libpthread.a" ]; then
sudo ln -s "${DEVKITPRO}/devkitA64/aarch64-none-elf/lib/libpthread.a" \
"${DEVKITPRO}/portlibs/switch/lib/libpthread.a"
fi
SWITCH_DIR=$(realpath "$(dirname "$0")")
STK_DIR=$(dirname "${SWITCH_DIR}")
# Some shells don't set BASH_SOURCE. Let's set it just in case:
BASH_SOURCE="${DEVKITPRO}/switchvars.sh"
source "${DEVKITPRO}/switchvars.sh" # Sets environment variables needed for cross-compiling
if [ ! -d "${STK_DIR}/lib/harfbuzz/cmake_build" ]; then
# Harfbuzz
echo "Compiling Harfbuzz"
mkdir "${STK_DIR}/lib/harfbuzz/cmake_build"
cd "${STK_DIR}/lib/harfbuzz/cmake_build"
cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE="${DEVKITPRO}/switch.cmake" \
-DUSE_SWITCH=ON -DCMAKE_INSTALL_PREFIX="$(pwd)/install" \
-DHB_HAVE_FREETYPE=ON \
../
make -j$(nproc)
make install
fi
if [ ! -d "${STK_DIR}/lib/openal/cmake_build" ]; then
# OpenAL
echo "Compiling OpenAL"
mkdir "${STK_DIR}/lib/openal/cmake_build"
cd "${STK_DIR}/lib/openal/cmake_build"
cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE="${DEVKITPRO}/switch.cmake" \
-DUSE_SWITCH=ON -DALSOFT_UTILS=OFF -DLIBTYPE=STATIC -DALSOFT_EXAMPLES=OFF \
-DALSOFT_REQUIRE_SDL2=ON -DALSOFT_BACKEND_SDL2=ON \
-DSDL2_INCLUDE_DIR="${PORTLIBS_PREFIX}/include" \
-DCMAKE_INSTALL_PREFIX="$(pwd)/install" \
../
make -j$(nproc)
make install
fi
echo "Compiling STK"
if [[ ! -d "${STK_DIR}/cmake_build" ]]; then
@ -95,17 +12,13 @@ if [[ ! -d "${STK_DIR}/cmake_build" ]]; then
fi
cd "${STK_DIR}/cmake_build"
cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE="${DEVKITPRO}/switch.cmake" \
"${DEVKITPRO}/portlibs/switch/bin/aarch64-none-elf-cmake" -G"Unix Makefiles" \
-DUSE_SWITCH=ON \
-DOPENAL_LIBRARY="${STK_DIR}/lib/openal/cmake_build/install/lib/libopenal.a" \
-DOPENAL_INCLUDE_DIR="${STK_DIR}/lib/openal/cmake_build/install/include" \
-DHARFBUZZ_LIBRARY="${STK_DIR}/lib/harfbuzz/cmake_build/install/lib/libharfbuzz.a" \
-DHARFBUZZ_INCLUDEDIR="${STK_DIR}/lib/harfbuzz/cmake_build/install/include" \
-DCMAKE_INSTALL_PREFIX=/ \
../
make -j$(nproc)
make install DESTDIR=./install
make -j$(nproc) || exit 1
make install DESTDIR=./install || exit 1
# Build nro (executable for switch)
"${SWITCH_DIR}/package.sh"