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

New build flag: -debug

This commit is contained in:
Lea\Anthony 2021-12-29 06:54:42 +11:00
parent e2f3a11a33
commit 3c6ed12637
4 changed files with 17 additions and 3 deletions

View File

@ -83,6 +83,9 @@ func AddBuildSubcommand(app *clir.Cli, w io.Writer) {
updateGoMod := false updateGoMod := false
command.BoolFlag("u", "Updates go.mod to use the same Wails version as the CLI", &updateGoMod) command.BoolFlag("u", "Updates go.mod to use the same Wails version as the CLI", &updateGoMod)
debug := false
command.BoolFlag("debug", "Retains debug data in the compiled application", &debug)
command.Action(func() error { command.Action(func() error {
quiet := verbosity == 0 quiet := verbosity == 0
@ -164,13 +167,20 @@ func AddBuildSubcommand(app *clir.Cli, w io.Writer) {
} }
} }
mode := build.Production
modeString := "Production"
if debug {
mode = build.Debug
modeString = "Debug"
}
// Create BuildOptions // Create BuildOptions
buildOptions := &build.Options{ buildOptions := &build.Options{
Logger: logger, Logger: logger,
OutputType: outputType, OutputType: outputType,
OutputFile: outputFilename, OutputFile: outputFilename,
CleanBuildDirectory: cleanBuildDirectory, CleanBuildDirectory: cleanBuildDirectory,
Mode: build.Production, Mode: mode,
Pack: !noPackage, Pack: !noPackage,
LDFlags: ldflags, LDFlags: ldflags,
Compiler: compilerCommand, Compiler: compilerCommand,
@ -206,6 +216,7 @@ func AddBuildSubcommand(app *clir.Cli, w io.Writer) {
fmt.Fprintf(w, "Platform: \t%s\n", buildOptions.Platform) fmt.Fprintf(w, "Platform: \t%s\n", buildOptions.Platform)
fmt.Fprintf(w, "Arch: \t%s\n", buildOptions.Arch) fmt.Fprintf(w, "Arch: \t%s\n", buildOptions.Arch)
fmt.Fprintf(w, "Compiler: \t%s\n", compilerPath) fmt.Fprintf(w, "Compiler: \t%s\n", compilerPath)
fmt.Fprintf(w, "Build Mode: \t%s\n", modeString)
fmt.Fprintf(w, "Skip Frontend: \t%t\n", skipFrontend) fmt.Fprintf(w, "Skip Frontend: \t%t\n", skipFrontend)
fmt.Fprintf(w, "Compress: \t%t\n", buildOptions.Compress) fmt.Fprintf(w, "Compress: \t%t\n", buildOptions.Compress)
fmt.Fprintf(w, "Package: \t%t\n", buildOptions.Pack) fmt.Fprintf(w, "Package: \t%t\n", buildOptions.Pack)

View File

@ -215,7 +215,7 @@ func (b *BaseBuilder) CompileProject(options *Options) error {
commands := slicer.String([]string{"build"}) commands := slicer.String([]string{"build"})
// Add better debugging flags // Add better debugging flags
if options.Mode == Dev { if options.Mode == Dev || options.Mode == Debug {
commands.Add("-gcflags") commands.Add("-gcflags")
commands.Add(`"all=-N -l"`) commands.Add(`"all=-N -l"`)
} }
@ -233,7 +233,7 @@ func (b *BaseBuilder) CompileProject(options *Options) error {
tags.Add(options.WebView2Strategy) tags.Add(options.WebView2Strategy)
} }
if options.Mode == Production { if options.Mode == Production || options.Mode == Debug {
tags.Add("production") tags.Add("production")
} }

View File

@ -23,6 +23,8 @@ const (
Dev Mode = iota Dev Mode = iota
// Production mode // Production mode
Production Production
// Debug build
Debug
) )
// Options contains all the build options as well as the project data // Options contains all the build options as well as the project data

View File

@ -67,6 +67,7 @@ A list of community maintained templates can be found [here](/docs/community/tem
| -v int | Verbosity level (0 - silent, 1 - default, 2 - verbose) | 1 | | -v int | Verbosity level (0 - silent, 1 - default, 2 - verbose) | 1 |
| -webview2 | WebView2 installer strategy: download,embed,browser,error | download | | -webview2 | WebView2 installer strategy: download,embed,browser,error | download |
| -u | Updates your project's `go.mod` to use the same version of Wails as the CLI | | | -u | Updates your project's `go.mod` to use the same version of Wails as the CLI | |
| -debug | Retains debug information in the application | false |
For a detailed description of the `webview2` flag, please refer to the [Windows](/docs/guides/windows) Guide. For a detailed description of the `webview2` flag, please refer to the [Windows](/docs/guides/windows) Guide.