Skip to content

Commit

Permalink
separate tests target
Browse files Browse the repository at this point in the history
  • Loading branch information
ReenigneArcher committed Oct 17, 2024
1 parent 22abcdf commit b000a0e
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 7 deletions.
17 changes: 16 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,24 @@ jobs:
cd "${GITHUB_WORKSPACE}"
mkdir -p build
cmake -DCMAKE_TOOLCHAIN_FILE="${nxdk_dir}/share/toolchain-nxdk.cmake" -B build -S .
# the main target needs to be cross compiled
echo "--- Building ALL ---"
cmake \
-B build \
-S . \
-DCMAKE_TOOLCHAIN_FILE="${nxdk_dir}/share/toolchain-nxdk.cmake"
cmake --build build
# the tests target should not be cross compiled
# https://stackoverflow.com/a/64335131/11214013
echo "--- Building tests ---"
cmake \
-B build/tests \
-S . \
-DBUILD_TESTS=ON
cmake --build build/tests --target test_moonlight
# recursively list all files in build directory
ls -R build
Expand Down
19 changes: 14 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ message(STATUS "XBOX_ISO: ${XBOX_ISO}")
#
# Options
#
option(BUILD_TESTS "Build tests" ON)
option(BUILD_TESTS "Build tests" OFF)

# create the xbe directory if it doesn't exist
file(MAKE_DIRECTORY ${XBOX_XBE_DIR})
Expand All @@ -38,11 +38,14 @@ set(MOONLIGHT_SOURCES
set(MOONLIGHT_EXTERNAL_LIBRARIES
"${NXDK_DIR}/lib/libpbkit.lib"
)
set(MOONLIGHT_INCLUDE_DIRS
"${NXDK_DIR}/lib"
)

add_executable(${CMAKE_PROJECT_NAME}
${MOONLIGHT_SOURCES}
)
include_directories("${NXDK_DIR}/lib")
include_directories(${MOONLIGHT_INCLUDE_DIRS})
target_link_libraries(${CMAKE_PROJECT_NAME} PUBLIC
${MOONLIGHT_EXTERNAL_LIBRARIES}
)
Expand All @@ -53,20 +56,26 @@ target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE "")
# tests
#
if(BUILD_TESTS)
add_subdirectory(tests)
add_subdirectory(tests EXCLUDE_FROM_ALL)
endif()

# Post-build exe to xbe conversion
add_custom_target(cxbe_convert ALL
VERBATIM COMMAND "${CMAKE_COMMAND}" -E env ./tools/cxbe/cxbe -OUT:${XBOX_XBE_DIR}/default.xbe -TITLE:${XBE_TITLE} ${CMAKE_CURRENT_BINARY_DIR}/${XBE_TITLE}.exe
VERBATIM COMMAND "${CMAKE_COMMAND}" -E env
./tools/cxbe/cxbe
-OUT:${XBOX_XBE_DIR}/default.xbe
-TITLE:${XBE_TITLE}
${CMAKE_CURRENT_BINARY_DIR}/${XBE_TITLE}.exe
WORKING_DIRECTORY ${NXDK_DIR}
COMMENT "CXBE Conversion: [EXE -> XBE]"
)
add_dependencies(cxbe_convert ${CMAKE_PROJECT_NAME})

# Post-build xbe to xiso conversion
add_custom_target(xbe_iso ALL
VERBATIM COMMAND "${CMAKE_COMMAND}" -E env ${NXDK_DIR}/tools/extract-xiso/build/extract-xiso -c ${XBOX_XBE_DIR} ${XBOX_ISO}
VERBATIM COMMAND "${CMAKE_COMMAND}" -E env
${NXDK_DIR}/tools/extract-xiso/build/extract-xiso
-c ${XBOX_XBE_DIR} ${XBOX_ISO}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "CXBE Conversion: [XBE -> XISO]"
)
Expand Down
10 changes: 9 additions & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,20 @@ cmake_minimum_required(VERSION 3.13)
project(test_moonlight)

include_directories("${CMAKE_SOURCE_DIR}")
include_directories(${MOONLIGHT_INCLUDE_DIRS})

# nxdk include dirs, these are set by the toolchain for ALL targets except this one since we don't use the toolchain
include_directories(
"${NXDK_DIR}/lib/winapi"
)

enable_testing()

# Add GoogleTest directory to the project
set(GTEST_SOURCE_DIR "${CMAKE_SOURCE_DIR}/third-party/googletest")
set(INSTALL_GTEST OFF)
set(INSTALL_GMOCK OFF)
add_subdirectory("${GTEST_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/googletest")
add_subdirectory("${GTEST_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/googletest" EXCLUDE_FROM_ALL)
include_directories("${GTEST_SOURCE_DIR}/googletest/include" "${GTEST_SOURCE_DIR}")

# coverage
Expand Down Expand Up @@ -50,4 +56,6 @@ target_compile_definitions(${PROJECT_NAME} PUBLIC ${MOONLIGHT_DEFINITIONS} ${TES
target_compile_options(${PROJECT_NAME} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:${MOONLIGHT_COMPILE_OPTIONS}>)
target_link_options(${PROJECT_NAME} PRIVATE)

add_dependencies(${PROJECT_NAME} gtest gtest_main gmock gmock_main)

add_test(NAME ${PROJECT_NAME} COMMAND moonlight_test)

0 comments on commit b000a0e

Please sign in to comment.