Skip to content

Commit

Permalink
Merge pull request #1758 from zoltanvb/cmake-build
Browse files Browse the repository at this point in the history
Cmake option for building with libretro-build.sh
  • Loading branch information
fpscan authored Oct 8, 2023
2 parents 76d2ae1 + 5f082fa commit 96ffa26
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 8 deletions.
67 changes: 67 additions & 0 deletions libretro-build-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,53 @@ build_makefile() {
fi
}

# build_cmake
#
# $core_build_subdir Subdir of the makefile (if any)
# $core_build_args Extra arguments to cmake
# $core_build_extradir Location of the binary under build/
# $core_build_cores A list of cores produced by the builds
build_cmake() {
[ -n "$core_build_subdir" ] && core_build_subdir="/$core_build_subdir"

make_cmdline="cmake"

build_dir="$WORKDIR/$core_dir$core_build_subdir"

if build_should_skip $1 "$build_dir"; then
echo "Core $1 is already built, skipping..."
return
fi


if [ -d "$build_dir" ]; then
echo_cmd "cd \"$build_dir\""

$core_build_configure

if [ -z "$NOCLEAN" ]; then
$core_build_preclean
echo_cmd "$make_cmdline --build build --target clean"
fi
make_cmdline1="$make_cmdline $core_build_args . -Bbuild"
make_cmdline2="$make_cmdline --build build/ --target $core_cmake_target --config Release -- "
[ -n "$JOBS" ] && make_cmdline2="$make_cmdline2 -j$JOBS"
[ -n "$DEBUG" ] && make_cmdline2="$make_cmdline2 DEBUG=$DEBUG"

$core_build_prebuild
echo_cmd "$make_cmdline1"
echo_cmd "$make_cmdline2"

# TODO: Make this a separate stage/package rule
$core_build_prepkg
for a in $core_build_cores; do
copy_core_to_dist ${core_build_products:+$core_build_products/}build/${core_build_extradir:-}$a $a
done
else
echo "$1 not fetched, skipping ..."
fi
}


# libretro_build_core: Build the given core using its build rules
#
Expand Down Expand Up @@ -310,6 +357,26 @@ libretro_build_core() {
build_makefile $1 2>&1
;;

cmake)
# As of right now, only configure is used for now...
if [ "$(type -t libretro_${1}_configure 2> /dev/null)" = "function" ]; then
eval "core_configure=libretro_${1}_configure"
else
eval "core_configure=do_nothing"
fi
eval "core_build_subdir=\$libretro_${1}_build_subdir"
eval "core_build_extradir=\$libretro_${1}_build_extradir"
eval "core_build_args=\$libretro_${1}_build_args"

# TODO: Really, change how all of this is done...
eval "core_build_platform=\${libretro_${1}_build_platform:-$FORMAT_COMPILER_TARGET}$opengl_type"

eval "core_build_cores=\${libretro_${1}_build_cores:-$1}"
eval "core_build_products=\$libretro_${1}_build_products"
eval "core_cmake_target=${1}_libretro"
build_cmake $1 2>&1
;;

legacy)
eval "core_build_legacy=\$libretro_${1}_build_legacy"
if [ -n "$core_build_legacy" ]; then
Expand Down
25 changes: 17 additions & 8 deletions rules.d/core-rules.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ include_core_dolphin() {
}
libretro_dolphin_name="Dolphin"
libretro_dolphin_git_url="https://github.com/libretro/dolphin.git"
libretro_dolphin_build_subdir="Source/Core/DolphinLibretro"
libretro_dolphin_build_makefile="Makefile"
libretro_dolphin_build_rule="cmake"
libretro_dolphin_build_args="-DLIBRETRO=ON"

include_core_dolphin_launcher() {
register_module core "dolphin_launcher"
Expand Down Expand Up @@ -87,7 +87,8 @@ include_core_swanstation() {
}
libretro_swanstation_name="Duckstation"
libretro_swanstation_git_url="https://github.com/libretro/swanstation.git"
libretro_swanstation_build_products="bin"
libretro_swanstation_build_rule="cmake"
libretro_swanstation_build_args="-DCMAKE_BUILD_TYPE=Release"

include_core_mrboom() {
register_module core "mrboom"
Expand Down Expand Up @@ -321,7 +322,8 @@ include_core_flycast() {
}
libretro_flycast_name="Flycast"
libretro_flycast_git_url="https://github.com/flyinghead/flycast"
libretro_flycast_build_makefile="Makefile"
libretro_flycast_build_rule="cmake"
libretro_flycast_build_args="-DLIBRETRO=ON -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE -DCMAKE_BUILD_TYPE=Release"

include_core_redream() {
register_module core "redream"
Expand Down Expand Up @@ -1229,6 +1231,7 @@ libretro_citra2018_name="Citra 2018"
libretro_citra2018_git_url="https://github.com/libretro/citra2018.git"
libretro_citra2018_git_submodules="yes"
libretro_citra2018_build_opengl="yes"
libretro_citra2018_build_rule="cmake"

include_core_citra_canary() {
register_module core "citra_canary" -ios -theos_ios -ngc -ps3 -psp1 -qnx -wii
Expand All @@ -1244,15 +1247,19 @@ include_core_thepowdertoy() {
libretro_thepowdertoy_name="The Powder Toy"
libretro_thepowdertoy_git_url="https://github.com/libretro/ThePowderToy.git"
libretro_thepowdertoy_git_submodules="yes"
libretro_thepowdertoy_build_rule="cmake"
libretro_thepowdertoy_build_args="-DBUILD_LIBRETRO=ON"
libretro_thepowdertoy_build_extradir="src/"

include_core_ppsspp() {
register_module core "ppsspp" -ios -theos_ios -ngc -ps3 -psp1 -qnx -wii
}
libretro_ppsspp_name="PPSSPP"
libretro_ppsspp_git_url="https://github.com/hrydgard/ppsspp.git"
libretro_ppsspp_git_submodules="yes"
libretro_ppsspp_build_subdir="libretro"
libretro_ppsspp_build_opengl="yes"
libretro_ppsspp_build_extradir="lib/"
libretro_ppsspp_build_rule="cmake"
libretro_ppsspp_build_args="-DLIBRETRO=ON"

include_core_play() {
register_module core "play" -ios -theos_ios -ngc -ps3 -psp1 -qnx -wii
Expand Down Expand Up @@ -1443,8 +1450,10 @@ include_core_tic80() {
libretro_tic80_name="TIC-80"
libretro_tic80_git_url="https://github.com/libretro/TIC-80.git"
libretro_tic80_git_submodules="yes"
libretro_tic80_build_makefile="Makefile"
libretro_tic80_build_subdir="build"
libretro_tic80_build_subdir="core"
libretro_tic80_build_extradir="lib/"
libretro_tic80_build_rule="cmake"
libretro_tic80_build_args="-DBUILD_PLAYER=OFF -DBUILD_SOKOL=OFF -DBUILD_SDL=OFF -DBUILD_DEMO_CARTS=OFF -DBUILD_LIBRETRO=ON -DBUILD_WITH_MRUBY=OFF -DCMAKE_BUILD_TYPE=Release"

include_core_lowresnx() {
register_module core "lowresnx" -theos_ios -ngc -sncps3 -ps3 -psp1 -qnx -wii
Expand Down

0 comments on commit 96ffa26

Please sign in to comment.