mirror of
https://gitee.com/energye/energy.git
synced 2024-12-04 04:38:21 +08:00
5a61fec1e9
windows: 386: -tags="tempdll latest" amd64: -tags="tempdll latest" windows(Windows 7, 8/8.1 and Windows Server 2012): 386: -tags="tempdll 109" amd64: -tags="tempdll 109" linux(gtk3): amd64: -tags="tempdll latest" arm64: -tags="tempdll latest" linux(gtk2): amd64: -tags="tempdll 106" arm64: -tags="tempdll 106" macos: amd64: -tags="tempdll latest" arm64: -tags="tempdll latest"
55 lines
1.5 KiB
Go
55 lines
1.5 KiB
Go
//----------------------------------------
|
|
//
|
|
// Copyright © yanghy. All Rights Reserved.
|
|
//
|
|
// Licensed under Apache License Version 2.0, January 2004
|
|
//
|
|
// https://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
//----------------------------------------
|
|
|
|
//go:build linux
|
|
// +build linux
|
|
|
|
package build
|
|
|
|
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) {
|
|
// go build
|
|
cmd := toolsCommand.NewCMD()
|
|
cmd.Dir = proj.ProjectPath
|
|
cmd.IsPrint = false
|
|
term.Section.Println("Building", proj.OutputFilename)
|
|
var args = []string{"build"}
|
|
if proj.TempDll {
|
|
args = append(args, "--tags=tempdll "+c.Build.TempDllFlag)
|
|
}
|
|
args = append(args, "-ldflags", "-s -w")
|
|
args = append(args, "-o", proj.OutputFilename)
|
|
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...)
|
|
}
|
|
cmd.Close()
|
|
if err == nil {
|
|
term.Section.Println("Build Successfully")
|
|
}
|
|
return nil
|
|
}
|