Tools: Moves IRLoader to independent folder

Which requires moving LinuxEmulation to its own independent folder as
well. Since both IRLoader and FEXLoader rely on it.

No functional change, just moves the the code around.
This commit is contained in:
Ryan Houdek 2023-12-15 17:37:23 -08:00
parent 86654907bf
commit f2bcc14cda
150 changed files with 210 additions and 191 deletions

View File

@ -18,6 +18,11 @@ if (NOT MINGW_BUILD)
add_subdirectory(FEXServer/)
add_subdirectory(FEXBash/)
add_subdirectory(CodeSizeValidation/)
add_subdirectory(LinuxEmulation/)
if (BUILD_TESTS)
add_subdirectory(IRLoader/)
endif()
endif()
add_subdirectory(FEXLoader/)

View File

@ -6,8 +6,6 @@ if (ENABLE_VIXL_SIMULATOR)
endif()
if (NOT MINGW_BUILD)
add_subdirectory(LinuxSyscalls)
if (TERMUX_BUILD)
# Termux needs android-shmem to get the shm emulation library.
list(APPEND LIBS android-shmem)
@ -16,7 +14,6 @@ if (NOT MINGW_BUILD)
function(GenerateInterpreter NAME AsInterpreter)
add_executable(${NAME}
FEXLoader.cpp
VDSO_Emulation.cpp
AOT/AOTGenerator.cpp)
target_compile_definitions(${NAME} PRIVATE ${DEFINES})
@ -181,24 +178,4 @@ if (BUILD_TESTS)
${LIBS}
${PTHREAD_LIB}
)
if (NOT MINGW_BUILD)
add_executable(IRLoader
IRLoader.cpp
)
target_compile_definitions(IRLoader PRIVATE ${DEFINES})
target_include_directories(IRLoader
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/Source/
${CMAKE_BINARY_DIR}/generated
)
target_link_libraries(IRLoader
PRIVATE
${LIBS}
LinuxEmulation
${PTHREAD_LIB}
fmt::fmt
)
endif()
endif()

View File

