diff --git a/v2/cmd/wails/internal/commands/build/build.go b/v2/cmd/wails/internal/commands/build/build.go index b582e29a..86df08ec 100644 --- a/v2/cmd/wails/internal/commands/build/build.go +++ b/v2/cmd/wails/internal/commands/build/build.go @@ -38,6 +38,9 @@ func AddBuildSubcommand(app *clir.Cli, w io.Writer) { compilerCommand := "go" command.StringFlag("compiler", "Use a different go compiler to build, eg go1.15beta1", &compilerCommand) + skipModTidy := false + command.BoolFlag("m", "Skip mod tidy before compile", &skipModTidy) + compress := false command.BoolFlag("upx", "Compress final binary with UPX (if installed)", &compress) @@ -167,6 +170,7 @@ func AddBuildSubcommand(app *clir.Cli, w io.Writer) { Pack: !noPackage, LDFlags: ldflags, Compiler: compilerCommand, + SkipModTidy: skipModTidy, Verbosity: verbosity, ForceBuild: forceBuild, IgnoreFrontend: skipFrontend, diff --git a/v2/pkg/commands/build/base.go b/v2/pkg/commands/build/base.go index fc5f60a5..39ca7a3e 100644 --- a/v2/pkg/commands/build/base.go +++ b/v2/pkg/commands/build/base.go @@ -198,15 +198,17 @@ func (b *BaseBuilder) CompileProject(options *Options) error { verbose := options.Verbosity == VERBOSE // Run go mod tidy first - cmd := exec.Command(options.Compiler, "mod", "tidy") - cmd.Stderr = os.Stderr - if verbose { - println("") - cmd.Stdout = os.Stdout - } - err = cmd.Run() - if err != nil { - return err + if !options.SkipModTidy { + cmd := exec.Command(options.Compiler, "mod", "tidy") + cmd.Stderr = os.Stderr + if verbose { + println("") + cmd.Stdout = os.Stdout + } + err = cmd.Run() + if err != nil { + return err + } } // Default go build command @@ -280,7 +282,7 @@ func (b *BaseBuilder) CompileProject(options *Options) error { options.CompiledBinary = compiledBinary // Create the command - cmd = exec.Command(options.Compiler, commands.AsSlice()...) + cmd := exec.Command(options.Compiler, commands.AsSlice()...) cmd.Stderr = os.Stderr if verbose { println(" Build command:", commands.Join(" ")) diff --git a/v2/pkg/commands/build/build.go b/v2/pkg/commands/build/build.go index f0197e56..37b862b9 100644 --- a/v2/pkg/commands/build/build.go +++ b/v2/pkg/commands/build/build.go @@ -37,6 +37,7 @@ type Options struct { Platform string // The platform to build for Arch string // The architecture to build for Compiler string // The compiler command to use + SkipModTidy bool // Skip mod tidy before compile IgnoreFrontend bool // Indicates if the frontend does not need building OutputFile string // Override the output filename BuildDirectory string // Directory to use for building the application