diff --git a/cmd/v/v.v b/cmd/v/v.v index bbdcb765a8..f15c328ed0 100644 --- a/cmd/v/v.v +++ b/cmd/v/v.v @@ -28,6 +28,10 @@ const ( ) fn main() { + main_v() +} + +fn main_v() { args := os.args[1..] // args = 123 if args.len == 0 || args[0] in ['-', 'repl'] { diff --git a/vlib/v/builder/cc.v b/vlib/v/builder/cc.v index 403b5e0609..244a406c1c 100644 --- a/vlib/v/builder/cc.v +++ b/vlib/v/builder/cc.v @@ -40,6 +40,7 @@ fn (mut v Builder) cc() { ends_with_c := v.pref.out_name.ends_with('.c') ends_with_js := v.pref.out_name.ends_with('.js') if ends_with_c || ends_with_js { + v.pref.skip_running = true // Translating V code to JS by launching vjs. // Using a separate process for V.js is for performance mostly, // to avoid constant is_js checks. @@ -69,7 +70,7 @@ fn (mut v Builder) cc() { os.mv_by_cp(v.out_name_c, v.pref.out_name) or { panic(err) } - exit(0) + return } // Cross compiling for Windows if v.pref.os == .windows { diff --git a/vlib/v/builder/compile.v b/vlib/v/builder/compile.v index c08c7c5fda..769544195e 100644 --- a/vlib/v/builder/compile.v +++ b/vlib/v/builder/compile.v @@ -40,10 +40,11 @@ pub fn compile(command string, pref &pref.Preferences) { if pref.is_stats { println('compilation took: ${sw.elapsed().milliseconds()} ms') } + // running does not require the parsers anymore + b.myfree() if pref.is_test || pref.is_run { b.run_compiled_executable_and_exit() } - b.myfree() } // Temporary, will be done by -autofree @@ -54,6 +55,9 @@ fn (mut b Builder) myfree() { } fn (mut b Builder) run_compiled_executable_and_exit() { + if b.pref.skip_running { + return + } if b.pref.is_verbose { println('============ running $b.pref.out_name ============') } diff --git a/vlib/v/pref/pref.v b/vlib/v/pref/pref.v index 97bb16fb45..77ca994002 100644 --- a/vlib/v/pref/pref.v +++ b/vlib/v/pref/pref.v @@ -83,6 +83,7 @@ pub mut: run_args []string // `v run x.v 1 2 3` => `1 2 3` printfn_list []string // a list of generated function names, whose source should be shown, for debugging print_v_files bool // when true, just print the list of all parsed .v files then stop. + skip_running bool // when true, do no try to run the produced file (set by b.cc(), when -o x.c or -o x.js) } pub fn backend_from_string(s string) ?Backend {