From 143a82b543421455eb8ad22c015bcbd52c4a16b6 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Sun, 23 May 2021 16:08:57 +1000 Subject: [PATCH] scripts: Add libretro core build scripts --- scripts/build_libretro_cores.bat | 31 +++++++++++++++++++++++++ scripts/build_libretro_cores.sh | 39 ++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 scripts/build_libretro_cores.bat create mode 100755 scripts/build_libretro_cores.sh diff --git a/scripts/build_libretro_cores.bat b/scripts/build_libretro_cores.bat new file mode 100644 index 000000000..4a38e025b --- /dev/null +++ b/scripts/build_libretro_cores.bat @@ -0,0 +1,31 @@ +@echo off +echo Updating SCM version... +pushd %~dp0 +cd ..\src\scmversion +start /w gen_scmversion.bat +popd + +echo Setting MSVC environment... +call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" x64 + +echo Creating build directory... +pushd %~dp0 +cd .. +if not exist build-libretro mkdir build-libretro +cd build-libretro +del /q duckstation_libretro_windows_x64.zip +rmdir /Q /S windows_x64 +mkdir windows_x64 +cd windows_x64 + +echo Running CMake... +cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_LIBRETRO_CORE=ON -DCMAKE_C_COMPILER:FILEPATH="%VCToolsInstallDir%\bin\HostX64\x64\cl.exe" -DCMAKE_CXX_COMPILER:FILEPATH="%VCToolsInstallDir%\bin\HostX64\x64\cl.exe" ..\.. + +echo Building... +ninja +if %errorlevel% neq 0 exit /b %errorlevel% + +echo Zipping... +"C:\Program Files\7-Zip\7z.exe" a ../duckstation_libretro_windows_x64.zip ./duckstation_libretro.dll + +echo All done. diff --git a/scripts/build_libretro_cores.sh b/scripts/build_libretro_cores.sh new file mode 100755 index 000000000..977e0dd9d --- /dev/null +++ b/scripts/build_libretro_cores.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash +SCRIPTDIR=$(dirname $(realpath "${BASH_SOURCE[0]}")) +ROOTDIR=$SCRIPTDIR/.. +BUILDDIR=$SCRIPTDIR/../build-libretro +set -e + +make_build() { + PLATFORM=$1 + OPTIONS=$2 + SUFFIX=$3 + + echo Building for ${PLATFORM}... + + cd $BUILDDIR + + rm -fr $PLATFORM + mkdir -p $PLATFORM + cd $PLATFORM + cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_LIBRETRO_CORE=ON $OPTIONS $ROOTDIR + + ninja + rm -f ../duckstation_${PLATFORM}.zip + zip -j ../duckstation_${PLATFORM}.zip duckstation_libretro${SUFFIX}.so + cd .. +} + +echo Creating build directory... +mkdir -p $BUILDDIR +cd $BUILDDIR || exit $? +rm -f duckstation_libretro_android_aarch64.zip duckstation_libretro_android_armv7.zip duckstation_libretro_linux_x64.zip duckstation_libretro_linux_aarch64.zip duckstation_libretro_linux_armv7.zip + +echo Building... +make_build linux_x64 "" "" +make_build linux_aarch64 "-DCMAKE_TOOLCHAIN_FILE=$ROOTDIR/CMakeModules/aarch64-cross-toolchain.cmake" "" +make_build linux_armv7 "-DCMAKE_TOOLCHAIN_FILE=$ROOTDIR/CMakeModules/armv7-cross-toolchain.cmake" "" + +make_build android_aarch64 "-DANDROID_ABI=arm64-v8a -DCMAKE_TOOLCHAIN_FILE=/home/user/Android/ndk-bundle/build/cmake/android.toolchain.cmake" "_android" +make_build android_armv7 "-DANDROID_ABI=armeabi-v7a -DANDROID_ARM_NEON=ON -DCMAKE_TOOLCHAIN_FILE=/home/user/Android/ndk-bundle/build/cmake/android.toolchain.cmake" "_android" +