fix: cross compiling on linux for windows (#4263)

compile wailsbindings for the build machine

Co-authored-by: rynsf <rynsf@users.noreply.github.com>
Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
This commit is contained in:
rynsf 2025-05-19 16:46:10 +05:30 committed by GitHub
commit ac1479afa2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 6 additions and 10 deletions

View file

@ -20,8 +20,6 @@ type Options struct {
ProjectDirectory string
Compiler string
GoModTidy bool
Platform string
Arch string
TsPrefix string
TsSuffix string
TsOutputType string
@ -56,12 +54,11 @@ func GenerateBindings(options Options) (string, error) {
}
envBuild := os.Environ()
arch := options.Arch
if arch == "universal" {
arch = runtime.GOARCH
}
envBuild = shell.SetEnv(envBuild, "GOOS", options.Platform)
envBuild = shell.SetEnv(envBuild, "GOARCH", arch)
envBuild = shell.SetEnv(envBuild, "GOOS", runtime.GOOS)
envBuild = shell.SetEnv(envBuild, "GOARCH", runtime.GOARCH)
// wailsbindings is executed on the build machine.
// So, use the default C compiler, not the one set for cross compiling.
envBuild = shell.RemoveEnv(envBuild, "CC")
stdout, stderr, err = shell.RunCommandWithEnv(envBuild, workingDirectory, options.Compiler, "build", "-buildvcs=false", "-tags", tagString, "-o", filename)
if err != nil {

View file

@ -234,8 +234,6 @@ 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,