提交 fcb8301e 编写于 作者: Z zhangli10

command-line: install, package, darwin upx

上级 3a19f98e
......@@ -17,7 +17,9 @@ import (
"github.com/energye/energy/v2/cmd/internal/command"
"github.com/energye/energy/v2/cmd/internal/project"
"github.com/energye/energy/v2/cmd/internal/term"
"github.com/energye/energy/v2/cmd/internal/tools"
toolsCommand "github.com/energye/golcl/tools/command"
"strings"
)
func build(c *command.Config, proj *project.Project) (err error) {
......@@ -35,6 +37,17 @@ func build(c *command.Config, proj *project.Project) (err error) {
cmd.Command("go", args...)
cmd.Command("strip", proj.OutputFilename)
// upx
if c.Build.Upx && tools.CommandExists("upx") {
term.Section.Println("Upx compression")
args = []string{"--best", "--no-color", "--no-progress", proj.OutputFilename}
if c.Build.UpxFlag != "" {
args = strings.Split(c.Build.UpxFlag, " ")
args = append(args, proj.OutputFilename)
}
cmd.Command("upx", args...)
} else if c.Build.Upx {
term.Logger.Error("upx command not found", term.Logger.Args("install-upx", "brew install upx"))
}
cmd.Close()
if err == nil {
......
......@@ -248,7 +248,7 @@ func nsisCanInstall() bool {
}
func upxCanInstall() bool {
return (consts.IsWindows && !consts.IsARM64) || (consts.IsLinux)
return (consts.IsWindows && !consts.IsARM64) || consts.IsLinux || consts.IsDarwin
}
func z7zCanInstall() bool {
......@@ -317,9 +317,15 @@ func checkInstallEnv(c *command.Config) (result []*softEnf) {
// upx
check(func() (string, bool) {
if upxCanInstall() {
return "Windows AMD, Linux", tools.CommandExists("upx")
if consts.IsDarwin {
if tools.CommandExists("upx") {
return "All", true
}
return "Install: brew install upx", true
}
return "All", tools.CommandExists("upx")
} else {
return "Non Windows and Linux skipping UPX.", true
return "Unsupported platform UPX.", true
}
}, "UPX", func() {
c.Install.IUPX = true //yes callback
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册