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 16, 2024
1 parent 22abcdf commit f7a7275
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 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 \
-S . \
-DBUILD_TESTS=ON
cmake --build build --target tests
# recursively list all files in build directory
ls -R build
Expand Down
14 changes: 10 additions & 4 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 Down Expand Up @@ -53,20 +53,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
4 changes: 3 additions & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ enable_testing()
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 +50,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 f7a7275

Please sign in to comment.