From e7aa74905ae8078d5d5e376202572843235bbf44 Mon Sep 17 00:00:00 2001 From: Lea Anthony Date: Wed, 27 Apr 2022 19:10:20 +1000 Subject: [PATCH] Initial commit (#1352) --- v2/cmd/wails/internal/commands/build/build.go | 4 ++++ v2/pkg/commands/build/base.go | 4 ++++ v2/pkg/commands/build/build.go | 1 + website/docs/reference/cli.mdx | 1 + 4 files changed, 10 insertions(+) diff --git a/v2/cmd/wails/internal/commands/build/build.go b/v2/cmd/wails/internal/commands/build/build.go index 1c26c49ad..22134658a 100644 --- a/v2/cmd/wails/internal/commands/build/build.go +++ b/v2/cmd/wails/internal/commands/build/build.go @@ -96,6 +96,9 @@ func AddBuildSubcommand(app *clir.Cli, w io.Writer) { nsis := false command.BoolFlag("nsis", "Generate NSIS installer for Windows", &nsis) + trimpath := false + command.BoolFlag("trimpath", "Remove all file system paths from the resulting executable", &trimpath) + command.Action(func() error { quiet := verbosity == 0 @@ -176,6 +179,7 @@ func AddBuildSubcommand(app *clir.Cli, w io.Writer) { CompressFlags: compressFlags, UserTags: userTags, WebView2Strategy: wv2rtstrategy, + TrimPath: trimpath, } // Start a new tabwriter diff --git a/v2/pkg/commands/build/base.go b/v2/pkg/commands/build/base.go index 3b5c5bcd3..573fdafd4 100644 --- a/v2/pkg/commands/build/base.go +++ b/v2/pkg/commands/build/base.go @@ -178,6 +178,10 @@ func (b *BaseBuilder) CompileProject(options *Options) error { commands.Add("-a") } + if options.TrimPath { + commands.Add("-trimpath") + } + var tags slicer.StringSlicer tags.Add(options.OutputType) tags.AddSlice(options.UserTags) diff --git a/v2/pkg/commands/build/build.go b/v2/pkg/commands/build/build.go index 3e423573d..fa5b60f66 100644 --- a/v2/pkg/commands/build/build.go +++ b/v2/pkg/commands/build/build.go @@ -55,6 +55,7 @@ type Options struct { WailsJSDir string // Directory to generate the wailsjs module ForceBuild bool // Force BundleName string // Bundlename for Mac + TrimPath bool // Use Go's trimpath compiler flag } // Build the project! diff --git a/website/docs/reference/cli.mdx b/website/docs/reference/cli.mdx index b9189ee3a..44ba1f165 100644 --- a/website/docs/reference/cli.mdx +++ b/website/docs/reference/cli.mdx @@ -69,6 +69,7 @@ A list of community maintained templates can be found [here](../community/templa | -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 | | | -debug | Retains debug information in the application | false | +| -trimpath | Remove all file system paths from the resulting executable. | false | For a detailed description of the `webview2` flag, please refer to the [Windows](../guides/windows.mdx) Guide.