Add project files.
This commit is contained in:
commit
3087fcea8a
71 files changed
+8325
No files matched your search
@@ -0,0 +1,28 @@
|
||||
# The one target this whole example is about rebuilding, in place,
|
||||
# while Host is already running and has it loaded. Hand-written rather
|
||||
# than add_lib_module() for the same reason as HotReloadDemo/PluginV1
|
||||
# -- see that file's comment -- even though there's only one build of
|
||||
# this one: what makes this target unusual isn't needing two versions,
|
||||
# it's needing to be a completely ordinary, repeatedly-overwritable
|
||||
# build output while another process holds an OLDER build of it open
|
||||
# via source/HotReload (see that library's HotReloadContext::
|
||||
# stagePathForLoad() for why the running Host never itself locks this
|
||||
# exact path).
|
||||
|
||||
if(BUILD_EXAMPLES)
|
||||
add_library(hotreload_live_plugin SHARED src/LivePlugin.cpp)
|
||||
else()
|
||||
add_library(hotreload_live_plugin SHARED EXCLUDE_FROM_ALL src/LivePlugin.cpp)
|
||||
endif()
|
||||
|
||||
set_target_properties(hotreload_live_plugin PROPERTIES
|
||||
OUTPUT_NAME "hotreload_live_plugin"
|
||||
WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
||||
_set_output_dirs(hotreload_live_plugin
|
||||
"${CMAKE_BINARY_DIR}/${RUNTIME_OUTPUT_SUBDIR}/examples"
|
||||
"${CMAKE_BINARY_DIR}/${LIBRARY_OUTPUT_SUBDIR}/examples")
|
||||
_apply_compile_options(hotreload_live_plugin)
|
||||
hot_reload_enable_patchable_functions(hotreload_live_plugin)
|
||||
|
||||
_register_module_target(EXAMPLE hotreload_live_plugin)
|
||||
add_dependencies(all_examples hotreload_live_plugin)
|
||||
@@ -0,0 +1,50 @@
|
||||
/* LivePlugin.cpp -- THE FILE TO EDIT.
|
||||
*
|
||||
* With source/examples/HotReloadLiveDemo/Host running in one
|
||||
* terminal, rebuild just this file from another with:
|
||||
*
|
||||
* cmake --build <your build dir> --target hotreload_live_plugin
|
||||
*
|
||||
* or run watch.sh (in this same directory) in that other terminal to
|
||||
* have it rebuild automatically every time you save. Either way, the
|
||||
* running Host notices within about a second of a successful rebuild
|
||||
* and hot-reloads -- no restart.
|
||||
*
|
||||
* Things worth trying, roughly in order:
|
||||
*
|
||||
* 1. Change the message or the multiplier in live_tick() below and
|
||||
* rebuild -- watch the running Host's output change mid-flight,
|
||||
* still counting the same frame number it already had.
|
||||
*
|
||||
* 2. Delete live_tick() entirely (or rename it) and rebuild -- the
|
||||
* Host supplies a fallback for exactly this case, so you'll see
|
||||
* that kick in instead of a crash. Bring the function back under
|
||||
* the same name and rebuild again... and notice it does NOT
|
||||
* automatically take back over -- see the Host's own comment on
|
||||
* why, right where it resolves live_tick.
|
||||
*
|
||||
* 3. Add a brand new function:
|
||||
*
|
||||
* extern "C" int live_extra(int frame) { ... }
|
||||
*
|
||||
* and rebuild -- the Host looks for this one on every frame and
|
||||
* starts calling it the moment it exists.
|
||||
*
|
||||
* 4. Add a new exported variable, e.g.
|
||||
*
|
||||
* extern "C" int live_marker = 1;
|
||||
*
|
||||
* then change its value on a later edit and rebuild -- watch the
|
||||
* reload log call it out as data, classified and left alone,
|
||||
* never patched, exactly like plugin_build_marker in
|
||||
* source/examples/HotReloadDemo.
|
||||
*/
|
||||
#include <cstdio>
|
||||
|
||||
extern "C" int live_tick(int frame)
|
||||
{
|
||||
int multiplier = 2; // <- try changing this
|
||||
int value = frame * multiplier;
|
||||
std::printf(" live_tick(%d) -> %d\n", frame, value);
|
||||
return value;
|
||||
}
|
||||
Reference in new issue
Block a user