Add Nintendo Switch chiaki-lib support (#233)

This commit is contained in:
H0neyBadger 2020-05-15 11:06:54 +02:00 committed by GitHub
commit f35311bf61
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 771 additions and 20 deletions

81
scripts/switch/Dockerfile Normal file
View file

@ -0,0 +1,81 @@
FROM docker.io/archlinux/base
ENV DEVKITPRO=/opt/devkitpro
ENV DEVKITARM=/opt/devkitpro/devkitARM
ENV DEVKITPPC=/opt/devkitpro/devkitPPC
ENV PATH="${PATH}:${DEVKITARM}/bin/:${DEVKITPPC}/bin/"
ENV WORKDIR="/build"
WORKDIR "${WORKDIR}"
# Upgarde image
RUN pacman --noconfirm -Syu
# Install requirements for libtransistor
RUN pacman --noconfirm -S \
llvm \
clang \
lld \
python \
python-pip \
python-virtualenv \
squashfs-tools \
base-devel \
git \
cmake \
libx11 \
vim
RUN pacman-key --init
# Install devkitpro
# doc source :
# https://devkitpro.org/wiki/devkitPro_pacman
# First import the key which is used to validate the packages
RUN pacman-key --recv F7FD5492264BB9D0
RUN pacman-key --lsign F7FD5492264BB9D0
# Add the devkitPro repositories
ADD devkit_repo ./devkit_repo
RUN cat ./devkit_repo >> /etc/pacman.conf
# Install the keyring which adds more keys which may be used to verify the packages.
RUN pacman --noconfirm -U https://downloads.devkitpro.org/devkitpro-keyring-r1.787e015-2-any.pkg.tar.xz
# Now resync the database and update installed packages.
RUN pacman -Sy
RUN pacman --noconfirm -Syu
#RUN pacman --noconfirm -S $(pacman -Slq dkp-libs)
RUN pacman --noconfirm -S \
protobuf \
python-protobuf \
sfml \
devkitARM \
switch-pkg-config \
devkitpro-pkgbuild-helpers \
switch-dev \
switch-zlib \
switch-sdl2 \
switch-freetype \
switch-curl \
switch-mesa \
switch-glad \
switch-glm \
switch-libconfig \
switch-sdl2_gfx \
switch-sdl2_ttf \
switch-sdl2_image \
switch-libexpat \
switch-bzip2 \
switch-libopus \
switch-ffmpeg \
switch-mbedtls
RUN pip3 install -U pip
VOLUME ${WORKDIR}
# nxlink server port
EXPOSE 28771
ENTRYPOINT ["/bin/bash"]

42
scripts/switch/build.sh Executable file
View file

@ -0,0 +1,42 @@
#!/bin/bash
set -xveo pipefail
arg1=$1
CHIAKI_ENABLE_SWITCH_LINUX="ON"
build="./build"
if [ "$arg1" != "linux" ]; then
CHIAKI_ENABLE_SWITCH_LINUX="OFF"
source /opt/devkitpro/switchvars.sh
toolchain=/opt/devkitpro/switch.cmake
export CC=${TOOL_PREFIX}gcc
export CXX=${TOOL_PREFIX}g++
build="./build_switch"
fi
SCRIPTDIR=$(dirname "$0")
BASEDIR=$(realpath "${SCRIPTDIR}/../../")
build_chiaki (){
pushd "${BASEDIR}"
#rm -rf ./build
cmake -B "${build}" -DCMAKE_TOOLCHAIN_FILE=${toolchain} \
-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \
-DCHIAKI_ENABLE_TESTS=OFF \
-DCHIAKI_ENABLE_CLI=OFF \
-DCHIAKI_ENABLE_GUI=OFF \
-DCHIAKI_ENABLE_ANDROID=OFF \
-DCHIAKI_ENABLE_SWITCH=ON \
-DCHIAKI_ENABLE_SWITCH_LINUX="${CHIAKI_ENABLE_SWITCH_LINUX}" \
-DCHIAKI_LIB_ENABLE_MBEDTLS=ON
pushd "${BASEDIR}/${build}/switch/"
make
popd
popd
}
build_chiaki

View file

@ -0,0 +1,6 @@
[dkp-libs]
Server = http://downloads.devkitpro.org/packages
[dkp-linux]
Server = http://downloads.devkitpro.org/packages/linux

View file

@ -0,0 +1,31 @@
# simple python3 http server to emulate ctest.nintendo.net
# you have to redirect nintendo.net to your own host
# https://gitlab.com/a/90dns
# the aim is to fake ctest.nintendo.net server
# to allow nintendo switch lan connection
# The nintendo switch tries to join ctest to validate wifi settings
# without 200 OK from ctest.nintendo.net, the LAN connection is denied
import http.server
import socketserver
from http.server import HTTPServer, BaseHTTPRequestHandler
class SimpleHTTPRequestHandler(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.send_header("Content-Type", "text/plain")
self.send_header("X-Organization", "Nintendo")
self.end_headers()
self.wfile.write(b'ok')
PORT = 80
httpd = HTTPServer(('0.0.0.0', PORT), SimpleHTTPRequestHandler)
httpd.serve_forever()