mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-02 03:20:09 +08:00
Fix -compiler flag for build, dev and generate commands (#3121)
* Fix -compiler flag for build, dev and generate commands * Update changelog and docs --------- Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
This commit is contained in:
parent
49a6b1aa3c
commit
946b6020c9
@ -2,6 +2,7 @@ package flags
|
||||
|
||||
type GenerateModule struct {
|
||||
Common
|
||||
Compiler string `description:"Use a different go compiler to build, eg go1.15beta1"`
|
||||
Tags string `description:"Build tags to pass to Go compiler. Must be quoted. Space or comma (but not both) separated"`
|
||||
Verbosity int `name:"v" description:"Verbosity level (0 = quiet, 1 = normal, 2 = verbose)"`
|
||||
}
|
||||
@ -12,3 +13,9 @@ type GenerateTemplate struct {
|
||||
Frontend string `description:"Frontend to use for the template"`
|
||||
Quiet bool `description:"Suppress output"`
|
||||
}
|
||||
|
||||
func (c *GenerateModule) Default() *GenerateModule {
|
||||
return &GenerateModule{
|
||||
Compiler: "go",
|
||||
}
|
||||
}
|
||||
|
@ -48,6 +48,7 @@ func generateModule(f *flags.GenerateModule) error {
|
||||
}
|
||||
|
||||
_, err = bindings.GenerateBindings(bindings.Options{
|
||||
Compiler: f.Compiler,
|
||||
Tags: buildTags,
|
||||
TsPrefix: projectConfig.Bindings.TsGeneration.Prefix,
|
||||
TsSuffix: projectConfig.Bindings.TsGeneration.Suffix,
|
||||
|
@ -61,7 +61,7 @@ func Application(f *flags.Dev, logger *clilogger.CLILogger) error {
|
||||
}
|
||||
|
||||
// Run go mod tidy to ensure we're up-to-date
|
||||
err = runCommand(cwd, false, "go", "mod", "tidy")
|
||||
err = runCommand(cwd, false, f.Compiler, "mod", "tidy")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ type Options struct {
|
||||
Filename string
|
||||
Tags []string
|
||||
ProjectDirectory string
|
||||
Compiler string
|
||||
GoModTidy bool
|
||||
TsPrefix string
|
||||
TsSuffix string
|
||||
@ -46,13 +47,13 @@ func GenerateBindings(options Options) (string, error) {
|
||||
tagString := buildtags.Stringify(genModuleTags)
|
||||
|
||||
if options.GoModTidy {
|
||||
stdout, stderr, err = shell.RunCommand(workingDirectory, "go", "mod", "tidy")
|
||||
stdout, stderr, err = shell.RunCommand(workingDirectory, options.Compiler, "mod", "tidy")
|
||||
if err != nil {
|
||||
return stdout, fmt.Errorf("%s\n%s\n%s", stdout, stderr, err)
|
||||
}
|
||||
}
|
||||
|
||||
stdout, stderr, err = shell.RunCommand(workingDirectory, "go", "build", "-tags", tagString, "-o", filename)
|
||||
stdout, stderr, err = shell.RunCommand(workingDirectory, options.Compiler, "build", "-tags", tagString, "-o", filename)
|
||||
if err != nil {
|
||||
return stdout, fmt.Errorf("%s\n%s\n%s", stdout, stderr, err)
|
||||
}
|
||||
|
@ -1,13 +1,14 @@
|
||||
package bindings
|
||||
|
||||
import (
|
||||
"github.com/matryer/is"
|
||||
"github.com/wailsapp/wails/v2/pkg/templates"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/matryer/is"
|
||||
"github.com/wailsapp/wails/v2/pkg/templates"
|
||||
)
|
||||
|
||||
const standardBindings = `// @ts-check
|
||||
@ -80,6 +81,7 @@ func TestGenerateBindings(t *testing.T) {
|
||||
name: "should generate standard bindings with no user tags",
|
||||
options: Options{
|
||||
ProjectDirectory: projectDir,
|
||||
Compiler: "go",
|
||||
GoModTidy: true,
|
||||
},
|
||||
expectedBindings: standardBindings,
|
||||
@ -90,6 +92,7 @@ func TestGenerateBindings(t *testing.T) {
|
||||
name: "should generate bindings when given tags",
|
||||
options: Options{
|
||||
ProjectDirectory: projectDir,
|
||||
Compiler: "go",
|
||||
Tags: []string{"test"},
|
||||
GoModTidy: true,
|
||||
},
|
||||
@ -101,6 +104,7 @@ func TestGenerateBindings(t *testing.T) {
|
||||
name: "should generate obfuscated bindings",
|
||||
options: Options{
|
||||
ProjectDirectory: projectDir,
|
||||
Compiler: "go",
|
||||
Tags: []string{"obfuscated"},
|
||||
GoModTidy: true,
|
||||
},
|
||||
|
@ -229,6 +229,7 @@ func GenerateBindings(buildOptions *Options) error {
|
||||
|
||||
// Generate Bindings
|
||||
output, err := bindings.GenerateBindings(bindings.Options{
|
||||
Compiler: buildOptions.Compiler,
|
||||
Tags: buildOptions.UserTags,
|
||||
GoModTidy: !buildOptions.SkipModTidy,
|
||||
TsPrefix: buildOptions.ProjectData.Bindings.TsGeneration.Prefix,
|
||||
|
@ -231,6 +231,11 @@ For more details on creating templates, consult the [Templates guide](../guides/
|
||||
|
||||
The `wails generate module` command allows you to manually generate the `wailsjs` directory for your application.
|
||||
|
||||
| Flag | Description | Default |
|
||||
|:---------------------|:------------------------------------------------------------|:--------|
|
||||
| -compiler "compiler" | Use a different go compiler to build, eg go1.15beta1 | go |
|
||||
| -tags "extra tags" | Build tags to pass to compiler (quoted and space separated) | |
|
||||
|
||||
## update
|
||||
|
||||
`wails update` will update the version of the Wails CLI.
|
||||
|
@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
### Fixed
|
||||
- Docs for IsZoomControlEnabled and ZoomFactor. Fixed by @leaanthony in [PR](https://github.com/wailsapp/wails/pull/3137)
|
||||
- Fixed `-compiler` flag for `wails build`, `wails dev` and `wails generate module`. Fixed in [PR](https://github.com/wailsapp/wails/pull/3121) by [@xtrafrancyz](https://github.com/xtrafrancyz)
|
||||
|
||||
## v2.7.1 - 2023-12-10
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user