mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-21 11:29:29 +08:00
Better verbose output
This commit is contained in:
parent
939e0f5975
commit
fd96ebc050
@ -157,9 +157,11 @@ func (b *BaseBuilder) OutputFilename(options *Options) string {
|
|||||||
// CompileProject compiles the project
|
// CompileProject compiles the project
|
||||||
func (b *BaseBuilder) CompileProject(options *Options) error {
|
func (b *BaseBuilder) CompileProject(options *Options) error {
|
||||||
|
|
||||||
|
verbose := options.Verbosity == VERBOSE
|
||||||
// Run go mod tidy first
|
// Run go mod tidy first
|
||||||
cmd := exec.Command(options.Compiler, "mod", "tidy")
|
cmd := exec.Command(options.Compiler, "mod", "tidy")
|
||||||
if options.Verbosity == VERBOSE {
|
if verbose {
|
||||||
|
println("")
|
||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = os.Stdout
|
||||||
cmd.Stderr = os.Stderr
|
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
|
// potentially try and see if the assets have changed but will
|
||||||
// this take as much time as a `-a` build?
|
// this take as much time as a `-a` build?
|
||||||
commands.Add("-a")
|
commands.Add("-a")
|
||||||
commands.Add("-x")
|
|
||||||
|
|
||||||
var tags slicer.StringSlicer
|
var tags slicer.StringSlicer
|
||||||
tags.Add(options.OutputType)
|
tags.Add(options.OutputType)
|
||||||
@ -235,7 +236,8 @@ func (b *BaseBuilder) CompileProject(options *Options) error {
|
|||||||
|
|
||||||
// Create the command
|
// Create the command
|
||||||
cmd = exec.Command(options.Compiler, commands.AsSlice()...)
|
cmd = exec.Command(options.Compiler, commands.AsSlice()...)
|
||||||
if options.Verbosity == VERBOSE {
|
if verbose {
|
||||||
|
println(" Build command:", commands.Join(" "))
|
||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = os.Stdout
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
}
|
}
|
||||||
@ -272,12 +274,21 @@ func (b *BaseBuilder) CompileProject(options *Options) error {
|
|||||||
return "1"
|
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
|
// Run command
|
||||||
err = cmd.Run()
|
err = cmd.Run()
|
||||||
|
|
||||||
// Format error if we have one
|
// Format error if we have one
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return fmt.Errorf("%s\n%s", err, string(stde.Bytes()))
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@ -393,7 +404,7 @@ func (b *BaseBuilder) BuildFrontend(outputLogger *clilogger.CLILogger) error {
|
|||||||
outputLogger.Print("Installing frontend dependencies: ")
|
outputLogger.Print("Installing frontend dependencies: ")
|
||||||
if verbose {
|
if verbose {
|
||||||
outputLogger.Println("")
|
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 {
|
if err := b.NpmInstallUsingCommand(frontendDir, b.projectData.InstallCommand, verbose); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -412,7 +423,7 @@ func (b *BaseBuilder) BuildFrontend(outputLogger *clilogger.CLILogger) error {
|
|||||||
cmd := strings.Split(b.projectData.BuildCommand, " ")
|
cmd := strings.Split(b.projectData.BuildCommand, " ")
|
||||||
if verbose {
|
if verbose {
|
||||||
outputLogger.Println("")
|
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:]...)
|
stdout, stderr, err := shell.RunCommand(frontendDir, cmd[0], cmd[1:]...)
|
||||||
if verbose || err != nil {
|
if verbose || err != nil {
|
||||||
|
@ -130,6 +130,10 @@ func Build(options *Options) (string, error) {
|
|||||||
// Build amd64 first
|
// Build amd64 first
|
||||||
options.Arch = "amd64"
|
options.Arch = "amd64"
|
||||||
options.OutputFile = amd64Filename
|
options.OutputFile = amd64Filename
|
||||||
|
if options.Verbosity == VERBOSE {
|
||||||
|
println()
|
||||||
|
println(" Building AMD64 Target:", filepath.Join(options.BuildDirectory, options.OutputFile))
|
||||||
|
}
|
||||||
err = builder.CompileProject(options)
|
err = builder.CompileProject(options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
@ -137,11 +141,17 @@ func Build(options *Options) (string, error) {
|
|||||||
// Build arm64
|
// Build arm64
|
||||||
options.Arch = "arm64"
|
options.Arch = "arm64"
|
||||||
options.OutputFile = arm64Filename
|
options.OutputFile = arm64Filename
|
||||||
|
if options.Verbosity == VERBOSE {
|
||||||
|
println(" Building ARM64 Target:", filepath.Join(options.BuildDirectory, options.OutputFile))
|
||||||
|
}
|
||||||
err = builder.CompileProject(options)
|
err = builder.CompileProject(options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
// Run lipo
|
// 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)
|
_, stderr, err := shell.RunCommand(options.BuildDirectory, "lipo", "-create", "-output", outputFile, amd64Filename, arm64Filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("%s - %s", err.Error(), stderr)
|
return "", fmt.Errorf("%s - %s", err.Error(), stderr)
|
||||||
|
Loading…
Reference in New Issue
Block a user