mirror of
https://github.com/momo5502/emulator.git
synced 2026-01-20 12:13:57 +00:00
Explicitly pass desired backend to emulator
This commit is contained in:
23
src/backend-selection/CMakeLists.txt
Normal file
23
src/backend-selection/CMakeLists.txt
Normal file
@@ -0,0 +1,23 @@
|
||||
file(GLOB_RECURSE SRC_FILES CONFIGURE_DEPENDS
|
||||
*.cpp
|
||||
*.hpp
|
||||
*.rc
|
||||
)
|
||||
|
||||
list(SORT SRC_FILES)
|
||||
|
||||
add_library(backend-selection ${SRC_FILES})
|
||||
|
||||
momo_assign_source_group(${SRC_FILES})
|
||||
|
||||
target_include_directories(backend-selection INTERFACE "${CMAKE_CURRENT_LIST_DIR}")
|
||||
|
||||
target_link_libraries(backend-selection PRIVATE
|
||||
unicorn-emulator
|
||||
)
|
||||
|
||||
if (MOMO_ENABLE_RUST_CODE)
|
||||
target_link_libraries(backend-selection PRIVATE
|
||||
icicle-emulator
|
||||
)
|
||||
endif()
|
||||
23
src/backend-selection/backend_selection.cpp
Normal file
23
src/backend-selection/backend_selection.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#include "backend_selection.hpp"
|
||||
|
||||
#include <string_view>
|
||||
#include <unicorn_x86_64_emulator.hpp>
|
||||
|
||||
#if MOMO_ENABLE_RUST_CODE
|
||||
#include <icicle_x86_64_emulator.hpp>
|
||||
#endif
|
||||
|
||||
using namespace std::literals;
|
||||
|
||||
std::unique_ptr<x86_64_emulator> create_x86_64_emulator()
|
||||
{
|
||||
#if MOMO_ENABLE_RUST_CODE
|
||||
const auto* env = getenv("EMULATOR_ICICLE");
|
||||
if (env && (env == "1"sv || env == "true"sv))
|
||||
{
|
||||
return icicle::create_x86_64_emulator();
|
||||
}
|
||||
#endif
|
||||
|
||||
return unicorn::create_x86_64_emulator();
|
||||
}
|
||||
6
src/backend-selection/backend_selection.hpp
Normal file
6
src/backend-selection/backend_selection.hpp
Normal file
@@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <arch_emulator.hpp>
|
||||
|
||||
std::unique_ptr<x86_64_emulator> create_x86_64_emulator();
|
||||
Reference in New Issue
Block a user