cmake: fix sdl3.pc for Nintendo 3DS + add to test matrix

This commit is contained in:
Anonymous Maarten 2023-01-15 17:39:07 +01:00
parent fc72ee5775
commit 0a1479d58c
6 changed files with 49 additions and 17 deletions

16
.github/cmake/CMakeLists.txt vendored Normal file
View File

@ -0,0 +1,16 @@
cmake_minimum_required(VERSION 3.0)
project(ci_utils C CXX)
set(txt "CC=${CMAKE_C_COMPILER}
CXX=${CMAKE_CXX_COMPILER}
CFLAGS=${CMAKE_C_FLAGS}
CXXFLAGS=${CMAKE_CXX_FLAGS}
LDFLAGS=${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_C_STANDARD_LIBRARIES}
")
message("${txt}")
set(VAR_PATH "/tmp/env.txt" CACHE PATH "Where to write environment file")
message(STATUS "Writing CC/CXX/CFLAGS/CXXFLAGS/LDFLAGS environment to ${VAR_PATH}")
file(WRITE "${VAR_PATH}" "${txt}")

View File

@ -42,5 +42,14 @@ jobs:
-DCMAKE_PREFIX_PATH=${{ env.SDL3_DIR }} \
-DCMAKE_BUILD_TYPE=Release
cmake --build cmake_config_build --verbose
# Not running test_pkgconfig.sh and test_sdlconfig.sh
# as invoking the compiler manually is not supported
- name: Extract CC/CXX/CFLAGS/CXXFLAGS from CMake toolchain
run: |
cmake -S .github/cmake -B /tmp/cmake_extract \
-DCMAKE_TOOLCHAIN_FILE=${DEVKITPRO}/cmake/3DS.cmake \
-DCMAKE_BUILD_TYPE=Release \
-DVAR_PATH=/tmp/n3ds_env.txt
cat /tmp/n3ds_env.txt >> $GITHUB_ENV
- name: Verify sdl3.pc
run: |
export PKG_CONFIG_PATH=${{ env.SDL3_DIR }}/lib/pkgconfig
cmake/test/test_pkgconfig.sh

View File

@ -54,7 +54,7 @@ jobs:
- name: Verify sdl3.pc
run: |
export CC=mips64r5900el-ps2-elf-gcc
export EXTRA_LDFLAGS="-L$PS2DEV/ps2sdk/ee/lib -L$PS2DEV/gsKit/lib -L$PS2DEV/ps2sdk/ports/lib"
export LDFLAGS="-L$PS2DEV/ps2sdk/ee/lib -L$PS2DEV/gsKit/lib -L$PS2DEV/ps2sdk/ports/lib"
export PKG_CONFIG_PATH=${{ env.SDL3_DIR }}/lib/pkgconfig
cmake/test/test_pkgconfig.sh

View File

@ -43,6 +43,6 @@ jobs:
- name: Verify sdl3.pc
run: |
export CC=psp-gcc
export LDFLAGS="-L$PSPDEV/lib -L$PSPDEV/psp/lib -L$PSPDEV/psp/sdk/lib"
export PKG_CONFIG_PATH=${{ env.SDL3_DIR }}/lib/pkgconfig
export EXTRA_LDFLAGS="-L$PSPDEV/lib -L$PSPDEV/psp/lib -L$PSPDEV/psp/sdk/lib"
cmake/test/test_pkgconfig.sh

View File

@ -2721,6 +2721,13 @@ elseif(N3DS)
else()
message_error("SDL_FILE must be enabled to build on N3DS")
endif()
foreach(lib ${CMAKE_C_STANDARD_LIBRARIES})
if(lib MATCHES "^-l")
string(SUBSTRING "${lib}" 2 -1 lib)
endif()
list(APPEND SDL_EXTRA_LIBS ${lib})
endforeach()
endif()
if(HAVE_VULKAN AND NOT SDL_LOADSO)

View File

@ -13,7 +13,7 @@ case "$machine" in
*android* )
EXEPREFIX="lib"
EXESUFFIX=".so"
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -shared"
LDFLAGS="$EXTRA_LDFLAGS -shared"
;;
* )
EXEPREFIX=""
@ -25,20 +25,20 @@ set -e
# Get the canonical path of the folder containing this script
testdir=$(cd -P -- "$(dirname -- "$0")" && printf '%s\n' "$(pwd -P)")
CFLAGS="$( pkg-config sdl3 --cflags )"
LDFLAGS="$( pkg-config sdl3 --libs )"
STATIC_LDFLAGS="$( pkg-config sdl3 --libs --static )"
SDL_CFLAGS="$( pkg-config sdl3 --cflags )"
SDL_LDFLAGS="$( pkg-config sdl3 --libs )"
SDL_STATIC_LDFLAGS="$( pkg-config sdl3 --libs --static )"
compile_cmd="$CC -c "$testdir/main_gui.c" -o main_gui_pkgconfig.c.o $CFLAGS $EXTRA_CFLAGS"
link_cmd="$CC main_gui_pkgconfig.c.o -o ${EXEPREFIX}main_gui_pkgconfig${EXESUFFIX} $LDFLAGS $EXTRA_LDFLAGS"
static_link_cmd="$CC main_gui_pkgconfig.c.o -o ${EXEPREFIX}main_gui_pkgconfig_static${EXESUFFIX} $STATIC_LDFLAGS $EXTRA_LDFLAGS"
compile_cmd="$CC -c "$testdir/main_gui.c" -o main_gui_pkgconfig.c.o $SDL_CFLAGS $CFLAGS"
link_cmd="$CC main_gui_pkgconfig.c.o -o ${EXEPREFIX}main_gui_pkgconfig${EXESUFFIX} $SDL_LDFLAGS $LDFLAGS"
static_link_cmd="$CC main_gui_pkgconfig.c.o -o ${EXEPREFIX}main_gui_pkgconfig_static${EXESUFFIX} $SDL_STATIC_LDFLAGS $LDFLAGS"
echo "-- CC: $CC"
echo "-- CFLAGS: $CFLAGS"
echo "-- EXTRA_CFLAGS: $EXTRA_CFLAGS"
echo "-- LDFLASG: $LDFLAGS"
echo "-- STATIC_LDFLAGS: $STATIC_LDFLAGS"
echo "-- EXTRA_LDFLAGS: $EXTRA_LDFLAGS"
echo "-- CC: $CC"
echo "-- CFLAGS: $CFLAGS"
echo "-- LDFLASG: $LDFLAGS"
echo "-- SDL_CFLAGS: $SDL_CFLAGS"
echo "-- SDL_LDFLAGS: $SDL_LDFLAGS"
echo "-- SDL_STATIC_LDFLAGS: $SDL_STATIC_LDFLAGS"
echo "-- COMPILE: $compile_cmd"
echo "-- LINK: $link_cmd"