2019-07-13 02:41:34 -07:00
|
|
|
|
|
|
|
# Careful. Globbing can't see changes to the contents of files
|
|
|
|
# Need to do a fresh clean to see changes
|
2020-03-03 17:11:24 -08:00
|
|
|
file(GLOB_RECURSE ASM_SOURCES CONFIGURE_DEPENDS *.asm)
|
2019-07-13 02:41:34 -07:00
|
|
|
|
|
|
|
set(ASM_DEPENDS "")
|
|
|
|
foreach(ASM_SRC ${ASM_SOURCES})
|
2020-06-10 17:39:08 -07:00
|
|
|
file(RELATIVE_PATH REL_ASM ${CMAKE_SOURCE_DIR} ${ASM_SRC})
|
|
|
|
file(RELATIVE_PATH REL_TEST_ASM ${CMAKE_CURRENT_SOURCE_DIR} ${ASM_SRC})
|
2019-07-13 02:41:34 -07:00
|
|
|
get_filename_component(ASM_NAME ${ASM_SRC} NAME)
|
2020-06-10 17:39:08 -07:00
|
|
|
get_filename_component(ASM_DIR "${REL_ASM}" DIRECTORY)
|
|
|
|
set(OUTPUT_ASM_FOLDER "${CMAKE_BINARY_DIR}/${ASM_DIR}")
|
|
|
|
|
|
|
|
# Generate build directory
|
|
|
|
add_custom_command(OUTPUT ${OUTPUT_ASM_FOLDER}
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E make_directory "${OUTPUT_ASM_FOLDER}")
|
2019-07-13 02:41:34 -07:00
|
|
|
|
|
|
|
# Generate a temporary file
|
2020-06-10 17:39:08 -07:00
|
|
|
set(ASM_TMP "${ASM_NAME}_TMP.asm")
|
|
|
|
set(TMP_FILE "${OUTPUT_ASM_FOLDER}/${ASM_TMP}")
|
|
|
|
|
2019-07-13 02:41:34 -07:00
|
|
|
add_custom_command(OUTPUT ${TMP_FILE}
|
2020-06-10 17:39:08 -07:00
|
|
|
DEPENDS "${OUTPUT_ASM_FOLDER}"
|
2019-07-13 02:41:34 -07:00
|
|
|
DEPENDS "${ASM_SRC}"
|
|
|
|
COMMAND "cp" ARGS "${ASM_SRC}" "${TMP_FILE}"
|
|
|
|
COMMAND "sed" ARGS "-i" "-e" "\'1s;^;BITS 64\\n;\'" "-e" "\'\$\$a\\ret\\n\'" "${TMP_FILE}"
|
|
|
|
)
|
|
|
|
|
2020-06-10 17:39:08 -07:00
|
|
|
set(OUTPUT_NAME "${OUTPUT_ASM_FOLDER}/${ASM_NAME}.bin")
|
|
|
|
set(OUTPUT_CONFIG_NAME "${OUTPUT_ASM_FOLDER}/${ASM_NAME}.config.bin")
|
2019-07-13 02:41:34 -07:00
|
|
|
|
|
|
|
add_custom_command(OUTPUT ${OUTPUT_NAME}
|
|
|
|
DEPENDS "${TMP_FILE}"
|
2020-06-10 17:39:08 -07:00
|
|
|
COMMAND "nasm" ARGS "${TMP_FILE}" "-o" "${OUTPUT_NAME}")
|
2019-07-13 02:41:34 -07:00
|
|
|
|
|
|
|
add_custom_command(OUTPUT ${OUTPUT_CONFIG_NAME}
|
|
|
|
DEPENDS "${ASM_SRC}"
|
2020-06-10 13:47:52 -07:00
|
|
|
DEPENDS "${CMAKE_SOURCE_DIR}/Scripts/json_asm_config_parse.py"
|
2020-08-20 23:33:14 +12:00
|
|
|
DEPENDS "${CMAKE_SOURCE_DIR}/Scripts/json_config_parse.py"
|
2020-06-10 17:39:08 -07:00
|
|
|
COMMAND "python3" ARGS "${CMAKE_SOURCE_DIR}/Scripts/json_asm_config_parse.py" "${ASM_SRC}" "${OUTPUT_CONFIG_NAME}")
|
2019-07-13 02:41:34 -07:00
|
|
|
|
|
|
|
list(APPEND ASM_DEPENDS "${OUTPUT_NAME};${OUTPUT_CONFIG_NAME}")
|
|
|
|
|
2020-03-17 14:40:28 -07:00
|
|
|
# Format is "<Test Arguments>" "<Test Name>"
|
2019-11-15 18:04:10 -08:00
|
|
|
set(TEST_ARGS
|
2020-03-17 14:40:28 -07:00
|
|
|
"-c irint -n 1" "int_1"
|
|
|
|
"-c irint -n 500" "int_500"
|
|
|
|
"-c irint -n 500 -m" "int_500_m"
|
|
|
|
"-c irjit -n 1" "jit_1"
|
|
|
|
"-c irjit -n 500" "jit_500"
|
|
|
|
"-c irjit -n 500 -m" "jit_500_m"
|
|
|
|
)
|
|
|
|
|
|
|
|
list(LENGTH TEST_ARGS ARG_COUNT)
|
|
|
|
math(EXPR ARG_COUNT "${ARG_COUNT}-1")
|
|
|
|
foreach(Index RANGE 0 ${ARG_COUNT} 2)
|
|
|
|
math(EXPR TEST_NAME_INDEX "${Index}+1")
|
2019-11-15 18:04:10 -08:00
|
|
|
|
2020-03-17 14:40:28 -07:00
|
|
|
list(GET TEST_ARGS ${Index} ARGS)
|
|
|
|
list(GET TEST_ARGS ${TEST_NAME_INDEX} TEST_DESC)
|
|
|
|
|
2020-06-10 17:39:08 -07:00
|
|
|
set(TEST_NAME "${TEST_DESC}/Test_${REL_TEST_ASM}")
|
2019-11-15 18:04:10 -08:00
|
|
|
string(REPLACE " " ";" ARGS_LIST ${ARGS})
|
|
|
|
add_test(NAME ${TEST_NAME}
|
2020-03-16 12:35:09 -07:00
|
|
|
COMMAND "python3" "${CMAKE_SOURCE_DIR}/Scripts/testharness_runner.py"
|
|
|
|
"${CMAKE_SOURCE_DIR}/unittests/ASM/Known_Failures"
|
2020-05-28 15:09:51 -07:00
|
|
|
"${CMAKE_SOURCE_DIR}/unittests/ASM/Disabled_Tests"
|
2020-06-10 17:39:08 -07:00
|
|
|
"Test_${REL_TEST_ASM}"
|
2020-03-16 12:35:09 -07:00
|
|
|
"${CMAKE_BINARY_DIR}/Bin/TestHarnessRunner"
|
|
|
|
${ARGS_LIST} "${OUTPUT_NAME}" "${OUTPUT_CONFIG_NAME}")
|
2019-11-15 18:04:10 -08:00
|
|
|
# This will cause the ASM tests to fail if it can't find the TestHarness or ASMN files
|
|
|
|
# Prety crap way to work around the fact that tests can't have a build dependency in a different directory
|
|
|
|
# Just make sure to independently run `make all` then `make test`
|
|
|
|
set_property(TEST ${TEST_NAME} APPEND PROPERTY DEPENDS "${CMAKE_BINARY_DIR}/Bin/TestHarnessRunner")
|
|
|
|
set_property(TEST ${TEST_NAME} APPEND PROPERTY DEPENDS "${OUTPUT_NAME}")
|
|
|
|
set_property(TEST ${TEST_NAME} APPEND PROPERTY DEPENDS "${OUTPUT_CONFIG_NAME}")
|
|
|
|
endforeach()
|
2019-07-13 02:41:34 -07:00
|
|
|
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
add_custom_target(asm_files ALL
|
|
|
|
DEPENDS "${ASM_DEPENDS}")
|
2020-05-08 19:28:59 -07:00
|
|
|
|
|
|
|
execute_process(COMMAND "nproc" OUTPUT_VARIABLE CORES)
|
|
|
|
string(STRIP ${CORES} CORES)
|
|
|
|
|
|
|
|
add_custom_target(
|
|
|
|
asm_tests
|
|
|
|
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
|
|
|
|
USES_TERMINAL
|
|
|
|
COMMAND "ctest" "-j${CORES}" "-R" "\.*.asm")
|