5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-21 03:19:31 +08:00

Better verbose output

This commit is contained in:
Lea Anthony 2021-03-26 18:12:42 +11:00
parent 939e0f5975
commit fd96ebc050
No known key found for this signature in database
GPG Key ID: 33DAF7BB90A58405
2 changed files with 27 additions and 6 deletions

View File

@ -157,9 +157,11 @@ func (b *BaseBuilder) OutputFilename(options *Options) string {
// CompileProject compiles the project
func (b *BaseBuilder) CompileProject(options *Options) error {
verbose := options.Verbosity == VERBOSE
// Run go mod tidy first
cmd := exec.Command(options.Compiler, "mod", "tidy")
if options.Verbosity == VERBOSE {
if verbose {
println("")
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
}
@ -183,7 +185,6 @@ func (b *BaseBuilder) CompileProject(options *Options) error {
// potentially try and see if the assets have changed but will
// this take as much time as a `-a` build?
commands.Add("-a")
commands.Add("-x")
var tags slicer.StringSlicer
tags.Add(options.OutputType)
@ -235,7 +236,8 @@ func (b *BaseBuilder) CompileProject(options *Options) error {
// Create the command
cmd = exec.Command(options.Compiler, commands.AsSlice()...)
if options.Verbosity == VERBOSE {
if verbose {
println(" Build command:", commands.Join(" "))
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
}
@ -272,12 +274,21 @@ func (b *BaseBuilder) CompileProject(options *Options) error {
return "1"
})
if verbose {
println(" Environment:", strings.Join(cmd.Env, " "))
}
// Setup buffers
var stdo, stde bytes.Buffer
cmd.Stdout = &stdo
cmd.Stderr = &stde
// Run command
err = cmd.Run()
// Format error if we have one
if err != nil {
return err
return fmt.Errorf("%s\n%s", err, string(stde.Bytes()))
}
return nil
@ -393,7 +404,7 @@ func (b *BaseBuilder) BuildFrontend(outputLogger *clilogger.CLILogger) error {
outputLogger.Print("Installing frontend dependencies: ")
if verbose {
outputLogger.Println("")
outputLogger.Println("\tCommand: " + b.projectData.InstallCommand)
outputLogger.Println(" Install command: '" + b.projectData.InstallCommand + "'")
}
if err := b.NpmInstallUsingCommand(frontendDir, b.projectData.InstallCommand, verbose); err != nil {
return err
@ -412,7 +423,7 @@ func (b *BaseBuilder) BuildFrontend(outputLogger *clilogger.CLILogger) error {
cmd := strings.Split(b.projectData.BuildCommand, " ")
if verbose {
outputLogger.Println("")
outputLogger.Println("\tCommand: '" + strings.Join(cmd, " ") + "'")
outputLogger.Println(" Build command: '" + strings.Join(cmd, " ") + "'")
}
stdout, stderr, err := shell.RunCommand(frontendDir, cmd[0], cmd[1:]...)
if verbose || err != nil {

View File

@ -130,6 +130,10 @@ func Build(options *Options) (string, error) {
// Build amd64 first
options.Arch = "amd64"
options.OutputFile = amd64Filename
if options.Verbosity == VERBOSE {
println()
println(" Building AMD64 Target:", filepath.Join(options.BuildDirectory, options.OutputFile))
}
err = builder.CompileProject(options)
if err != nil {
return "", err
@ -137,11 +141,17 @@ func Build(options *Options) (string, error) {
// Build arm64
options.Arch = "arm64"
options.OutputFile = arm64Filename
if options.Verbosity == VERBOSE {
println(" Building ARM64 Target:", filepath.Join(options.BuildDirectory, options.OutputFile))
}
err = builder.CompileProject(options)
if err != nil {
return "", err
}
// Run lipo
if options.Verbosity == VERBOSE {
println(" Running lipo: ", "lipo", "-create", "-output", outputFile, amd64Filename, arm64Filename)
}
_, stderr, err := shell.RunCommand(options.BuildDirectory, "lipo", "-create", "-output", outputFile, amd64Filename, arm64Filename)
if err != nil {
return "", fmt.Errorf("%s - %s", err.Error(), stderr)