Skip to content

Commit

Permalink
fix: pass platform and arch to GenerateBindings for cross compilation (
Browse files Browse the repository at this point in the history
  • Loading branch information
fcying authored Oct 10, 2024
1 parent a2e32fe commit 8a5a050
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
8 changes: 7 additions & 1 deletion v2/pkg/commands/bindings/bindings.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ type Options struct {
ProjectDirectory string
Compiler string
GoModTidy bool
Platform string
Arch string
TsPrefix string
TsSuffix string
TsOutputType string
Expand Down Expand Up @@ -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)
}
Expand Down
2 changes: 2 additions & 0 deletions v2/pkg/commands/build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions website/src/pages/changelog.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 8a5a050

Please sign in to comment.