cordova-electron icon indicating copy to clipboard operation
cordova-electron copied to clipboard

Cannot build Windows platform on a Mac

Open sc0ttdav3y opened this issue 3 years ago • 0 comments

Bug Report

Problem

I'm running MacOS Big Sur, and the windows platform within electron doesn't build.

What is expected to happen?

I expect a 64 bit windows binary to be built. I know MacOS Catalina and greater can't build 32 bit binaries.

What does actually happen?

I get an error message: bad CPU type in executable

  • packaging       platform=win32 arch=x64 electron=4.0.1 appOutDir=platforms/electron/build/win-unpacked
  ⨯ error: fork/exec /Users/XXX/Library/Caches/electron-builder/wine/wine-2.0.3-mac-10.13/bin/wine: bad CPU type in executable
path: /Users/XXX/Library/Caches/electron-builder/wine/wine-2.0.3-mac-10.13/bin/wine
args: /Users/XXX/Library/Caches/electron-builder/wine/wine-2.0.3-mac-10.13/bin/wine /Users/XXX/Library/Caches/electron-builder/winCodeSign/winCodeSign-2.4.0/rcedit-ia32.exe /Users/XXX/.jenkins/jobs/Apps/jobs/develop/jobs/cw-electron-develop/workspace/cordova-build/app/platforms/electron/build/win-unpacked/XXX.exe --set-version-string FileDescription XXX --set-version-string ProductName XXX --set-version-string LegalCopyright Copyright © 2021 XXX --set-file-version 1.16.4.46 --set-product-version 1.16.4.46 --set-version-string InternalName XXX --set-version-string OriginalFilename  --set-version-string CompanyName XXX --set-icon /Users/XXX/.jenkins/jobs/Apps/jobs/develop/jobs/cw-electron-develop/workspace/cordova-build/app/platforms/electron/build/.icon-ico/icon.ico
output: 
error output:
github.com/develar/app-builder/pkg/util.Execute
	/Volumes/data/Documents/app-builder/pkg/util/util.go:61
github.com/develar/app-builder/pkg/wine.execWine
	/Volumes/data/Documents/app-builder/pkg/wine/wine.go:92
github.com/develar/app-builder/pkg/wine.ConfigureCommand.func2
	/Volumes/data/Documents/app-builder/pkg/wine/wine.go:43
github.com/alecthomas/kingpin.(*actionMixin).applyActions
	/Volumes/data/go/pkg/mod/github.com/alecthomas/[email protected]+incompatible/actions.go:28
github.com/alecthomas/kingpin.(*Application).applyActions
	/Volumes/data/go/pkg/mod/github.com/alecthomas/[email protected]+incompatible/app.go:557
github.com/alecthomas/kingpin.(*Application).execute
	/Volumes/data/go/pkg/mod/github.com/alecthomas/[email protected]+incompatible/app.go:390
github.com/alecthomas/kingpin.(*Application).Parse
	/Volumes/data/go/pkg/mod/github.com/alecthomas/[email protected]+incompatible/app.go:222
main.main
	/Volumes/data/Documents/app-builder/main.go:78
runtime.main
	/usr/local/Cellar/go/1.12.6/libexec/src/runtime/proc.go:200
runtime.goexit
	/usr/local/Cellar/go/1.12.6/libexec/src/runtime/asm_amd64.s:1337

Information

I understand there's a bit of history or dependency to this issue:

  • MacOS no longer supports 32-bit executables since Catalina
  • Back in 2019 when many tickets on this were opened, wine didn't ship with a 64-bit executable (but it does now)
  • This package depends on upstream packages, which depend on upstream packages, and the problem is most likely rooted up there somewhere.

Some concrete information on the issue from upstream:

  • https://github.com/electron-userland/electron-builder/issues/5377
  • https://github.com/electron/electron-packager/issues/1055
  • https://github.com/electron/node-rcedit/issues/51

A workaround:

A solution that is floated around on most of those issues above is summarised well here: https://github.com/electron/node-rcedit/issues/51#issuecomment-546234084

It suggests using brew to install wine, then editing a package called rcedit to rename wine to wine64. In short, there is a way to make this work. The problem with the workaround from a cordova-electron perspective is that the package doesn't actually get installed anywhere coming from cordova-electron, and I can't work out where this rcedit package fits in the schema of things to file a report elsewhere.

Anyway, back to the core of this issue, it seems possible to build win64 binaries from MacOS and so it seems surprising to me that I can't build those binaries when I could on an earlier mac.

So here's this ticket, where I hope cordova-electron can pursue MacOS win64 builds, even if that simply means identifying the upstream packages and having the community advocate with them. I'm happy to play my part if I can determine how it all fits together.

Command or Code

cordova platform add [email protected]
cordova build electron

Environment, Platform, Device

  • MacOS Big Sur (also present on MacOS Catalina)

Version information

  • cordova 10.0.0
  • cordova-electron 2.0.0
  • brew 3.0.9
  • wine-stable package from brew
  • wine64 --version reports wine-5.0

Checklist

  • [x] I searched for existing GitHub issues
  • [x] I updated all Cordova tooling to most recent version
  • [x] I included all the necessary information above

Thanks for the project, and thanks in advance for your help.

sc0ttdav3y avatar Apr 07 '21 09:04 sc0ttdav3y