diff --git a/v2/pkg/commands/bindings/bindings.go b/v2/pkg/commands/bindings/bindings.go index a4a84e1be66..d1c8d60bfb1 100644 --- a/v2/pkg/commands/bindings/bindings.go +++ b/v2/pkg/commands/bindings/bindings.go @@ -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) } diff --git a/v2/pkg/commands/build/build.go b/v2/pkg/commands/build/build.go index 261f4c6d7ff..f247f2db180 100644 --- a/v2/pkg/commands/build/build.go +++ b/v2/pkg/commands/build/build.go @@ -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, diff --git a/website/src/pages/changelog.mdx b/website/src/pages/changelog.mdx index 4bd7beefc5f..9890a0cfa7b 100644 --- a/website/src/pages/changelog.mdx +++ b/website/src/pages/changelog.mdx @@ -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