mirror of
https://github.com/taigrr/wails.git
synced 2026-04-16 19:55:05 -07:00
Added release mode flag
fixed logging logging info level by default
This commit is contained in:
@@ -105,6 +105,7 @@ func NewCommand(name string, description string, app *Cli, parentCommandPath str
|
||||
Shortdescription: description,
|
||||
SubCommandsMap: make(map[string]*Command),
|
||||
App: app,
|
||||
log: NewLogger(),
|
||||
}
|
||||
|
||||
// Set up command path
|
||||
@@ -181,6 +182,7 @@ func (c *Command) Run(args []string) error {
|
||||
|
||||
// Nothing left we can do
|
||||
c.PrintHelp()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -103,6 +103,11 @@ func (p *ProgramHelper) InstallGoPackage(packageName string) error {
|
||||
// RunCommand runs the given command
|
||||
func (p *ProgramHelper) RunCommand(command string) error {
|
||||
args := strings.Split(command, " ")
|
||||
return p.RunCommandArray(args)
|
||||
}
|
||||
|
||||
// RunCommandArray runs the command specified in the array
|
||||
func (p *ProgramHelper) RunCommandArray(args []string) error {
|
||||
program := args[0]
|
||||
// TODO: Run FindProgram here and get the full path to the exe
|
||||
program, err := exec.LookPath(program)
|
||||
|
||||
@@ -220,6 +220,8 @@ func (sc *SystemConfig) load(filename string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// CheckDependenciesSilent checks for dependencies but
|
||||
// only outputs if there's an error
|
||||
func CheckDependenciesSilent(logger *Logger) (bool, error) {
|
||||
logger.SetErrorOnly(true)
|
||||
result, err := CheckDependencies(logger)
|
||||
|
||||
@@ -4,8 +4,8 @@ import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/leaanthony/slicer"
|
||||
"github.com/leaanthony/spinner"
|
||||
"github.com/wailsapp/wails/cmd"
|
||||
)
|
||||
@@ -14,6 +14,7 @@ func init() {
|
||||
|
||||
var bundle = false
|
||||
var forceRebuild = false
|
||||
var releaseMode = false
|
||||
buildSpinner := spinner.NewSpinner()
|
||||
buildSpinner.SetSpinSpeed(50)
|
||||
|
||||
@@ -21,7 +22,8 @@ func init() {
|
||||
initCmd := app.Command("build", "Builds your Wails project").
|
||||
LongDescription(commandDescription).
|
||||
BoolFlag("b", "Bundle application on successful build", &bundle).
|
||||
BoolFlag("f", "Force rebuild of application components", &forceRebuild)
|
||||
BoolFlag("f", "Force rebuild of application components", &forceRebuild).
|
||||
BoolFlag("r", "Build in Release mode", &releaseMode)
|
||||
|
||||
initCmd.Action(func() error {
|
||||
log := cmd.NewLogger()
|
||||
@@ -186,27 +188,40 @@ func init() {
|
||||
}
|
||||
depSpinner.Success()
|
||||
|
||||
packSpinner := spinner.New("Packing + Compiling project...")
|
||||
compileMessage := "Packing + Compiling project"
|
||||
if releaseMode {
|
||||
compileMessage += " (Release Mode)"
|
||||
}
|
||||
|
||||
packSpinner := spinner.New(compileMessage + "...")
|
||||
packSpinner.SetSpinSpeed(50)
|
||||
packSpinner.Start()
|
||||
|
||||
buildCommand := "packr build"
|
||||
buildCommand := slicer.String()
|
||||
buildCommand.AddSlice([]string{"packr", "build"})
|
||||
|
||||
// Add build tags
|
||||
if len(buildTags) > 0 {
|
||||
buildCommand += fmt.Sprintf(" --tags '%s'", strings.Join(buildTags, " "))
|
||||
buildCommand.Add("--tags")
|
||||
buildCommand.AddSlice(buildTags)
|
||||
|
||||
}
|
||||
|
||||
if projectOptions.BinaryName != "" {
|
||||
buildCommand += " -o " + projectOptions.BinaryName
|
||||
buildCommand.Add("-o")
|
||||
buildCommand.Add(projectOptions.BinaryName)
|
||||
}
|
||||
|
||||
// If we are forcing a rebuild
|
||||
if forceRebuild {
|
||||
buildCommand += " -a"
|
||||
buildCommand.Add(" -a")
|
||||
}
|
||||
|
||||
err = program.RunCommand(buildCommand)
|
||||
// Release mode
|
||||
if releaseMode {
|
||||
buildCommand.AddSlice([]string{"-ldflags","-X github.com/wailsapp/wails.DebugMode=false"})
|
||||
}
|
||||
err = program.RunCommandArray(buildCommand.AsSlice())
|
||||
if err != nil {
|
||||
packSpinner.Error()
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user