1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

v.markused: enable v -skip-unused -live run examples/hot_reload/bounce.v

This commit is contained in:
Delyan Angelov 2023-04-08 14:30:41 +03:00
parent e70084f203
commit 48d42287a9
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
3 changed files with 8 additions and 6 deletions

View File

@ -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'

View File

@ -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

View File

@ -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