-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
build(client/electron): build cross-platform with zig #1960
Changes from 5 commits
2433e31
10dfd0b
afbaa31
ab04bf4
19d8549
7767855
0236cd4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -2,19 +2,6 @@ | |||||
|
||||||
Unlike the Android and Apple clients, the Windows and Linux clients use the Electron framework, rather than Cordova. | ||||||
|
||||||
You will need [Docker](https://www.docker.com/) installed to build the Electron clients. | ||||||
fortuna marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
> If you can't use Docker, you can use [podman](https://podman.io) as substitute by running the following (for macOS): | ||||||
|
||||||
```sh | ||||||
podman machine init | ||||||
sudo ln -s $(which podman) /usr/local/bin/docker | ||||||
sudo /opt/homebrew/Cellar/podman/<podman version>/bin/podman-mac-helper install | ||||||
podman machine start | ||||||
``` | ||||||
|
||||||
> You may run into the error: `/var/folders/<path>/xgo-cache: no such file or directory`. If so, simply create that directory with `mkdir -p /var/folders/<path>/xgo-cache` and try again. | ||||||
|
||||||
To build the Electron clients, run (it will also package an installer executable into `build/dist`): | ||||||
|
||||||
```sh | ||||||
|
@@ -27,28 +14,21 @@ To run the Electron clients, run: | |||||
npm run action electron/start [windows|linux] | ||||||
``` | ||||||
|
||||||
## Windows | ||||||
## Cross-Compiling | ||||||
|
||||||
To build for Windows on a macOS, you need to first install [MinGW-w64](https://www.mingw-w64.org/) v11.0.1+. | ||||||
To build the app for a platform target on a different host target, you will need a cross-compiler. We use [zig to cross-compile with cgo](https://dev.to/kristoff/zig-makes-go-cross-compilation-just-work-29ho). | ||||||
|
||||||
With [MacPorts](https://www.mingw-w64.org/downloads/#macports) (official channel): | ||||||
[Install zig](https://ziglang.org/learn/getting-started/#installing-zig) and make sure it's in the PATH. | ||||||
|
||||||
```sh | ||||||
sudo port install x86_64-w64-mingw32-gcc @11.0.1 | ||||||
``` | ||||||
|
||||||
With Homebrew (unofficial, how to ensure consistent version?): | ||||||
You can download the binary tarball, or use a package manager, like Homebrew: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A link to the supported package managers may be useful. It covers almost all platforms including Windows, macOS and Ubuntu.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added (though the install instruction above also mentions list them) |
||||||
|
||||||
```sh | ||||||
brew install mingw-w64 | ||||||
jyyi1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
brew install zig | ||||||
``` | ||||||
|
||||||
You can also build it on Ubuntu. To install MinGW-w64: | ||||||
|
||||||
```sh | ||||||
apt update && apt install -y gcc-mingw-w64-x86-64 | ||||||
``` | ||||||
## Release | ||||||
|
||||||
To build the _release_ version of Windows installer, you'll also need: | ||||||
|
||||||
- [Java 8+ Runtime](https://www.java.com/en/download/). This is required for the cross-platform Windows executable signing tool [Jsign](https://ebourg.github.io/jsign/). If you don't need to sign the executables, feel free to skip this. | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
zig
also supportsx86_64-windows
as well. But it only supports Windows 10+. We can keep using MinGW-w64 for backward compatibility now, but I'd prefer to use the same toolchain in the future when we decide to drop the support of old Windows.