mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
compiler: do not exit early, when given -o x.c or -o x.js
This commit is contained in:
parent
4c320e1512
commit
e08566d571
@ -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'] {
|
||||
|
@ -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 {
|
||||
|
@ -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 ============')
|
||||
}
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user