@ -1,168 +0,0 @@
add_compile_options(-fno-operator-names)
set (SRCS
GdbServer.cpp
EmulatedFiles/EmulatedFiles.cpp
FileManagement.cpp
LinuxAllocator.cpp
SignalDelegator.cpp
Syscalls.cpp
SyscallsSMCTracking.cpp
SyscallsVMATracking.cpp
Utils/Threads.cpp
x32/Syscalls.cpp
x32/EPoll.cpp
x32/FD.cpp
x32/FS.cpp
x32/Info.cpp
x32/IO.cpp
x32/Memory.cpp
x32/Msg.cpp
x32/NotImplemented.cpp
x32/Semaphore.cpp
x32/Sched.cpp
x32/Signals.cpp
x32/Socket.cpp
x32/Stubs.cpp
x32/Thread.cpp
x32/Time.cpp
x32/Timer.cpp
x32/IoctlEmulation.cpp
x64/EPoll.cpp
x64/FD.cpp
x64/IO.cpp
x64/Ioctl.cpp
x64/Info.cpp
x64/Memory.cpp
x64/Msg.cpp
x64/NotImplemented.cpp
x64/Semaphore.cpp
x64/Sched.cpp
x64/Signals.cpp
x64/Socket.cpp
x64/Thread.cpp
x64/Syscalls.cpp
x64/Time.cpp
Syscalls/EPoll.cpp
Syscalls/FD.cpp
Syscalls/FS.cpp
Syscalls/Info.cpp
Syscalls/IO.cpp
Syscalls/IOUring.cpp
Syscalls/Key.cpp
Syscalls/Memory.cpp
Syscalls/Msg.cpp
Syscalls/Namespace.cpp
Syscalls/Sched.cpp
Syscalls/Semaphore.cpp
Syscalls/SHM.cpp
Syscalls/Signals.cpp
Syscalls/Socket.cpp
Syscalls/Thread.cpp
Syscalls/Time.cpp
Syscalls/Timer.cpp
Syscalls/NotImplemented.cpp
Syscalls/Stubs.cpp)
add_library(LinuxEmulation STATIC ${SRCS})
target_compile_options(LinuxEmulation
PRIVATE
-Wall
-Werror=cast-qual
-Werror=ignored-qualifiers
-Werror=implicit-fallthrough
-Wno-trigraphs
-fwrapv
)
target_include_directories(LinuxEmulation
PRIVATE
${CMAKE_BINARY_DIR}/generated
${CMAKE_CURRENT_SOURCE_DIR}/../
${PROJECT_SOURCE_DIR}/External/drm-headers/include/
)
target_link_libraries(LinuxEmulation
PRIVATE
Common
FEXCore
CommonTools
)
set(HEADERS_TO_VERIFY
x32/Types.h x86_32 # This needs to match structs to 32bit structs
x32/Ioctl/asound.h x86_32 # This needs to match structs to 32bit structs
x32/Ioctl/drm.h x86_32 # This needs to match structs to 32bit structs
x32/Ioctl/streams.h x86_32 # This needs to match structs to 32bit structs
x32/Ioctl/usbdev.h x86_32 # This needs to match structs to 32bit structs
x32/Ioctl/input.h x86_32 # This needs to match structs to 32bit structs
x32/Ioctl/sockios.h x86_32 # This needs to match structs to 32bit structs
x32/Ioctl/joystick.h x86_32 # This needs to match structs to 32bit structs
x64/Types.h x86_64 # This needs to match structs to 64bit structs
)
list(LENGTH HEADERS_TO_VERIFY ARG_COUNT)
math(EXPR ARG_COUNT "${ARG_COUNT}-1")
set (ARGS
"-x" "c++"
"-std=c++20"
"-fno-operator-names"
"-I${PROJECT_SOURCE_DIR}/External/drm-headers/include/"
"-I${CMAKE_CURRENT_SOURCE_DIR}/../")
# Global include directories
get_directory_property (INC_DIRS INCLUDE_DIRECTORIES)
list(TRANSFORM INC_DIRS PREPEND "-I")
list(APPEND ARGS ${INC_DIRS})
# FEXCore directories
get_target_property(INC_DIRS FEXCore INTERFACE_INCLUDE_DIRECTORIES)
list(TRANSFORM INC_DIRS PREPEND "-I")
list(APPEND ARGS ${INC_DIRS})
foreach(Index RANGE 0 ${ARG_COUNT} 2)
math(EXPR TEST_TYPE_INDEX "${Index}+1")
list(GET HEADERS_TO_VERIFY ${Index} HEADER)
list(GET HEADERS_TO_VERIFY ${TEST_TYPE_INDEX} TEST_TYPE)
file(RELATIVE_PATH REL_HEADER ${CMAKE_BINARY_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/${HEADER}")
set(TEST_NAME "${TEST_DESC}/Test_verify_${HEADER}")
set(TEST_NAME_ARCH "${TEST_DESC}/Test_verify_arch_${HEADER}")
add_test(
NAME ${TEST_NAME}_x86_64
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
COMMAND "python3" "${CMAKE_SOURCE_DIR}/Scripts/StructPackVerifier.py" "-c1" "x86_64" "${REL_HEADER}" ${ARGS})
add_test(
NAME ${TEST_NAME}_aarch64
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
COMMAND "python3" "${CMAKE_SOURCE_DIR}/Scripts/StructPackVerifier.py" "-c1" "aarch64" "${REL_HEADER}" ${ARGS})
add_test(
NAME ${TEST_NAME_ARCH}_x86_64
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
COMMAND "python3" "${CMAKE_SOURCE_DIR}/Scripts/StructPackVerifier.py" "-c1" "x86_64" "-c2" "${TEST_TYPE}" "${REL_HEADER}" ${ARGS})
add_test(
NAME ${TEST_NAME_ARCH}_aarch64
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
COMMAND "python3" "${CMAKE_SOURCE_DIR}/Scripts/StructPackVerifier.py" "-c1" "aarch64" "-c2" "${TEST_TYPE}" "${REL_HEADER}" ${ARGS})
set_property(TEST ${TEST_NAME}_x86_64 APPEND PROPERTY DEPENDS "${HEADER}")
set_property(TEST ${TEST_NAME}_aarch64 APPEND PROPERTY DEPENDS "${HEADER}")
set_property(TEST ${TEST_NAME_ARCH}_x86_64 APPEND PROPERTY DEPENDS "${HEADER}")
set_property(TEST ${TEST_NAME_ARCH}_aarch64 APPEND PROPERTY DEPENDS "${HEADER}")
endforeach()
execute_process(COMMAND "nproc" OUTPUT_VARIABLE CORES)
string(STRIP ${CORES} CORES)
add_custom_target(
struct_verifier
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
USES_TERMINAL
COMMAND "ctest" "--output-on-failure" "--timeout" "302" "-j${CORES}" "-R" "Test_verify*")

View File

@ -0,0 +1,23 @@
list(APPEND LIBS FEXCore Common)
add_executable(IRLoader
IRLoader.cpp
)
if (ENABLE_VIXL_SIMULATOR)
target_compile_definitions(IRLoader PRIVATE "-DVIXL_SIMULATOR=1")
endif()
target_include_directories(IRLoader
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/Source/
${CMAKE_BINARY_DIR}/generated
)
target_link_libraries(IRLoader
PRIVATE
${LIBS}
LinuxEmulation
CommonTools
${PTHREAD_LIB}
fmt::fmt
)

View File

@ -0,0 +1,182 @@
add_compile_options(-fno-operator-names)
set (SRCS
VDSO_Emulation.cpp
LinuxSyscalls/GdbServer.cpp
LinuxSyscalls/EmulatedFiles/EmulatedFiles.cpp
LinuxSyscalls/FileManagement.cpp
LinuxSyscalls/LinuxAllocator.cpp
LinuxSyscalls/SignalDelegator.cpp
LinuxSyscalls/Syscalls.cpp
LinuxSyscalls/SyscallsSMCTracking.cpp
LinuxSyscalls/SyscallsVMATracking.cpp
LinuxSyscalls/Utils/Threads.cpp
LinuxSyscalls/x32/Syscalls.cpp
LinuxSyscalls/x32/EPoll.cpp
LinuxSyscalls/x32/FD.cpp
LinuxSyscalls/x32/FS.cpp
LinuxSyscalls/x32/Info.cpp
LinuxSyscalls/x32/IO.cpp
LinuxSyscalls/x32/Memory.cpp
LinuxSyscalls/x32/Msg.cpp
LinuxSyscalls/x32/NotImplemented.cpp
LinuxSyscalls/x32/Semaphore.cpp
LinuxSyscalls/x32/Sched.cpp
LinuxSyscalls/x32/Signals.cpp
LinuxSyscalls/x32/Socket.cpp
LinuxSyscalls/x32/Stubs.cpp
LinuxSyscalls/x32/Thread.cpp
LinuxSyscalls/x32/Time.cpp
LinuxSyscalls/x32/Timer.cpp
LinuxSyscalls/x32/IoctlEmulation.cpp
LinuxSyscalls/x64/EPoll.cpp
LinuxSyscalls/x64/FD.cpp
LinuxSyscalls/x64/IO.cpp
LinuxSyscalls/x64/Ioctl.cpp
LinuxSyscalls/x64/Info.cpp
LinuxSyscalls/x64/Memory.cpp
LinuxSyscalls/x64/Msg.cpp
LinuxSyscalls/x64/NotImplemented.cpp
LinuxSyscalls/x64/Semaphore.cpp
LinuxSyscalls/x64/Sched.cpp
LinuxSyscalls/x64/Signals.cpp
LinuxSyscalls/x64/Socket.cpp
LinuxSyscalls/x64/Thread.cpp
LinuxSyscalls/x64/Syscalls.cpp
LinuxSyscalls/x64/Time.cpp
LinuxSyscalls/Syscalls/EPoll.cpp
LinuxSyscalls/Syscalls/FD.cpp
LinuxSyscalls/Syscalls/FS.cpp
LinuxSyscalls/Syscalls/Info.cpp
LinuxSyscalls/Syscalls/IO.cpp
LinuxSyscalls/Syscalls/IOUring.cpp
LinuxSyscalls/Syscalls/Key.cpp
LinuxSyscalls/Syscalls/Memory.cpp
LinuxSyscalls/Syscalls/Msg.cpp
LinuxSyscalls/Syscalls/Namespace.cpp
LinuxSyscalls/Syscalls/Sched.cpp
LinuxSyscalls/Syscalls/Semaphore.cpp
LinuxSyscalls/Syscalls/SHM.cpp
LinuxSyscalls/Syscalls/Signals.cpp
LinuxSyscalls/Syscalls/Socket.cpp
LinuxSyscalls/Syscalls/Thread.cpp
LinuxSyscalls/Syscalls/Time.cpp
LinuxSyscalls/Syscalls/Timer.cpp
LinuxSyscalls/Syscalls/NotImplemented.cpp
LinuxSyscalls/Syscalls/Stubs.cpp)
add_library(LinuxEmulation STATIC ${SRCS})
target_compile_options(LinuxEmulation
PRIVATE
-Wall
-Werror=cast-qual
-Werror=ignored-qualifiers
-Werror=implicit-fallthrough
-Wno-trigraphs
-fwrapv
)
target_include_directories(LinuxEmulation
PRIVATE
${CMAKE_BINARY_DIR}/generated
${CMAKE_CURRENT_SOURCE_DIR}/
${PROJECT_SOURCE_DIR}/External/drm-headers/include/
)
target_include_directories(LinuxEmulation
INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}/
)
target_link_libraries(LinuxEmulation
PRIVATE
Common
CommonTools
)
target_link_libraries(LinuxEmulation
INTERFACE
FEXCore
)
set(HEADERS_TO_VERIFY
LinuxSyscalls/x32/Types.h x86_32 # This needs to match structs to 32bit structs
LinuxSyscalls/x32/Ioctl/asound.h x86_32 # This needs to match structs to 32bit structs
LinuxSyscalls/x32/Ioctl/drm.h x86_32 # This needs to match structs to 32bit structs
LinuxSyscalls/x32/Ioctl/streams.h x86_32 # This needs to match structs to 32bit structs
LinuxSyscalls/x32/Ioctl/usbdev.h x86_32 # This needs to match structs to 32bit structs
LinuxSyscalls/x32/Ioctl/input.h x86_32 # This needs to match structs to 32bit structs
LinuxSyscalls/x32/Ioctl/sockios.h x86_32 # This needs to match structs to 32bit structs
LinuxSyscalls/x32/Ioctl/joystick.h x86_32 # This needs to match structs to 32bit structs
LinuxSyscalls/x64/Types.h x86_64 # This needs to match structs to 64bit structs
)
list(LENGTH HEADERS_TO_VERIFY ARG_COUNT)
math(EXPR ARG_COUNT "${ARG_COUNT}-1")
set (ARGS
"-x" "c++"
"-std=c++20"
"-fno-operator-names"
"-I${PROJECT_SOURCE_DIR}/External/drm-headers/include/"
"-I${CMAKE_CURRENT_SOURCE_DIR}/../")
# Global include directories
get_directory_property (INC_DIRS INCLUDE_DIRECTORIES)
list(TRANSFORM INC_DIRS PREPEND "-I")
list(APPEND ARGS ${INC_DIRS})
# FEXCore directories
get_target_property(INC_DIRS FEXCore INTERFACE_INCLUDE_DIRECTORIES)
list(TRANSFORM INC_DIRS PREPEND "-I")
list(APPEND ARGS ${INC_DIRS})
get_target_property(INC_DIRS LinuxEmulation INTERFACE_INCLUDE_DIRECTORIES)
list(TRANSFORM INC_DIRS PREPEND "-I")
list(APPEND ARGS ${INC_DIRS})
foreach(Index RANGE 0 ${ARG_COUNT} 2)
math(EXPR TEST_TYPE_INDEX "${Index}+1")
list(GET HEADERS_TO_VERIFY ${Index} HEADER)
list(GET HEADERS_TO_VERIFY ${TEST_TYPE_INDEX} TEST_TYPE)
file(RELATIVE_PATH REL_HEADER ${CMAKE_BINARY_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/${HEADER}")
set(TEST_NAME "${TEST_DESC}/Test_verify_${HEADER}")
set(TEST_NAME_ARCH "${TEST_DESC}/Test_verify_arch_${HEADER}")
add_test(
NAME ${TEST_NAME}_x86_64
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
COMMAND "python3" "${CMAKE_SOURCE_DIR}/Scripts/StructPackVerifier.py" "-c1" "x86_64" "${REL_HEADER}" ${ARGS})
add_test(
NAME ${TEST_NAME}_aarch64
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
COMMAND "python3" "${CMAKE_SOURCE_DIR}/Scripts/StructPackVerifier.py" "-c1" "aarch64" "${REL_HEADER}" ${ARGS})
add_test(
NAME ${TEST_NAME_ARCH}_x86_64
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
COMMAND "python3" "${CMAKE_SOURCE_DIR}/Scripts/StructPackVerifier.py" "-c1" "x86_64" "-c2" "${TEST_TYPE}" "${REL_HEADER}" ${ARGS})
add_test(
NAME ${TEST_NAME_ARCH}_aarch64
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
COMMAND "python3" "${CMAKE_SOURCE_DIR}/Scripts/StructPackVerifier.py" "-c1" "aarch64" "-c2" "${TEST_TYPE}" "${REL_HEADER}" ${ARGS})
set_property(TEST ${TEST_NAME}_x86_64 APPEND PROPERTY DEPENDS "${HEADER}")
set_property(TEST ${TEST_NAME}_aarch64 APPEND PROPERTY DEPENDS "${HEADER}")
set_property(TEST ${TEST_NAME_ARCH}_x86_64 APPEND PROPERTY DEPENDS "${HEADER}")
set_property(TEST ${TEST_NAME_ARCH}_aarch64 APPEND PROPERTY DEPENDS "${HEADER}")
endforeach()
execute_process(COMMAND "nproc" OUTPUT_VARIABLE CORES)
string(STRIP ${CORES} CORES)
add_custom_target(
struct_verifier
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
USES_TERMINAL
COMMAND "ctest" "--output-on-failure" "--timeout" "302" "-j${CORES}" "-R" "Test_verify*")

Some files were not shown because too many files have changed in this diff Show More