mirror of https://github.com/WerWolv/ImHex.git
build: Restructured entire custom plugin system (#1469)
This commit is contained in:
parent
538e79183c
commit
84bfd10416
|
@ -67,3 +67,4 @@ add_subdirectory(tests EXCLUDE_FROM_ALL)
|
||||||
# Configure packaging
|
# Configure packaging
|
||||||
createPackage()
|
createPackage()
|
||||||
generatePDBs()
|
generatePDBs()
|
||||||
|
generateSDKDirectory()
|
|
@ -679,10 +679,9 @@ function(generatePDBs)
|
||||||
WORKING_DIRECTORY ${cv2pdb_SOURCE_DIR}
|
WORKING_DIRECTORY ${cv2pdb_SOURCE_DIR}
|
||||||
COMMAND
|
COMMAND
|
||||||
(
|
(
|
||||||
${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:${PDB}> ${CMAKE_BINARY_DIR}/${GENERATED_PDB}.bak &&
|
|
||||||
${CMAKE_COMMAND} -E remove -f ${CMAKE_BINARY_DIR}/${GENERATED_PDB}.pdb &&
|
${CMAKE_COMMAND} -E remove -f ${CMAKE_BINARY_DIR}/${GENERATED_PDB}.pdb &&
|
||||||
${cv2pdb_SOURCE_DIR}/cv2pdb64.exe ${CMAKE_BINARY_DIR}/${GENERATED_PDB}.bak &&
|
${cv2pdb_SOURCE_DIR}/cv2pdb64.exe
|
||||||
${CMAKE_COMMAND} -E remove -f ${CMAKE_BINARY_DIR}/${GENERATED_PDB}.bak
|
$<TARGET_FILE:${PDB}>
|
||||||
) || (exit 0)
|
) || (exit 0)
|
||||||
DEPENDS $<TARGET_FILE:${PDB}>
|
DEPENDS $<TARGET_FILE:${PDB}>
|
||||||
COMMAND_EXPAND_LISTS)
|
COMMAND_EXPAND_LISTS)
|
||||||
|
@ -694,10 +693,33 @@ function(generatePDBs)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
function(generateSDKDirectory)
|
function(generateSDKDirectory)
|
||||||
|
if (WIN32)
|
||||||
set(SDK_PATH "./sdk")
|
set(SDK_PATH "./sdk")
|
||||||
|
elseif (APPLE)
|
||||||
|
set(SDK_PATH "imhex.app/Contents/Resources/sdk")
|
||||||
|
else()
|
||||||
|
set(SDK_PATH "share/imhex/sdk")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
install(DIRECTORY ${CMAKE_SOURCE_DIR}/lib/libimhex DESTINATION "${SDK_PATH}/lib")
|
||||||
|
install(DIRECTORY ${CMAKE_SOURCE_DIR}/lib/external DESTINATION "${SDK_PATH}/lib")
|
||||||
|
install(DIRECTORY ${CMAKE_SOURCE_DIR}/lib/third_party/imgui DESTINATION "${SDK_PATH}/lib/third_party")
|
||||||
|
if (NOT USE_SYSTEM_FMT)
|
||||||
|
install(DIRECTORY ${CMAKE_SOURCE_DIR}/lib/third_party/fmt DESTINATION "${SDK_PATH}/lib/third_party")
|
||||||
|
endif()
|
||||||
|
if (NOT USE_SYSTEM_NLOHMANN_JSON)
|
||||||
|
install(DIRECTORY ${CMAKE_SOURCE_DIR}/lib/third_party/nlohmann_json DESTINATION "${SDK_PATH}/lib/third_party")
|
||||||
|
endif()
|
||||||
|
|
||||||
install(DIRECTORY ${CMAKE_SOURCE_DIR}/lib/libimhex/include DESTINATION "${SDK_PATH}")
|
|
||||||
install(FILES ${CMAKE_SOURCE_DIR}/cmake/modules/ImHexPlugin.cmake DESTINATION "${SDK_PATH}/cmake/modules")
|
install(FILES ${CMAKE_SOURCE_DIR}/cmake/modules/ImHexPlugin.cmake DESTINATION "${SDK_PATH}/cmake/modules")
|
||||||
|
install(FILES ${CMAKE_SOURCE_DIR}/cmake/build_helpers.cmake DESTINATION "${SDK_PATH}/cmake")
|
||||||
|
install(FILES ${CMAKE_SOURCE_DIR}/cmake/sdk/CMakeLists.txt DESTINATION "${SDK_PATH}")
|
||||||
install(TARGETS libimhex ARCHIVE DESTINATION "${SDK_PATH}/lib")
|
install(TARGETS libimhex ARCHIVE DESTINATION "${SDK_PATH}/lib")
|
||||||
install(TARGETS libimhex RUNTIME DESTINATION "${SDK_PATH}/lib")
|
install(TARGETS libimhex RUNTIME DESTINATION "${SDK_PATH}/lib")
|
||||||
|
install(TARGETS libimhex LIBRARY DESTINATION "${SDK_PATH}/lib")
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(addIncludesFromLibrary target library)
|
||||||
|
get_target_property(library_include_dirs ${library} INTERFACE_INCLUDE_DIRECTORIES)
|
||||||
|
target_include_directories(${target} PRIVATE ${library_include_dirs})
|
||||||
endfunction()
|
endfunction()
|
|
@ -24,7 +24,8 @@ macro(add_imhex_plugin)
|
||||||
|
|
||||||
# Add include directories and link libraries
|
# Add include directories and link libraries
|
||||||
target_include_directories(${IMHEX_PLUGIN_NAME} PUBLIC ${IMHEX_PLUGIN_INCLUDES})
|
target_include_directories(${IMHEX_PLUGIN_NAME} PUBLIC ${IMHEX_PLUGIN_INCLUDES})
|
||||||
target_link_libraries(${IMHEX_PLUGIN_NAME} PRIVATE libimhex ${FMT_LIBRARIES} ${IMHEX_PLUGIN_LIBRARIES})
|
target_link_libraries(${IMHEX_PLUGIN_NAME} PRIVATE libimhex ${IMHEX_PLUGIN_LIBRARIES} fmt::fmt imgui_all_includes libwolv)
|
||||||
|
addIncludesFromLibrary(${IMHEX_PLUGIN_NAME} libpl)
|
||||||
|
|
||||||
# Add IMHEX_PROJECT_NAME and IMHEX_VERSION define
|
# Add IMHEX_PROJECT_NAME and IMHEX_VERSION define
|
||||||
target_compile_definitions(${IMHEX_PLUGIN_NAME} PRIVATE IMHEX_PROJECT_NAME="${IMHEX_PLUGIN_NAME}")
|
target_compile_definitions(${IMHEX_PLUGIN_NAME} PRIVATE IMHEX_PROJECT_NAME="${IMHEX_PLUGIN_NAME}")
|
||||||
|
@ -53,7 +54,9 @@ macro(add_imhex_plugin)
|
||||||
target_link_libraries(${IMHEX_PLUGIN_NAME} PRIVATE ${LIBROMFS_LIBRARY})
|
target_link_libraries(${IMHEX_PLUGIN_NAME} PRIVATE ${LIBROMFS_LIBRARY})
|
||||||
|
|
||||||
# Add the new plugin to the main dependency list so it gets built by default
|
# Add the new plugin to the main dependency list so it gets built by default
|
||||||
|
if (TARGET imhex_all)
|
||||||
add_dependencies(imhex_all ${IMHEX_PLUGIN_NAME})
|
add_dependencies(imhex_all ${IMHEX_PLUGIN_NAME})
|
||||||
|
endif()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
macro(add_romfs_resource input output)
|
macro(add_romfs_resource input output)
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
cmake_minimum_required(VERSION 3.20)
|
||||||
|
project(ImHexSDK)
|
||||||
|
|
||||||
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
|
||||||
|
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/build_helpers.cmake")
|
||||||
|
|
||||||
|
set(IMHEX_BASE_FOLDER ${CMAKE_CURRENT_SOURCE_DIR} PARENT_SCOPE)
|
||||||
|
include(ImHexPlugin)
|
||||||
|
|
||||||
|
function(add_subdirectory_if_exists folder)
|
||||||
|
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${folder}/CMakeLists.txt")
|
||||||
|
add_subdirectory("${folder}")
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
set(IMHEX_EXTERNAL_PLUGIN_BUILD ON)
|
||||||
|
add_custom_target(imhex_all)
|
||||||
|
|
||||||
|
add_subdirectory(lib/third_party/imgui)
|
||||||
|
add_subdirectory_if_exists(lib/third_party/fmt)
|
||||||
|
add_subdirectory_if_exists(lib/third_party/nlohmann_json)
|
||||||
|
|
||||||
|
add_subdirectory(lib/external/libwolv)
|
||||||
|
|
||||||
|
set(LIBPL_BUILD_CLI_AS_EXECUTABLE OFF)
|
||||||
|
add_subdirectory(lib/external/pattern_language)
|
||||||
|
|
||||||
|
add_subdirectory(lib/libimhex)
|
||||||
|
|
||||||
|
if (WIN32)
|
||||||
|
set_target_properties(libimhex PROPERTIES
|
||||||
|
IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/lib/libimhex.dll"
|
||||||
|
IMPORTED_IMPLIB "${CMAKE_CURRENT_SOURCE_DIR}/lib/liblibimhex.dll.a"
|
||||||
|
INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/lib/libimhex/include")
|
||||||
|
elseif (APPLE)
|
||||||
|
set_target_properties(libimhex PROPERTIES
|
||||||
|
IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/lib/libimhex.dylib"
|
||||||
|
INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/lib/libimhex/include")
|
||||||
|
else()
|
||||||
|
set_target_properties(libimhex PROPERTIES
|
||||||
|
IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/lib/libimhex.so"
|
||||||
|
INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/lib/libimhex/include")
|
||||||
|
endif()
|
|
@ -125,6 +125,7 @@ cp -a lib/third_party/xdgpp/LICENSE %{buildroot
|
||||||
%{_libdir}/libimhex.so*
|
%{_libdir}/libimhex.so*
|
||||||
%{_libdir}/%{name}/
|
%{_libdir}/%{name}/
|
||||||
%{_metainfodir}/net.werwolv.%{name}.metainfo.xml
|
%{_metainfodir}/net.werwolv.%{name}.metainfo.xml
|
||||||
|
%{_datadir}/%{name}/sdk/
|
||||||
|
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
|
|
@ -65,12 +65,19 @@ endif ()
|
||||||
|
|
||||||
add_compile_definitions(IMHEX_PROJECT_NAME="${PROJECT_NAME}")
|
add_compile_definitions(IMHEX_PROJECT_NAME="${PROJECT_NAME}")
|
||||||
|
|
||||||
|
if (IMHEX_EXTERNAL_PLUGIN_BUILD)
|
||||||
|
add_library(libimhex IMPORTED SHARED GLOBAL)
|
||||||
|
set(LIBIMHEX_LIBRARY_TYPE INTERFACE)
|
||||||
|
else()
|
||||||
if (IMHEX_STATIC_LINK_PLUGINS)
|
if (IMHEX_STATIC_LINK_PLUGINS)
|
||||||
add_library(libimhex STATIC ${LIBIMHEX_SOURCES})
|
add_library(libimhex STATIC ${LIBIMHEX_SOURCES})
|
||||||
else()
|
else()
|
||||||
add_library(libimhex SHARED ${LIBIMHEX_SOURCES})
|
add_library(libimhex SHARED ${LIBIMHEX_SOURCES})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
set(LIBIMHEX_LIBRARY_TYPE PUBLIC)
|
||||||
|
endif()
|
||||||
|
|
||||||
set_target_properties(libimhex PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
set_target_properties(libimhex PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||||
enableUnityBuild(libimhex)
|
enableUnityBuild(libimhex)
|
||||||
setupCompilerFlags(libimhex)
|
setupCompilerFlags(libimhex)
|
||||||
|
@ -78,16 +85,17 @@ setupCompilerFlags(libimhex)
|
||||||
include(GenerateExportHeader)
|
include(GenerateExportHeader)
|
||||||
generate_export_header(libimhex)
|
generate_export_header(libimhex)
|
||||||
|
|
||||||
target_include_directories(libimhex PUBLIC include ${XDGPP_INCLUDE_DIRS} ${MBEDTLS_INCLUDE_DIR} ${CAPSTONE_INCLUDE_DIRS} ${MAGIC_INCLUDE_DIRS} ${LLVM_INCLUDE_DIRS} ${FMT_INCLUDE_DIRS} ${CURL_INCLUDE_DIRS} ${YARA_INCLUDE_DIRS} ${LIBBACKTRACE_INCLUDE_DIRS})
|
target_include_directories(libimhex ${LIBIMHEX_LIBRARY_TYPE} include ${XDGPP_INCLUDE_DIRS} ${MBEDTLS_INCLUDE_DIR} ${MAGIC_INCLUDE_DIRS} ${LLVM_INCLUDE_DIRS} ${FMT_INCLUDE_DIRS} ${CURL_INCLUDE_DIRS} ${LIBBACKTRACE_INCLUDE_DIRS})
|
||||||
target_link_directories(libimhex PUBLIC ${MBEDTLS_LIBRARY_DIR} ${CAPSTONE_LIBRARY_DIRS} ${MAGIC_LIBRARY_DIRS})
|
target_link_directories(libimhex ${LIBIMHEX_LIBRARY_TYPE} ${MBEDTLS_LIBRARY_DIR} ${MAGIC_LIBRARY_DIRS})
|
||||||
|
|
||||||
if (NOT EMSCRIPTEN)
|
if (NOT EMSCRIPTEN)
|
||||||
# curl is only used in non-emscripten builds
|
# curl is only used in non-emscripten builds
|
||||||
target_include_directories(libimhex PUBLIC ${CURL_INCLUDE_DIRS})
|
target_include_directories(libimhex ${LIBIMHEX_LIBRARY_TYPE} ${CURL_INCLUDE_DIRS})
|
||||||
target_link_libraries(libimhex PUBLIC ${LIBCURL_LIBRARIES})
|
target_link_libraries(libimhex ${LIBIMHEX_LIBRARY_TYPE} ${LIBCURL_LIBRARIES})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
if (NOT IMHEX_EXTERNAL_PLUGIN_BUILD)
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
set_target_properties(libimhex PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
|
set_target_properties(libimhex PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
|
||||||
target_link_options(libimhex PRIVATE -Wl,--export-all-symbols)
|
target_link_options(libimhex PRIVATE -Wl,--export-all-symbols)
|
||||||
|
@ -96,8 +104,10 @@ elseif (APPLE)
|
||||||
target_link_libraries(libimhex PUBLIC ${FOUNDATION})
|
target_link_libraries(libimhex PUBLIC ${FOUNDATION})
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
target_link_libraries(libimhex PRIVATE ${FMT_LIBRARIES})
|
target_link_libraries(libimhex PRIVATE microtar libpl plcli libpl-gen libwolv ${FMT_LIBRARIES} ${NFD_LIBRARIES} magic dl ${IMGUI_LIBRARIES} ${NLOHMANN_JSON_LIBRARIES} ${MBEDTLS_LIBRARIES} ${LIBBACKTRACE_LIBRARIES} ${JTHREAD_LIBRARIES})
|
||||||
target_link_libraries(libimhex PUBLIC dl ${IMGUI_LIBRARIES} ${NFD_LIBRARIES} magic ${CAPSTONE_LIBRARIES} LLVMDemangle microtar ${NLOHMANN_JSON_LIBRARIES} ${YARA_LIBRARIES} ${MBEDTLS_LIBRARIES} ${LIBBACKTRACE_LIBRARIES} plcli libpl libpl-gen ${MINIAUDIO_LIBRARIES} ${JTHREAD_LIBRARIES} wolv::utils wolv::io wolv::hash wolv::net wolv::containers wolv::math_eval)
|
endif()
|
||||||
|
|
||||||
|
target_link_libraries(libimhex ${LIBIMHEX_LIBRARY_TYPE} ${NLOHMANN_JSON_LIBRARIES} ${IMGUI_LIBRARIES} LLVMDemangle)
|
||||||
|
|
||||||
set_property(TARGET libimhex PROPERTY INTERPROCEDURAL_OPTIMIZATION FALSE)
|
set_property(TARGET libimhex PROPERTY INTERPROCEDURAL_OPTIMIZATION FALSE)
|
||||||
|
|
||||||
|
|
|
@ -4,19 +4,16 @@
|
||||||
#include <hex/api/localization_manager.hpp>
|
#include <hex/api/localization_manager.hpp>
|
||||||
#include <hex/helpers/concepts.hpp>
|
#include <hex/helpers/concepts.hpp>
|
||||||
|
|
||||||
#include <pl/pattern_language.hpp>
|
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <span>
|
#include <span>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <thread>
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <jthread.hpp>
|
#include <pl/pattern_language.hpp>
|
||||||
|
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
#include <wolv/io/fs.hpp>
|
||||||
|
|
||||||
using ImGuiDataType = int;
|
using ImGuiDataType = int;
|
||||||
using ImGuiInputTextFlags = int;
|
using ImGuiInputTextFlags = int;
|
||||||
|
@ -972,12 +969,6 @@ namespace hex {
|
||||||
namespace impl {
|
namespace impl {
|
||||||
using Callback = std::function<void()>;
|
using Callback = std::function<void()>;
|
||||||
|
|
||||||
struct Service {
|
|
||||||
std::string name;
|
|
||||||
std::jthread thread;
|
|
||||||
};
|
|
||||||
|
|
||||||
std::vector<Service> &getServices();
|
|
||||||
void stopServices();
|
void stopServices();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,15 +4,12 @@
|
||||||
#include <hex/api/localization_manager.hpp>
|
#include <hex/api/localization_manager.hpp>
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <thread>
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <condition_variable>
|
#include <condition_variable>
|
||||||
|
|
||||||
#include <jthread.hpp>
|
|
||||||
|
|
||||||
namespace hex {
|
namespace hex {
|
||||||
|
|
||||||
class TaskHolder;
|
class TaskHolder;
|
||||||
|
@ -166,8 +163,6 @@ namespace hex {
|
||||||
static void runDeferredCalls();
|
static void runDeferredCalls();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void runner(const std::stop_token &stopToken);
|
|
||||||
|
|
||||||
static TaskHolder createTask(std::string name, u64 maxValue, bool background, std::function<void(Task &)> function);
|
static TaskHolder createTask(std::string name, u64 maxValue, bool background, std::function<void(Task &)> function);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,9 @@
|
||||||
|
|
||||||
#include <hex/helpers/fs.hpp>
|
#include <hex/helpers/fs.hpp>
|
||||||
|
|
||||||
#include <microtar.h>
|
#include <memory>
|
||||||
|
|
||||||
|
struct mtar_t;
|
||||||
|
|
||||||
namespace hex {
|
namespace hex {
|
||||||
|
|
||||||
|
@ -32,28 +34,28 @@ namespace hex {
|
||||||
*/
|
*/
|
||||||
std::string getOpenErrorString() const;
|
std::string getOpenErrorString() const;
|
||||||
|
|
||||||
[[nodiscard]] std::vector<u8> readVector(const std::fs::path &path);
|
[[nodiscard]] std::vector<u8> readVector(const std::fs::path &path) const;
|
||||||
[[nodiscard]] std::string readString(const std::fs::path &path);
|
[[nodiscard]] std::string readString(const std::fs::path &path) const;
|
||||||
|
|
||||||
void writeVector(const std::fs::path &path, const std::vector<u8> &data);
|
void writeVector(const std::fs::path &path, const std::vector<u8> &data) const;
|
||||||
void writeString(const std::fs::path &path, const std::string &data);
|
void writeString(const std::fs::path &path, const std::string &data) const;
|
||||||
|
|
||||||
[[nodiscard]] std::vector<std::fs::path> listEntries(const std::fs::path &basePath = "/");
|
[[nodiscard]] std::vector<std::fs::path> listEntries(const std::fs::path &basePath = "/") const;
|
||||||
[[nodiscard]] bool contains(const std::fs::path &path);
|
[[nodiscard]] bool contains(const std::fs::path &path) const;
|
||||||
|
|
||||||
void extract(const std::fs::path &path, const std::fs::path &outputPath);
|
void extract(const std::fs::path &path, const std::fs::path &outputPath) const;
|
||||||
void extractAll(const std::fs::path &outputPath);
|
void extractAll(const std::fs::path &outputPath) const;
|
||||||
|
|
||||||
[[nodiscard]] bool isValid() const { return m_valid; }
|
[[nodiscard]] bool isValid() const { return m_valid; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
mtar_t m_ctx = { };
|
std::unique_ptr<mtar_t> m_ctx;
|
||||||
std::fs::path m_path;
|
std::fs::path m_path;
|
||||||
|
|
||||||
bool m_valid = false;
|
bool m_valid = false;
|
||||||
|
|
||||||
// These will be updated when the constructor is called
|
// These will be updated when the constructor is called
|
||||||
int m_tarOpenErrno = MTAR_ESUCCESS;
|
int m_tarOpenErrno = 0;
|
||||||
int m_fileOpenErrno = 0;
|
int m_fileOpenErrno = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
#include <hex/data_processor/node.hpp>
|
#include <hex/data_processor/node.hpp>
|
||||||
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <thread>
|
|
||||||
#include <jthread.hpp>
|
#include <jthread.hpp>
|
||||||
|
|
||||||
#if defined(OS_WEB)
|
#if defined(OS_WEB)
|
||||||
|
@ -1000,6 +999,11 @@ namespace hex {
|
||||||
|
|
||||||
namespace impl {
|
namespace impl {
|
||||||
|
|
||||||
|
struct Service {
|
||||||
|
std::string name;
|
||||||
|
std::jthread thread;
|
||||||
|
};
|
||||||
|
|
||||||
std::vector<Service> &getServices() {
|
std::vector<Service> &getServices() {
|
||||||
static std::vector<Service> services;
|
static std::vector<Service> services;
|
||||||
|
|
||||||
|
@ -1007,14 +1011,18 @@ namespace hex {
|
||||||
}
|
}
|
||||||
|
|
||||||
void stopServices() {
|
void stopServices() {
|
||||||
for (auto &service : getServices()) {
|
auto &services = getServices();
|
||||||
|
|
||||||
|
for (auto &service : services) {
|
||||||
service.thread.request_stop();
|
service.thread.request_stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto &service : getServices()) {
|
for (auto &service : services) {
|
||||||
if (service.thread.joinable())
|
if (service.thread.joinable())
|
||||||
service.thread.join();
|
service.thread.join();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
services.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
#include <jthread.hpp>
|
||||||
|
|
||||||
#if defined(OS_WINDOWS)
|
#if defined(OS_WINDOWS)
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <processthreadsapi.h>
|
#include <processthreadsapi.h>
|
||||||
|
@ -227,31 +229,8 @@ namespace hex {
|
||||||
log::debug("Initializing task manager thread pool with {} workers.", threadCount);
|
log::debug("Initializing task manager thread pool with {} workers.", threadCount);
|
||||||
|
|
||||||
// Create worker threads
|
// Create worker threads
|
||||||
for (u32 i = 0; i < threadCount; i++)
|
for (u32 i = 0; i < threadCount; i++) {
|
||||||
s_workers.emplace_back(TaskManager::runner);
|
s_workers.emplace_back([](const std::stop_token &stopToken) {
|
||||||
}
|
|
||||||
|
|
||||||
void TaskManager::exit() {
|
|
||||||
// Interrupt all tasks
|
|
||||||
for (auto &task : s_tasks) {
|
|
||||||
task->interrupt();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ask worker threads to exit after finishing their task
|
|
||||||
for (auto &thread : s_workers)
|
|
||||||
thread.request_stop();
|
|
||||||
|
|
||||||
// Wake up all the idle worker threads so they can exit
|
|
||||||
s_jobCondVar.notify_all();
|
|
||||||
|
|
||||||
// Wait for all worker threads to exit
|
|
||||||
s_workers.clear();
|
|
||||||
|
|
||||||
s_tasks.clear();
|
|
||||||
s_taskQueue.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void TaskManager::runner(const std::stop_token &stopToken) {
|
|
||||||
while (true) {
|
while (true) {
|
||||||
std::shared_ptr<Task> task;
|
std::shared_ptr<Task> task;
|
||||||
|
|
||||||
|
@ -299,6 +278,28 @@ namespace hex {
|
||||||
|
|
||||||
task->finish();
|
task->finish();
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TaskManager::exit() {
|
||||||
|
// Interrupt all tasks
|
||||||
|
for (auto &task : s_tasks) {
|
||||||
|
task->interrupt();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ask worker threads to exit after finishing their task
|
||||||
|
for (auto &thread : s_workers)
|
||||||
|
thread.request_stop();
|
||||||
|
|
||||||
|
// Wake up all the idle worker threads so they can exit
|
||||||
|
s_jobCondVar.notify_all();
|
||||||
|
|
||||||
|
// Wait for all worker threads to exit
|
||||||
|
s_workers.clear();
|
||||||
|
|
||||||
|
s_tasks.clear();
|
||||||
|
s_taskQueue.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
TaskHolder TaskManager::createTask(std::string name, u64 maxValue, bool background, std::function<void(Task&)> function) {
|
TaskHolder TaskManager::createTask(std::string name, u64 maxValue, bool background, std::function<void(Task&)> function) {
|
||||||
|
|
|
@ -5,12 +5,14 @@
|
||||||
|
|
||||||
#include <wolv/io/file.hpp>
|
#include <wolv/io/file.hpp>
|
||||||
|
|
||||||
|
#include <microtar.h>
|
||||||
|
|
||||||
namespace hex {
|
namespace hex {
|
||||||
|
|
||||||
using namespace hex::literals;
|
using namespace hex::literals;
|
||||||
|
|
||||||
Tar::Tar(const std::fs::path &path, Mode mode) {
|
Tar::Tar(const std::fs::path &path, Mode mode) {
|
||||||
int tar_error = MTAR_ESUCCESS;
|
int tarError = MTAR_ESUCCESS;
|
||||||
|
|
||||||
// Explicitly create file so a short path gets generated
|
// Explicitly create file so a short path gets generated
|
||||||
if (mode == Mode::Create) {
|
if (mode == Mode::Create) {
|
||||||
|
@ -18,21 +20,23 @@ namespace hex {
|
||||||
file.flush();
|
file.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_ctx = std::make_unique<mtar_t>();
|
||||||
|
|
||||||
auto shortPath = wolv::io::fs::toShortPath(path);
|
auto shortPath = wolv::io::fs::toShortPath(path);
|
||||||
if (mode == Tar::Mode::Read)
|
if (mode == Tar::Mode::Read)
|
||||||
tar_error = mtar_open(&m_ctx, shortPath.string().c_str(), "r");
|
tarError = mtar_open(m_ctx.get(), shortPath.string().c_str(), "r");
|
||||||
else if (mode == Tar::Mode::Write)
|
else if (mode == Tar::Mode::Write)
|
||||||
tar_error = mtar_open(&m_ctx, shortPath.string().c_str(), "a");
|
tarError = mtar_open(m_ctx.get(), shortPath.string().c_str(), "a");
|
||||||
else if (mode == Tar::Mode::Create)
|
else if (mode == Tar::Mode::Create)
|
||||||
tar_error = mtar_open(&m_ctx, shortPath.string().c_str(), "w");
|
tarError = mtar_open(m_ctx.get(), shortPath.string().c_str(), "w");
|
||||||
else
|
else
|
||||||
tar_error = MTAR_EFAILURE;
|
tarError = MTAR_EFAILURE;
|
||||||
|
|
||||||
m_path = path;
|
m_path = path;
|
||||||
m_valid = (tar_error == MTAR_ESUCCESS);
|
m_valid = (tarError == MTAR_ESUCCESS);
|
||||||
|
|
||||||
if (!m_valid) {
|
if (!m_valid) {
|
||||||
m_tarOpenErrno = tar_error;
|
m_tarOpenErrno = tarError;
|
||||||
|
|
||||||
// Hopefully this errno corresponds to the file open call in mtar_open
|
// Hopefully this errno corresponds to the file open call in mtar_open
|
||||||
m_fileOpenErrno = errno;
|
m_fileOpenErrno = errno;
|
||||||
|
@ -44,7 +48,7 @@ namespace hex {
|
||||||
}
|
}
|
||||||
|
|
||||||
Tar::Tar(hex::Tar &&other) noexcept {
|
Tar::Tar(hex::Tar &&other) noexcept {
|
||||||
m_ctx = other.m_ctx;
|
m_ctx = std::move(other.m_ctx);
|
||||||
m_path = other.m_path;
|
m_path = other.m_path;
|
||||||
m_valid = other.m_valid;
|
m_valid = other.m_valid;
|
||||||
m_tarOpenErrno = other.m_tarOpenErrno;
|
m_tarOpenErrno = other.m_tarOpenErrno;
|
||||||
|
@ -55,10 +59,8 @@ namespace hex {
|
||||||
}
|
}
|
||||||
|
|
||||||
Tar &Tar::operator=(Tar &&other) noexcept {
|
Tar &Tar::operator=(Tar &&other) noexcept {
|
||||||
m_ctx = other.m_ctx;
|
m_ctx = std::move(other.m_ctx);
|
||||||
other.m_ctx = { };
|
m_path = std::move(other.m_path);
|
||||||
|
|
||||||
m_path = other.m_path;
|
|
||||||
|
|
||||||
m_valid = other.m_valid;
|
m_valid = other.m_valid;
|
||||||
other.m_valid = false;
|
other.m_valid = false;
|
||||||
|
@ -68,24 +70,24 @@ namespace hex {
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::fs::path> Tar::listEntries(const std::fs::path &basePath) {
|
std::vector<std::fs::path> Tar::listEntries(const std::fs::path &basePath) const {
|
||||||
std::vector<std::fs::path> result;
|
std::vector<std::fs::path> result;
|
||||||
|
|
||||||
const std::string PaxHeaderName = "@PaxHeader";
|
const std::string PaxHeaderName = "@PaxHeader";
|
||||||
mtar_header_t header;
|
mtar_header_t header;
|
||||||
while (mtar_read_header(&m_ctx, &header) != MTAR_ENULLRECORD) {
|
while (mtar_read_header(m_ctx.get(), &header) != MTAR_ENULLRECORD) {
|
||||||
std::fs::path path = header.name;
|
std::fs::path path = header.name;
|
||||||
if (header.name != PaxHeaderName && wolv::io::fs::isSubPath(basePath, path)) {
|
if (header.name != PaxHeaderName && wolv::io::fs::isSubPath(basePath, path)) {
|
||||||
result.emplace_back(header.name);
|
result.emplace_back(header.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
mtar_next(&m_ctx);
|
mtar_next(m_ctx.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Tar::contains(const std::fs::path &path) {
|
bool Tar::contains(const std::fs::path &path) const {
|
||||||
mtar_header_t header;
|
mtar_header_t header;
|
||||||
|
|
||||||
auto fixedPath = path.string();
|
auto fixedPath = path.string();
|
||||||
|
@ -93,7 +95,7 @@ namespace hex {
|
||||||
std::replace(fixedPath.begin(), fixedPath.end(), '\\', '/');
|
std::replace(fixedPath.begin(), fixedPath.end(), '\\', '/');
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return mtar_find(&m_ctx, fixedPath.c_str(), &header) == MTAR_ESUCCESS;
|
return mtar_find(m_ctx.get(), fixedPath.c_str(), &header) == MTAR_ESUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Tar::getOpenErrorString() const {
|
std::string Tar::getOpenErrorString() const {
|
||||||
|
@ -102,22 +104,22 @@ namespace hex {
|
||||||
|
|
||||||
void Tar::close() {
|
void Tar::close() {
|
||||||
if (m_valid) {
|
if (m_valid) {
|
||||||
mtar_finalize(&m_ctx);
|
mtar_finalize(m_ctx.get());
|
||||||
mtar_close(&m_ctx);
|
mtar_close(m_ctx.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
m_ctx = { };
|
m_ctx.reset();
|
||||||
m_valid = false;
|
m_valid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<u8> Tar::readVector(const std::fs::path &path) {
|
std::vector<u8> Tar::readVector(const std::fs::path &path) const {
|
||||||
mtar_header_t header;
|
mtar_header_t header;
|
||||||
|
|
||||||
auto fixedPath = path.string();
|
auto fixedPath = path.string();
|
||||||
#if defined(OS_WINDOWS)
|
#if defined(OS_WINDOWS)
|
||||||
std::replace(fixedPath.begin(), fixedPath.end(), '\\', '/');
|
std::replace(fixedPath.begin(), fixedPath.end(), '\\', '/');
|
||||||
#endif
|
#endif
|
||||||
int ret = mtar_find(&m_ctx, fixedPath.c_str(), &header);
|
int ret = mtar_find(m_ctx.get(), fixedPath.c_str(), &header);
|
||||||
if (ret != MTAR_ESUCCESS){
|
if (ret != MTAR_ESUCCESS){
|
||||||
log::debug("Failed to read vector from path {} in tarred file {}: {}",
|
log::debug("Failed to read vector from path {} in tarred file {}: {}",
|
||||||
path.string(), m_path.string(), mtar_strerror(ret));
|
path.string(), m_path.string(), mtar_strerror(ret));
|
||||||
|
@ -125,17 +127,17 @@ namespace hex {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<u8> result(header.size, 0x00);
|
std::vector<u8> result(header.size, 0x00);
|
||||||
mtar_read_data(&m_ctx, result.data(), result.size());
|
mtar_read_data(m_ctx.get(), result.data(), result.size());
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Tar::readString(const std::fs::path &path) {
|
std::string Tar::readString(const std::fs::path &path) const {
|
||||||
auto result = this->readVector(path);
|
auto result = this->readVector(path);
|
||||||
return { result.begin(), result.end() };
|
return { result.begin(), result.end() };
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tar::writeVector(const std::fs::path &path, const std::vector<u8> &data) {
|
void Tar::writeVector(const std::fs::path &path, const std::vector<u8> &data) const {
|
||||||
if (path.has_parent_path()) {
|
if (path.has_parent_path()) {
|
||||||
std::fs::path pathPart;
|
std::fs::path pathPart;
|
||||||
for (const auto &part : path.parent_path()) {
|
for (const auto &part : path.parent_path()) {
|
||||||
|
@ -145,7 +147,7 @@ namespace hex {
|
||||||
#if defined(OS_WINDOWS)
|
#if defined(OS_WINDOWS)
|
||||||
std::replace(fixedPath.begin(), fixedPath.end(), '\\', '/');
|
std::replace(fixedPath.begin(), fixedPath.end(), '\\', '/');
|
||||||
#endif
|
#endif
|
||||||
mtar_write_dir_header(&m_ctx, fixedPath.c_str());
|
mtar_write_dir_header(m_ctx.get(), fixedPath.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,11 +155,11 @@ namespace hex {
|
||||||
#if defined(OS_WINDOWS)
|
#if defined(OS_WINDOWS)
|
||||||
std::replace(fixedPath.begin(), fixedPath.end(), '\\', '/');
|
std::replace(fixedPath.begin(), fixedPath.end(), '\\', '/');
|
||||||
#endif
|
#endif
|
||||||
mtar_write_file_header(&m_ctx, fixedPath.c_str(), data.size());
|
mtar_write_file_header(m_ctx.get(), fixedPath.c_str(), data.size());
|
||||||
mtar_write_data(&m_ctx, data.data(), data.size());
|
mtar_write_data(m_ctx.get(), data.data(), data.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tar::writeString(const std::fs::path &path, const std::string &data) {
|
void Tar::writeString(const std::fs::path &path, const std::string &data) const {
|
||||||
this->writeVector(path, { data.begin(), data.end() });
|
this->writeVector(path, { data.begin(), data.end() });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,26 +177,26 @@ namespace hex {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tar::extract(const std::fs::path &path, const std::fs::path &outputPath) {
|
void Tar::extract(const std::fs::path &path, const std::fs::path &outputPath) const {
|
||||||
mtar_header_t header;
|
mtar_header_t header;
|
||||||
mtar_find(&m_ctx, path.string().c_str(), &header);
|
mtar_find(m_ctx.get(), path.string().c_str(), &header);
|
||||||
|
|
||||||
writeFile(&m_ctx, &header, outputPath);
|
writeFile(m_ctx.get(), &header, outputPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tar::extractAll(const std::fs::path &outputPath) {
|
void Tar::extractAll(const std::fs::path &outputPath) const {
|
||||||
mtar_header_t header;
|
mtar_header_t header;
|
||||||
while (mtar_read_header(&m_ctx, &header) != MTAR_ENULLRECORD) {
|
while (mtar_read_header(m_ctx.get(), &header) != MTAR_ENULLRECORD) {
|
||||||
const auto filePath = std::fs::absolute(outputPath / std::fs::path(header.name));
|
const auto filePath = std::fs::absolute(outputPath / std::fs::path(header.name));
|
||||||
|
|
||||||
if (filePath.filename() != "@PaxHeader") {
|
if (filePath.filename() != "@PaxHeader") {
|
||||||
|
|
||||||
std::fs::create_directories(filePath.parent_path());
|
std::fs::create_directories(filePath.parent_path());
|
||||||
|
|
||||||
writeFile(&m_ctx, &header, filePath);
|
writeFile(m_ctx.get(), &header, filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
mtar_next(&m_ctx);
|
mtar_next(m_ctx.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,8 @@ project(imgui)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
|
||||||
|
add_library(imgui_all_includes INTERFACE)
|
||||||
|
|
||||||
add_subdirectory(imgui)
|
add_subdirectory(imgui)
|
||||||
add_subdirectory(implot)
|
add_subdirectory(implot)
|
||||||
add_subdirectory(imnodes)
|
add_subdirectory(imnodes)
|
||||||
|
|
|
@ -12,5 +12,7 @@ target_include_directories(imgui_color_text_editor PUBLIC
|
||||||
include
|
include
|
||||||
)
|
)
|
||||||
|
|
||||||
|
target_include_directories(imgui_all_includes INTERFACE include)
|
||||||
|
|
||||||
target_link_libraries(imgui_color_text_editor PRIVATE imgui_includes)
|
target_link_libraries(imgui_color_text_editor PRIVATE imgui_includes)
|
||||||
set_property(TARGET imgui_color_text_editor PROPERTY POSITION_INDEPENDENT_CODE ON)
|
set_property(TARGET imgui_color_text_editor PROPERTY POSITION_INDEPENDENT_CODE ON)
|
|
@ -15,6 +15,7 @@ target_include_directories(imgui_custom PUBLIC
|
||||||
|
|
||||||
target_link_libraries(imgui_custom PRIVATE imgui_includes)
|
target_link_libraries(imgui_custom PRIVATE imgui_includes)
|
||||||
set_property(TARGET imgui_custom PROPERTY POSITION_INDEPENDENT_CODE ON)
|
set_property(TARGET imgui_custom PROPERTY POSITION_INDEPENDENT_CODE ON)
|
||||||
|
target_include_directories(imgui_all_includes INTERFACE include)
|
||||||
|
|
||||||
find_package(PkgConfig REQUIRED)
|
find_package(PkgConfig REQUIRED)
|
||||||
find_package(OpenGL REQUIRED)
|
find_package(OpenGL REQUIRED)
|
||||||
|
|
|
@ -10,3 +10,5 @@ add_library(imgui_fonts INTERFACE)
|
||||||
target_include_directories(imgui_fonts INTERFACE
|
target_include_directories(imgui_fonts INTERFACE
|
||||||
include
|
include
|
||||||
)
|
)
|
||||||
|
|
||||||
|
target_include_directories(imgui_all_includes INTERFACE include)
|
||||||
|
|
|
@ -21,6 +21,7 @@ target_include_directories(imgui_imgui PUBLIC
|
||||||
|
|
||||||
add_library(imgui_includes INTERFACE)
|
add_library(imgui_includes INTERFACE)
|
||||||
target_include_directories(imgui_includes INTERFACE include)
|
target_include_directories(imgui_includes INTERFACE include)
|
||||||
|
target_include_directories(imgui_all_includes INTERFACE include include/misc/freetype)
|
||||||
|
|
||||||
target_compile_options(imgui_imgui PRIVATE -Wno-unknown-warning-option)
|
target_compile_options(imgui_imgui PRIVATE -Wno-unknown-warning-option)
|
||||||
set_property(TARGET imgui_imgui PROPERTY POSITION_INDEPENDENT_CODE ON)
|
set_property(TARGET imgui_imgui PROPERTY POSITION_INDEPENDENT_CODE ON)
|
||||||
|
|
|
@ -13,4 +13,5 @@ target_include_directories(imgui_imnodes PUBLIC
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(imgui_imnodes PRIVATE imgui_includes)
|
target_link_libraries(imgui_imnodes PRIVATE imgui_includes)
|
||||||
|
target_include_directories(imgui_all_includes INTERFACE include)
|
||||||
set_property(TARGET imgui_imnodes PROPERTY POSITION_INDEPENDENT_CODE ON)
|
set_property(TARGET imgui_imnodes PROPERTY POSITION_INDEPENDENT_CODE ON)
|
||||||
|
|
|
@ -15,4 +15,6 @@ target_include_directories(imgui_implot PUBLIC
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(imgui_implot PRIVATE imgui_includes)
|
target_link_libraries(imgui_implot PRIVATE imgui_includes)
|
||||||
|
target_include_directories(imgui_all_includes INTERFACE include)
|
||||||
|
|
||||||
set_property(TARGET imgui_implot PROPERTY POSITION_INDEPENDENT_CODE ON)
|
set_property(TARGET imgui_implot PROPERTY POSITION_INDEPENDENT_CODE ON)
|
||||||
|
|
|
@ -52,7 +52,7 @@ set_target_properties(main PROPERTIES
|
||||||
|
|
||||||
add_compile_definitions(IMHEX_PROJECT_NAME="${PROJECT_NAME}")
|
add_compile_definitions(IMHEX_PROJECT_NAME="${PROJECT_NAME}")
|
||||||
|
|
||||||
target_link_libraries(main PRIVATE libromfs-imhex libimhex ${FMT_LIBRARIES})
|
target_link_libraries(main PRIVATE libromfs-imhex libimhex ${GLFW_LIBRARIES} libwolv libpl plcli libpl-gen ${FMT_LIBRARIES})
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
target_link_libraries(main PRIVATE usp10 wsock32 ws2_32 Dwmapi.lib)
|
target_link_libraries(main PRIVATE usp10 wsock32 ws2_32 Dwmapi.lib)
|
||||||
else ()
|
else ()
|
||||||
|
|
|
@ -125,7 +125,6 @@ namespace hex::init {
|
||||||
ContentRegistry::HexEditor::impl::getVisualizers().clear();
|
ContentRegistry::HexEditor::impl::getVisualizers().clear();
|
||||||
|
|
||||||
ContentRegistry::BackgroundServices::impl::stopServices();
|
ContentRegistry::BackgroundServices::impl::stopServices();
|
||||||
ContentRegistry::BackgroundServices::impl::getServices().clear();
|
|
||||||
|
|
||||||
ContentRegistry::CommunicationInterface::impl::getNetworkEndpoints().clear();
|
ContentRegistry::CommunicationInterface::impl::getNetworkEndpoints().clear();
|
||||||
|
|
||||||
|
|
|
@ -129,6 +129,17 @@ add_imhex_plugin(
|
||||||
|
|
||||||
INCLUDES
|
INCLUDES
|
||||||
include
|
include
|
||||||
|
${CAPSTONE_INCLUDE_DIRS}
|
||||||
|
${YARA_INCLUDE_DIRS}
|
||||||
|
${MINIAUDIO_INCLUDE_DIRS}
|
||||||
|
|
||||||
|
LIBRARIES
|
||||||
|
${CAPSTONE_LIBRARIES}
|
||||||
|
${YARA_LIBRARIES}
|
||||||
|
${MINIAUDIO_LIBRARIES}
|
||||||
|
${JTHREAD_LIBRARIES}
|
||||||
|
${GLFW_LIBRARIES}
|
||||||
|
plcli libpl-gen
|
||||||
)
|
)
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include <hex/ui/view.hpp>
|
#include <hex/ui/view.hpp>
|
||||||
#include <ui/widgets.hpp>
|
#include <ui/widgets.hpp>
|
||||||
|
|
||||||
#include <hex/helpers/disassembler.hpp>
|
#include <content/helpers/disassembler.hpp>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
|
@ -15,6 +15,8 @@ if (WIN32)
|
||||||
source/content/settings_entries.cpp
|
source/content/settings_entries.cpp
|
||||||
INCLUDES
|
INCLUDES
|
||||||
include
|
include
|
||||||
|
LIBRARIES
|
||||||
|
${JTHREAD_LIBRARIES}
|
||||||
)
|
)
|
||||||
|
|
||||||
endif ()
|
endif ()
|
||||||
|
|
|
@ -6,4 +6,4 @@ add_library(tests_common STATIC
|
||||||
source/main.cpp
|
source/main.cpp
|
||||||
)
|
)
|
||||||
target_include_directories(tests_common PUBLIC include)
|
target_include_directories(tests_common PUBLIC include)
|
||||||
target_link_libraries(tests_common PUBLIC libimhex ${FMT_LIBRARIES})
|
target_link_libraries(tests_common PUBLIC libimhex ${FMT_LIBRARIES} libwolv)
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
#include <hex/providers/provider.hpp>
|
#pragma once
|
||||||
|
|
||||||
#include <hex/helpers/logger.hpp>
|
#include <hex/providers/provider.hpp>
|
||||||
#include <stdexcept>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
namespace hex::test {
|
namespace hex::test {
|
||||||
using namespace hex::prv;
|
using namespace hex::prv;
|
||||||
|
|
||||||
class TestProvider : public prv::Provider {
|
class TestProvider : public prv::Provider {
|
||||||
public:
|
public:
|
||||||
explicit TestProvider(std::vector<u8> *data) : Provider() {
|
explicit TestProvider(std::vector<u8> *data) {
|
||||||
this->setData(data);
|
this->setData(data);
|
||||||
}
|
}
|
||||||
~TestProvider() override = default;
|
~TestProvider() override = default;
|
||||||
|
@ -47,11 +47,14 @@ namespace hex::test {
|
||||||
return m_data->size();
|
return m_data->size();
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] virtual std::string getTypeName() const override { return "hex.test.provider.test"; }
|
[[nodiscard]] std::string getTypeName() const override { return "hex.test.provider.test"; }
|
||||||
|
|
||||||
bool open() override { return true; }
|
bool open() override { return true; }
|
||||||
void close() override { }
|
void close() override { }
|
||||||
|
|
||||||
|
nlohmann::json storeSettings(nlohmann::json) const override { return {}; }
|
||||||
|
void loadSettings(const nlohmann::json &) override {};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<u8> *m_data = nullptr;
|
std::vector<u8> *m_data = nullptr;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue