diff --git a/cmd/tools/vtest-all.v b/cmd/tools/vtest-all.v index a32caf3d94..50c234af03 100644 --- a/cmd/tools/vtest-all.v +++ b/cmd/tools/vtest-all.v @@ -180,6 +180,11 @@ fn get_all_commands() []Command { okmsg: 'V can compile 2048 with -skip-unused.' rmfile: 'examples/2048/2048' } + res << Command{ + line: '${vexe} -skip-unused -live examples/hot_reload/bounce.v' + okmsg: 'V can compile the hot code reloading bounce.v example with both: -skip-unused -live' + rmfile: 'examples/hot_reload/bounce' + } } res << Command{ line: '${vexe} -o vtmp cmd/v' diff --git a/vlib/v/live/executable/reloader.v b/vlib/v/live/executable/reloader.v index 95f464c020..b4f7af4264 100644 --- a/vlib/v/live/executable/reloader.v +++ b/vlib/v/live/executable/reloader.v @@ -9,6 +9,7 @@ pub const is_used = 1 // The live reloader code is implemented here. // Note: new_live_reload_info will be called by generated C code inside main() +[markused] pub fn new_live_reload_info(original string, vexe string, vopts string, live_fn_mutex voidptr, live_linkfn live.FNLinkLiveSymbols) &live.LiveReloadInfo { file_base := os.file_name(original).replace('.v', '') so_dir := os.cache_dir() @@ -34,6 +35,7 @@ pub fn new_live_reload_info(original string, vexe string, vopts string, live_fn_ // Note: start_reloader will be called by generated code inside main(), to start // the hot code reloader thread. start_reloader is executed in the context of // the original main thread. +[markused] pub fn start_reloader(mut r live.LiveReloadInfo) { // The shared library should be loaded once in the main thread // If that fails, the program would crash anyway, just provide @@ -50,6 +52,7 @@ pub fn start_reloader(mut r live.LiveReloadInfo) { // that were used during the main program compilation. Any change to any of them, will later trigger a // recompilation and reloading of the produced shared library. This makes it possible for [live] functions // inside modules to also work, not just in the top level program. +[markused] pub fn add_live_monitored_file(mut lri live.LiveReloadInfo, path string) { mtime := os.file_last_mod_unix(path) lri.monitored_files << path diff --git a/vlib/v/markused/markused.v b/vlib/v/markused/markused.v index 4a519c31de..ee3c713afa 100644 --- a/vlib/v/markused/markused.v +++ b/vlib/v/markused/markused.v @@ -338,12 +338,6 @@ pub fn mark_used(mut table ast.Table, pref_ &pref.Preferences, ast_files []&ast. } } - // handle -live main programs: - if pref_.is_livemain { - all_fn_root_names << 'v.live.executable.start_reloader' - all_fn_root_names << 'v.live.executable.new_live_reload_info' - } - mut walker := Walker{ table: table files: ast_files