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

feature: Add -windowsconsole flag

This commit is contained in:
Lea Anthony 2022-07-04 22:52:50 +10:00
parent 4c312b155d
commit 4726b72708
No known key found for this signature in database
GPG Key ID: 33DAF7BB90A58405
4 changed files with 7 additions and 1 deletions

View File

@ -102,6 +102,9 @@ func AddBuildSubcommand(app *clir.Cli, w io.Writer) {
raceDetector := false raceDetector := false
command.BoolFlag("race", "Build with Go's race detector", &raceDetector) command.BoolFlag("race", "Build with Go's race detector", &raceDetector)
windowsConsole := false
command.BoolFlag("windowsconsole", "Keep the console when building for Windows", &windowsConsole)
command.Action(func() error { command.Action(func() error {
quiet := verbosity == 0 quiet := verbosity == 0
@ -184,6 +187,7 @@ func AddBuildSubcommand(app *clir.Cli, w io.Writer) {
WebView2Strategy: wv2rtstrategy, WebView2Strategy: wv2rtstrategy,
TrimPath: trimpath, TrimPath: trimpath,
RaceDetector: raceDetector, RaceDetector: raceDetector,
WindowsConsole: windowsConsole,
} }
// Start a new tabwriter // Start a new tabwriter

View File

@ -217,7 +217,7 @@ func (b *BaseBuilder) CompileProject(options *Options) error {
if options.Mode == Production { if options.Mode == Production {
ldflags.Add("-w", "-s") ldflags.Add("-w", "-s")
if options.Platform == "windows" { if options.Platform == "windows" && !options.WindowsConsole {
ldflags.Add("-H windowsgui") ldflags.Add("-H windowsgui")
} }
} }

View File

@ -57,6 +57,7 @@ type Options struct {
BundleName string // Bundlename for Mac BundleName string // Bundlename for Mac
TrimPath bool // Use Go's trimpath compiler flag TrimPath bool // Use Go's trimpath compiler flag
RaceDetector bool // Build with Go's race detector RaceDetector bool // Build with Go's race detector
WindowsConsole bool // Indicates that the windows console should be kept
} }
// Build the project! // Build the project!

View File

@ -71,6 +71,7 @@ A list of community maintained templates can be found [here](../community/templa
| -debug | Retains debug information in the application. Allows the use of the devtools in the application window | false | | -debug | Retains debug information in the application. Allows the use of the devtools in the application window | false |
| -trimpath | Remove all file system paths from the resulting executable. | false | | -trimpath | Remove all file system paths from the resulting executable. | false |
| -race | Build with Go's race detector | false | | -race | Build with Go's race detector | false |
| -windowsconsole | Keep the console window for Windows builds | false |
For a detailed description of the `webview2` flag, please refer to the [Windows](../guides/windows.mdx) Guide. For a detailed description of the `webview2` flag, please refer to the [Windows](../guides/windows.mdx) Guide.