mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-03 04:11:05 +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 {
|
type GenerateModule struct {
|
||||||
Common
|
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"`
|
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)"`
|
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"`
|
Frontend string `description:"Frontend to use for the template"`
|
||||||
Quiet bool `description:"Suppress output"`
|
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{
|
_, err = bindings.GenerateBindings(bindings.Options{
|
||||||
|
Compiler: f.Compiler,
|
||||||
Tags: buildTags,
|
Tags: buildTags,
|
||||||
TsPrefix: projectConfig.Bindings.TsGeneration.Prefix,
|
TsPrefix: projectConfig.Bindings.TsGeneration.Prefix,
|
||||||
TsSuffix: projectConfig.Bindings.TsGeneration.Suffix,
|
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
|
// 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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ type Options struct {
|
|||||||
Filename string
|
Filename string
|
||||||
Tags []string
|
Tags []string
|
||||||
ProjectDirectory string
|
ProjectDirectory string
|
||||||
|
Compiler string
|
||||||
GoModTidy bool
|
GoModTidy bool
|
||||||
TsPrefix string
|
TsPrefix string
|
||||||
TsSuffix string
|
TsSuffix string
|
||||||
@ -46,13 +47,13 @@ func GenerateBindings(options Options) (string, error) {
|
|||||||
tagString := buildtags.Stringify(genModuleTags)
|
tagString := buildtags.Stringify(genModuleTags)
|
||||||
|
|
||||||
if options.GoModTidy {
|
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 {
|
if err != nil {
|
||||||
return stdout, fmt.Errorf("%s\n%s\n%s", stdout, stderr, err)
|
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 {
|
if err != nil {
|
||||||
return stdout, fmt.Errorf("%s\n%s\n%s", stdout, stderr, err)
|
return stdout, fmt.Errorf("%s\n%s\n%s", stdout, stderr, err)
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
package bindings
|
package bindings
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/matryer/is"
|
|
||||||
"github.com/wailsapp/wails/v2/pkg/templates"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/matryer/is"
|
||||||
|
"github.com/wailsapp/wails/v2/pkg/templates"
|
||||||
)
|
)
|
||||||
|
|
||||||
const standardBindings = `// @ts-check
|
const standardBindings = `// @ts-check
|
||||||
@ -80,6 +81,7 @@ func TestGenerateBindings(t *testing.T) {
|
|||||||
name: "should generate standard bindings with no user tags",
|
name: "should generate standard bindings with no user tags",
|
||||||
options: Options{
|
options: Options{
|
||||||
ProjectDirectory: projectDir,
|
ProjectDirectory: projectDir,
|
||||||
|
Compiler: "go",
|
||||||
GoModTidy: true,
|
GoModTidy: true,
|
||||||
},
|
},
|
||||||
expectedBindings: standardBindings,
|
expectedBindings: standardBindings,
|
||||||
@ -90,6 +92,7 @@ func TestGenerateBindings(t *testing.T) {
|
|||||||
name: "should generate bindings when given tags",
|
name: "should generate bindings when given tags",
|
||||||
options: Options{
|
options: Options{
|
||||||
ProjectDirectory: projectDir,
|
ProjectDirectory: projectDir,
|
||||||
|
Compiler: "go",
|
||||||
Tags: []string{"test"},
|
Tags: []string{"test"},
|
||||||
GoModTidy: true,
|
GoModTidy: true,
|
||||||
},
|
},
|
||||||
@ -101,6 +104,7 @@ func TestGenerateBindings(t *testing.T) {
|
|||||||
name: "should generate obfuscated bindings",
|
name: "should generate obfuscated bindings",
|
||||||
options: Options{
|
options: Options{
|
||||||
ProjectDirectory: projectDir,
|
ProjectDirectory: projectDir,
|
||||||
|
Compiler: "go",
|
||||||
Tags: []string{"obfuscated"},
|
Tags: []string{"obfuscated"},
|
||||||
GoModTidy: true,
|
GoModTidy: true,
|
||||||
},
|
},
|
||||||
|
@ -229,6 +229,7 @@ func GenerateBindings(buildOptions *Options) error {
|
|||||||
|
|
||||||
// Generate Bindings
|
// Generate Bindings
|
||||||
output, err := bindings.GenerateBindings(bindings.Options{
|
output, err := bindings.GenerateBindings(bindings.Options{
|
||||||
|
Compiler: buildOptions.Compiler,
|
||||||
Tags: buildOptions.UserTags,
|
Tags: buildOptions.UserTags,
|
||||||
GoModTidy: !buildOptions.SkipModTidy,
|
GoModTidy: !buildOptions.SkipModTidy,
|
||||||
TsPrefix: buildOptions.ProjectData.Bindings.TsGeneration.Prefix,
|
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.
|
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
|
## update
|
||||||
|
|
||||||
`wails update` will update the version of the Wails CLI.
|
`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
|
### Fixed
|
||||||
- Docs for IsZoomControlEnabled and ZoomFactor. Fixed by @leaanthony in [PR](https://github.com/wailsapp/wails/pull/3137)
|
- 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
|
## v2.7.1 - 2023-12-10
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user