-compress option

pull/2047/head
Alexander Medvednikov 2019-09-19 15:52:38 +03:00
parent ad6ab39287
commit afb372bbdf
2 changed files with 23 additions and 0 deletions

View File

@ -239,6 +239,27 @@ fn (v mut V) cc() {
if !v.pref.is_debug && v.out_name_c != 'v.c' && v.out_name_c != 'v_macos.c' {
os.rm(v.out_name_c)
}
if v.pref.compress {
ret := os.system('strip $v.out_name')
if ret != 0 {
println('strip failed')
return
}
ret2 := os.system('upx --lzma -qqq $v.out_name')
if ret2 != 0 {
println('upx failed')
$if mac {
println('install upx with `brew install upx`')
}
$if linux {
println('install upx\n' +
'for example, on Debian/Ubuntu run `sudo apt install upx`')
}
$if windows {
// :)
}
}
}
}

View File

@ -101,6 +101,7 @@ mut:
ccompiler string // the name of the used C compiler
building_v bool
autofree bool
compress bool
}
fn main() {
@ -848,6 +849,7 @@ fn new_v(args[]string) &V {
translated: 'translated' in args
is_run: 'run' in args
autofree: '-autofree' in args
compress: '-compress' in args
is_repl: is_repl
build_mode: build_mode
cflags: cflags