From afb372bbdf02552b2ef186228d1f56ea54b229ca Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Thu, 19 Sep 2019 15:52:38 +0300 Subject: [PATCH] -compress option --- compiler/cc.v | 21 +++++++++++++++++++++ compiler/main.v | 2 ++ 2 files changed, 23 insertions(+) diff --git a/compiler/cc.v b/compiler/cc.v index ec37539979..fb29845ddb 100644 --- a/compiler/cc.v +++ b/compiler/cc.v @@ -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 { + // :) + } + } + } } diff --git a/compiler/main.v b/compiler/main.v index 698493715f..c3b6bc6e13 100644 --- a/compiler/main.v +++ b/compiler/main.v @@ -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