-
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 Windows with MinGW #1952
Changes from 1 commit
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 |
---|---|---|
|
@@ -12,18 +12,17 @@ IMPORT_PATH=$(IMPORT_HOST)/Jigsaw-Code/outline-apps | |
all: android apple linux windows | ||
|
||
ROOT_PKG=client/src/tun2socks | ||
# Don't strip Android debug symbols so we can upload them to crash reporting tools. | ||
ANDROID_BUILD_CMD=$(GOBIND) -a -ldflags '-w' -target=android -androidapi 19 -tags android -work | ||
|
||
android: $(BUILDDIR)/android/tun2socks.aar | ||
|
||
$(BUILDDIR)/android/tun2socks.aar: $(GOMOBILE) | ||
mkdir -p "$(BUILDDIR)/android" | ||
$(ANDROID_BUILD_CMD) -o "$@" $(IMPORT_PATH)/$(ROOT_PKG)/outline/tun2socks $(IMPORT_PATH)/$(ROOT_PKG)/outline/shadowsocks | ||
# Don't strip Android debug symbols so we can upload them to crash reporting tools. | ||
$(GOBIND) -target=android -androidapi 19 -tags android -work -a -ldflags '-w' -o "$@" $(IMPORT_PATH)/$(ROOT_PKG)/outline/tun2socks $(IMPORT_PATH)/$(ROOT_PKG)/outline/shadowsocks | ||
|
||
$(BUILDDIR)/ios/Tun2socks.xcframework: $(GOMOBILE) | ||
# -iosversion should match what outline-client supports. | ||
$(GOBIND) -iosversion=12.0 -target=ios,iossimulator -o $@ -ldflags '-w' -bundleid org.outline.tun2socks $(IMPORT_PATH)/$(ROOT_PKG)/outline/tun2socks $(IMPORT_PATH)/$(ROOT_PKG)/outline/shadowsocks | ||
$(GOBIND) -target=ios,iossimulator -iosversion=12.0 -bundleid org.outline.tun2socks -ldflags '-w' -o "$@" $(IMPORT_PATH)/$(ROOT_PKG)/outline/tun2socks $(IMPORT_PATH)/$(ROOT_PKG)/outline/shadowsocks | ||
|
||
$(BUILDDIR)/macos/Tun2socks.xcframework: $(GOMOBILE) | ||
# MACOSX_DEPLOYMENT_TARGET and -iosversion should match what outline-client supports. | ||
|
@@ -38,7 +37,7 @@ $(BUILDDIR)/apple/Tun2socks.xcframework: $(BUILDDIR)/ios/Tun2socks.xcframework $ | |
XGO=$(GOBIN)/xgo | ||
TUN2SOCKS_VERSION=v1.16.11 | ||
XGO_LDFLAGS='-w -X main.version=$(TUN2SOCKS_VERSION)' | ||
ELECTRON_PKG=$(ROOT_PKG)/outline/electron | ||
ELECTRON_PKG="./client/src/tun2socks/outline/electron" | ||
|
||
# TODO: build directly when on linux | ||
LINUX_BUILDDIR=$(BUILDDIR)/linux | ||
|
@@ -56,16 +55,12 @@ WINDOWS_BUILDDIR=$(BUILDDIR)/windows | |
|
||
windows: $(WINDOWS_BUILDDIR)/tun2socks.exe | ||
|
||
$(WINDOWS_BUILDDIR)/tun2socks.exe: $(XGO) | ||
$(WINDOWS_BUILDDIR)/tun2socks.exe: | ||
mkdir -p "$(WINDOWS_BUILDDIR)/$(IMPORT_PATH)" | ||
$(XGO) -ldflags $(XGO_LDFLAGS) --targets=windows/386 -dest "$(WINDOWS_BUILDDIR)" -pkg $(ELECTRON_PKG) . | ||
mv "$(WINDOWS_BUILDDIR)/$(IMPORT_PATH)-windows-386.exe" "$@" | ||
rm -r "$(WINDOWS_BUILDDIR)/$(IMPORT_HOST)" | ||
|
||
GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC="x86_64-w64-mingw32-gcc" go build --ldflags=--extldflags=$(XGO_LDFLAGS) -o "$@" $(ELECTRON_PKG) | ||
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. Note that this is updating from a 32-bit ( 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. As discussed, let's move forward with 64-bit 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. Maybe not in this PR: our CI is not checking the build file (it is building directly from native Windows), we may need to add some x-compile CI jobs in the future. |
||
|
||
$(GOMOBILE): go.mod | ||
env GOBIN="$(GOBIN)" go install golang.org/x/mobile/cmd/gomobile | ||
env GOBIN="$(GOBIN)" $(GOMOBILE) init | ||
go build -o "$(@D)" golang.org/x/mobile/cmd/gomobile golang.org/x/mobile/cmd/gobind | ||
|
||
$(XGO): go.mod | ||
env GOBIN="$(GOBIN)" go install github.com/crazy-max/xgo | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -7,7 +7,6 @@ You will need [Docker](https://www.docker.com/) installed to build the Electron | |||||
> If you can't use Docker, you can use [podman](https://podman.io) as substitute by running the following (for macOS): | ||||||
|
||||||
```sh | ||||||
brew install podman | ||||||
podman machine init | ||||||
sudo ln -s $(which podman) /usr/local/bin/docker | ||||||
sudo /opt/homebrew/Cellar/podman/<podman version>/bin/podman-mac-helper install | ||||||
|
@@ -30,6 +29,26 @@ npm run action electron/start [windows|linux] | |||||
|
||||||
### Windows | ||||||
|
||||||
To build for Windows on a macOS, you need to install minGW v11.0.1. | ||||||
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.
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. Done |
||||||
|
||||||
With Homebrew (how to ensure consistent version?): | ||||||
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. Will MacPorts allow you downloading an old version? Actually homebrew is not the official release channel, MacPorts is: https://www.mingw-w64.org/downloads/ 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. Yes, updated. |
||||||
|
||||||
``` | ||||||
brew install mingw-w64 | ||||||
``` | ||||||
|
||||||
With [MacPorts](https://www.mingw-w64.org/downloads/#macports): | ||||||
|
||||||
``` | ||||||
sudo port install mingw-w64 | ||||||
``` | ||||||
|
||||||
On Ubuntu: | ||||||
|
||||||
``` | ||||||
apt update && apt install -y gcc-mingw-w64 | ||||||
``` | ||||||
|
||||||
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.
I think we are still stripping the debug symbols (
-w
)? Should this be aTODO
?Also we need to consider whether we should include debug symbols, that increase the binary size in a significant amount.
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.
-s is what disables the symbol table.
-w is disable DWARF generation
Ideally we would output tun2socks with debug info, and the client build would remove them. Is that possible?
But that's out of scope for this PR