Add project files.
This commit is contained in:
commit
3087fcea8a
71 files changed
+8325
No files matched your search
@@ -0,0 +1,39 @@
|
||||
# Not built through add_lib_module(): a hot-reloadable plugin is a
|
||||
# different shape from an ordinary library module. PluginV1 and its
|
||||
# sibling PluginV2 are two SEPARATE binaries that deliberately export
|
||||
# the SAME extern "C" symbol names (see ../Shared/PluginApi.h) --
|
||||
# that's exactly what lets HotReloadContext line them up and patch one
|
||||
# into the other at runtime. add_lib_module() assumes one canonical
|
||||
# build per module name and would not fit two builds of the same name
|
||||
# needing to coexist, so this is plain add_library(), reusing the
|
||||
# project's usual output-directory/warnings helpers directly. Gated on
|
||||
# BUILD_EXAMPLES exactly like every other target under source/examples/.
|
||||
|
||||
if(BUILD_EXAMPLES)
|
||||
add_library(hotreload_demo_plugin_v1 SHARED src/Plugin.cpp src/CppWidget.cpp)
|
||||
else()
|
||||
add_library(hotreload_demo_plugin_v1 SHARED EXCLUDE_FROM_ALL src/Plugin.cpp src/CppWidget.cpp)
|
||||
endif()
|
||||
|
||||
target_include_directories(hotreload_demo_plugin_v1 PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../Shared)
|
||||
set_target_properties(hotreload_demo_plugin_v1 PROPERTIES
|
||||
OUTPUT_NAME "hotreload_demo_plugin_v1"
|
||||
# Matches add_lib_module()'s own SHARED-library branch
|
||||
# (cmake/BuildHelpers.cmake) exactly, for exactly the same reason:
|
||||
# MinGW's linker exports every global symbol from a DLL by
|
||||
# default, but MSVC exports NONE unless told to -- without this,
|
||||
# PluginApi.h's functions would not be visible in the export table
|
||||
# at all when built with MSVC, silently breaking the whole demo on
|
||||
# that one toolchain.
|
||||
WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
||||
_set_output_dirs(hotreload_demo_plugin_v1
|
||||
"${CMAKE_BINARY_DIR}/${RUNTIME_OUTPUT_SUBDIR}/examples"
|
||||
"${CMAKE_BINARY_DIR}/${LIBRARY_OUTPUT_SUBDIR}/examples")
|
||||
_apply_compile_options(hotreload_demo_plugin_v1)
|
||||
|
||||
# The whole point of this target: give source/HotReload's jump-patch
|
||||
# backends guaranteed room to write into. See cmake/HotReload.cmake.
|
||||
hot_reload_enable_patchable_functions(hotreload_demo_plugin_v1)
|
||||
|
||||
_register_module_target(EXAMPLE hotreload_demo_plugin_v1)
|
||||
add_dependencies(all_examples hotreload_demo_plugin_v1)
|
||||
@@ -0,0 +1,32 @@
|
||||
/* CppWidget V1 -- "before your edit". See PluginV2/src/CppWidget.cpp
|
||||
* for "after": same three exports change behavior together, exactly
|
||||
* like PluginV1/src/Plugin.cpp's plain-C functions do.
|
||||
*/
|
||||
#include "CppWidgetApi.h"
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
int CppWidget::virtualTick(int input)
|
||||
{
|
||||
int result = input * 2;
|
||||
std::printf(" CppWidget::virtualTick(%d) -> %d [V1: input * 2, via vtable]\n", input, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
int CppWidget::tick(int input)
|
||||
{
|
||||
int result = input * 2;
|
||||
std::printf(" CppWidget::tick(%d) -> %d [V1: input * 2, via mangled-name lookup]\n", input, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
CppWidget CppWidget::operator+(const CppWidget& /*other*/) const
|
||||
{
|
||||
std::printf(" CppWidget::operator+ [V1]\n");
|
||||
return CppWidget();
|
||||
}
|
||||
|
||||
extern "C" CppWidget* make_cpp_widget()
|
||||
{
|
||||
return new CppWidget();
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/* PluginV1 -- "before your edit". See PluginV2/src/Plugin.cpp for
|
||||
* "after"; the two deliberately export the identical set of names
|
||||
* (minus plugin_legacy_feature, removed in V2) so HotReloadContext can
|
||||
* line them up. See ../Shared/PluginApi.h for what each export is
|
||||
* there to demonstrate.
|
||||
*/
|
||||
#include "PluginApi.h"
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
int plugin_tick(int input)
|
||||
{
|
||||
int result = input * 2;
|
||||
std::printf(" plugin_tick(%d) -> %d [V1: input * 2]\n", input, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
int plugin_legacy_feature(int input)
|
||||
{
|
||||
std::printf(" plugin_legacy_feature(%d) -> %d [V1, about to be removed in V2]\n", input, input);
|
||||
return input;
|
||||
}
|
||||
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
int plugin_tiny_function(int input)
|
||||
{
|
||||
return input + 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
int plugin_build_marker = 1;
|
||||
Reference in new issue
Block a user