5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-02 18:10:48 +08:00

fix: pass platform and arch to GenerateBindings for cross compilation (#3795)

This commit is contained in:
fcying 2024-10-10 17:17:43 +08:00 committed by GitHub
parent a2e32fe414
commit 8a5a0506bf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 11 additions and 1 deletions

View File

@ -20,6 +20,8 @@ type Options struct {
ProjectDirectory string
Compiler string
GoModTidy bool
Platform string
Arch string
TsPrefix string
TsSuffix string
TsOutputType string
@ -53,7 +55,11 @@ func GenerateBindings(options Options) (string, error) {
}
}
stdout, stderr, err = shell.RunCommand(workingDirectory, options.Compiler, "build", "-tags", tagString, "-o", filename)
envBuild := os.Environ()
envBuild = shell.SetEnv(envBuild, "GOOS", options.Platform)
envBuild = shell.SetEnv(envBuild, "GOARCH", options.Arch)
stdout, stderr, err = shell.RunCommandWithEnv(envBuild, workingDirectory, options.Compiler, "build", "-tags", tagString, "-o", filename)
if err != nil {
return stdout, fmt.Errorf("%s\n%s\n%s", stdout, stderr, err)
}

View File

@ -231,6 +231,8 @@ func GenerateBindings(buildOptions *Options) error {
Compiler: buildOptions.Compiler,
Tags: buildOptions.UserTags,
GoModTidy: !buildOptions.SkipModTidy,
Platform: buildOptions.Platform,
Arch: buildOptions.Arch,
TsPrefix: buildOptions.ProjectData.Bindings.TsGeneration.Prefix,
TsSuffix: buildOptions.ProjectData.Bindings.TsGeneration.Suffix,
TsOutputType: buildOptions.ProjectData.Bindings.TsGeneration.OutputType,

View File

@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `Security` in case of vulnerabilities.
## [Unreleased]
### Fixed
- Fixed cross compilation failed with CGO [PR](https://github.com/wailsapp/wails/pull/3795) by [@fcying](https://github.com/fcying)
## v2.9.2 - 2024-09-18