mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-28 15:57:03 -05:00
build/plugins: Added initial support for Rust plugins (#327)
* build: Added initial support for Rust plugins * github: Install correct rust version * github: Fixed rustup command * github: Fix swapped win/linux commands * github: Install linux rust toolchain on Linux * github: Add rustup parameters to correct command * build: libimhex-rust -> hex * rust-plugins: Disable optimization to export functions correctly * build: Use cdylib instead of dylib * build: Fixed rust building and artifact copying * build: Fixed installing plugins * build: Fix copying and installing on Windows * github: Added windows debugging * github: Use curl instead of wget * github: Added debug on failure * github: Update path variable with rust toolchain path * build/github: Set rust location so cmake can find it * build: Remove leftovers * api: Added rust wrappers for the ImHexAPI * rust: Fixed compile flags with older gcc/clang * build: Enable concepts for cxx.rs * build: Explicitly set compiler for cxx.rs * rust: Added imgui-rs to libimhex-rust * rust: Export functions with double underscore prefix on mac * rust: Export functions adjusted for ABI * Add Rust target folder to gitignore * Add vendored imgui-rs copy * Add Context::current() to vendored imgui-rs * Fix libimhex not exporting cimgui symbols * Simplify plugin export mangling * build: Fixed cimgui linking * build: Only specify --export-all-symbols on Windows * Add context setting to Rust plugins * rust: Cleanup * deps: Update curl Co-authored-by: jam1garner <8260240+jam1garner@users.noreply.github.com>
This commit is contained in:
32
plugins/example_cpp/CMakeLists.txt
Normal file
32
plugins/example_cpp/CMakeLists.txt
Normal file
@@ -0,0 +1,32 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
# Change this to the name of your plugin #
|
||||
project(example_cpp)
|
||||
|
||||
# Add your source files here #
|
||||
add_library(${PROJECT_NAME} SHARED
|
||||
source/plugin_example.cpp
|
||||
)
|
||||
|
||||
# Add additional include directories here #
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE include)
|
||||
# Add additional libraries here #
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE libimhex)
|
||||
|
||||
|
||||
|
||||
# ---- No need to change anything from here downwards unless you know what you're doing ---- #
|
||||
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_SHARED_LIBRARY_PREFIX "")
|
||||
set(CMAKE_SHARED_LIBRARY_SUFFIX ".hexplug")
|
||||
|
||||
if (WIN32)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--allow-multiple-definition -fvisibility=hidden")
|
||||
endif()
|
||||
|
||||
add_compile_definitions(IMHEX_PLUGIN_NAME=${PROJECT_NAME})
|
||||
|
||||
if (NOT TARGET libimhex)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../libimhex ${CMAKE_CURRENT_BINARY_DIR}/plugins/libimhex)
|
||||
endif()
|
||||
24
plugins/example_cpp/source/plugin_example.cpp
Normal file
24
plugins/example_cpp/source/plugin_example.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
#include <hex/plugin.hpp>
|
||||
|
||||
#include <hex/views/view.hpp>
|
||||
|
||||
class ViewExample : public hex::View {
|
||||
public:
|
||||
ViewExample() : hex::View("Example") {}
|
||||
~ViewExample() override {}
|
||||
|
||||
void drawContent() override {
|
||||
if (ImGui::Begin("Example")) {
|
||||
ImGui::Text("Custom plugin window");
|
||||
}
|
||||
ImGui::End();
|
||||
}
|
||||
};
|
||||
|
||||
IMHEX_PLUGIN_SETUP("Example C++", "WerWolv", "Example C++ plugin used as template for plugin devs") {
|
||||
|
||||
ContentRegistry::Views::add<ViewExample>();
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user