mirror of
https://github.com/FEX-Emu/FEX.git
synced 2025-02-13 03:02:47 +00:00
67 lines
2.7 KiB
CMake
67 lines
2.7 KiB
CMake
# Careful. Globbing can't see changes to the contents of files
|
|
# Need to do a fresh clean to see changes
|
|
file(GLOB_RECURSE JSON_SOURCES CONFIGURE_DEPENDS *.json)
|
|
|
|
set(JSON_DEPENDS "")
|
|
set(JSON_UPDATE_DEPENDS "")
|
|
|
|
foreach(JSON_SRC ${JSON_SOURCES})
|
|
file(RELATIVE_PATH REL_JSON ${CMAKE_SOURCE_DIR} ${JSON_SRC})
|
|
file(RELATIVE_PATH REL_TEST_JSON ${CMAKE_CURRENT_SOURCE_DIR} ${JSON_SRC})
|
|
get_filename_component(JSON_NAME ${JSON_SRC} NAME)
|
|
get_filename_component(JSON_DIR "${REL_JSON}" DIRECTORY)
|
|
set(OUTPUT_JSON_FOLDER "${CMAKE_BINARY_DIR}/${JSON_DIR}")
|
|
|
|
# Generate build directory
|
|
file(MAKE_DIRECTORY "${OUTPUT_JSON_FOLDER}")
|
|
set(OUTPUT_JSON_NAME "${OUTPUT_JSON_FOLDER}/${JSON_NAME}.instcountci")
|
|
set(OUTPUT_JSON_NEWNUMBERS_NAME "${OUTPUT_JSON_FOLDER}/${JSON_NAME}.instcountci.json")
|
|
|
|
add_custom_command(OUTPUT ${OUTPUT_JSON_NAME}
|
|
DEPENDS "${JSON_SRC}"
|
|
DEPENDS "${CMAKE_SOURCE_DIR}/Scripts/InstructionCountParser.py"
|
|
COMMAND "python3" ARGS "${CMAKE_SOURCE_DIR}/Scripts/InstructionCountParser.py" "${JSON_SRC}" "${OUTPUT_JSON_NAME}")
|
|
|
|
list(APPEND JSON_DEPENDS "${OUTPUT_JSON_NAME}")
|
|
|
|
if (NOT MINGW_BUILD)
|
|
set (LAUNCH_PROGRAM "${CMAKE_BINARY_DIR}/Bin/CodeSizeValidation")
|
|
else()
|
|
set (LAUNCH_PROGRAM "wine" "${CMAKE_BINARY_DIR}/Bin/CodeSizeValidation.exe")
|
|
endif()
|
|
|
|
file(RELATIVE_PATH JSON_PATH_RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${JSON_SRC})
|
|
set(TEST_NAME "InstCountCI/Test_${JSON_PATH_RELATIVE}.instcountci")
|
|
set(TEST_NAME_UPDATE_NUMBERS "InstCountCI/Test_${JSON_PATH_RELATIVE}.new_numbers")
|
|
|
|
add_test(NAME ${TEST_NAME}
|
|
COMMAND ${LAUNCH_PROGRAM} "${OUTPUT_JSON_NAME}" "${OUTPUT_JSON_NEWNUMBERS_NAME}")
|
|
|
|
add_test(NAME ${TEST_NAME_UPDATE_NUMBERS}
|
|
COMMAND "python3" "${CMAKE_SOURCE_DIR}/Scripts/UpdateInstructionCountJson.py" "${JSON_SRC}" "${OUTPUT_JSON_NEWNUMBERS_NAME}")
|
|
|
|
set_property(TEST ${TEST_NAME} APPEND PROPERTY DEPENDS "${CMAKE_BINARY_DIR}/Bin/CodeSizeValidation")
|
|
set_property(TEST ${TEST_NAME} APPEND PROPERTY DEPENDS "${OUTPUT_JSON_NAME}")
|
|
|
|
set_property(TEST ${TEST_NAME_UPDATE_NUMBERS} APPEND PROPERTY DEPENDS "${TEST_NAME}")
|
|
endforeach()
|
|
|
|
add_custom_target(instcountci_test_files ALL
|
|
DEPENDS "${JSON_DEPENDS}")
|
|
|
|
execute_process(COMMAND "nproc" OUTPUT_VARIABLE CORES)
|
|
string(STRIP ${CORES} CORES)
|
|
|
|
add_custom_target(
|
|
instcountci_tests
|
|
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
|
|
USES_TERMINAL
|
|
DEPENDS instcountci_test_files
|
|
COMMAND "ctest" "--output-on-failure" "--timeout" "302" "-j${CORES}" "-R" "InstCountCI/\.*.instcountci$$")
|
|
|
|
add_custom_target(
|
|
instcountci_update_tests
|
|
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
|
|
USES_TERMINAL
|
|
COMMAND "ctest" "--output-on-failure" "--timeout" "302" "-j${CORES}" "-R" "InstCountCI/\.*new_numbers$$")
|