mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
builder: support -o -
to print the generated C/JS source to stdout
This commit is contained in:
parent
a5c784830b
commit
a007dd5d22
@ -62,6 +62,12 @@ fn get_all_commands() []Command {
|
||||
okmsg: 'V can output a .c file, without compiling further.'
|
||||
rmfile: 'hhww.c'
|
||||
}
|
||||
$if linux || macos {
|
||||
res << Command{
|
||||
line: '$vexe -o - examples/hello_world.v | grep "#define V_COMMIT_HASH" > /dev/null'
|
||||
okmsg: 'V prints the generated source code to stdout with `-o -` .'
|
||||
}
|
||||
}
|
||||
res << Command{
|
||||
line: '$vexe -o vtmp cmd/v'
|
||||
okmsg: 'V can compile itself.'
|
||||
@ -152,7 +158,8 @@ fn (mut cmd Command) run() {
|
||||
sw := time.new_stopwatch({})
|
||||
cmd.ecode = os.system(cmd.line)
|
||||
spent := sw.elapsed().milliseconds()
|
||||
println(term_highlight('> Running: "$cmd.line" took: $spent ms.'))
|
||||
println('> Running: "$cmd.line" took: $spent ms ... ' +
|
||||
if cmd.ecode != 0 { term.failed('FAILED') } else { term_highlight('OK') })
|
||||
if vtest_nocleanup {
|
||||
return
|
||||
}
|
||||
|
@ -479,6 +479,13 @@ fn (mut v Builder) cc() {
|
||||
}
|
||||
return
|
||||
}
|
||||
if v.pref.out_name.ends_with('/-') {
|
||||
// output to stdout
|
||||
content := os.read_file(v.out_name_c) or { panic(err) }
|
||||
println(content)
|
||||
os.rm(v.out_name_c) or {}
|
||||
return
|
||||
}
|
||||
// whether to just create a .c or .js file and exit, for example: `v -o v.c cmd.v`
|
||||
ends_with_c := v.pref.out_name.ends_with('.c')
|
||||
ends_with_js := v.pref.out_name.ends_with('.js')
|
||||
|
Loading…
Reference in New Issue
Block a user