From 576224eb21c90cb95a9089678f12bf1394dd9fe4 Mon Sep 17 00:00:00 2001 From: Vinicius Fortuna Date: Thu, 4 Apr 2024 18:29:31 -0400 Subject: [PATCH 1/3] Build Windows with MinGW --- Makefile | 19 +++++++------------ src/electron/README.md | 21 ++++++++++++++++++++- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 17a7512923..dc6b031320 100644 --- a/Makefile +++ b/Makefile @@ -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) $(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 diff --git a/src/electron/README.md b/src/electron/README.md index 331658da54..560757c0cb 100644 --- a/src/electron/README.md +++ b/src/electron/README.md @@ -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//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. + +With Homebrew (how to ensure consistent version?): + +``` +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. From b0bcf5a4785985b0e503642fa3595dc8cb155e96 Mon Sep 17 00:00:00 2001 From: Vinicius Fortuna Date: Thu, 4 Apr 2024 19:12:41 -0400 Subject: [PATCH 2/3] Fix Makefile --- Makefile | 3 ++- package-lock.json | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index dc6b031320..d19085aaf1 100644 --- a/Makefile +++ b/Makefile @@ -56,10 +56,11 @@ WINDOWS_BUILDDIR=$(BUILDDIR)/windows windows: $(WINDOWS_BUILDDIR)/tun2socks.exe $(WINDOWS_BUILDDIR)/tun2socks.exe: - mkdir -p "$(WINDOWS_BUILDDIR)/$(IMPORT_PATH)" + mkdir -p "$(@D)" GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC="x86_64-w64-mingw32-gcc" go build --ldflags=--extldflags=$(XGO_LDFLAGS) -o "$@" $(ELECTRON_PKG) $(GOMOBILE): go.mod + mkdir -p "$(@D)" go build -o "$(@D)" golang.org/x/mobile/cmd/gomobile golang.org/x/mobile/cmd/gobind $(XGO): go.mod diff --git a/package-lock.json b/package-lock.json index e4abd813ba..d5e246cd3b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -121,8 +121,7 @@ "karma-webpack": "^5.0.0", "minimist": "^1.2.6", "node-fetch": "^3.3.0", - "node-gyp": "^10.1.0", - "outline-i18n": "Jigsaw-Code/outline-i18n#v0.0.7", + "node-gyp": "^10.0.1", "postcss": "^7.0.39", "postcss-rtl": "^1.7.3", "prettier": "^2.8.0", From b6a236b1fb1d197c1ab203be6e83603d39c4db53 Mon Sep 17 00:00:00 2001 From: Vinicius Fortuna Date: Fri, 5 Apr 2024 12:40:32 -0400 Subject: [PATCH 3/3] Address comments --- src/electron/README.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/electron/README.md b/src/electron/README.md index 560757c0cb..5db4ed4306 100644 --- a/src/electron/README.md +++ b/src/electron/README.md @@ -1,4 +1,4 @@ -## Electron Development Instructions +# Electron Development Instructions Unlike the Android and Apple clients, the Windows and Linux clients use the Electron framework, rather than Cordova. @@ -27,26 +27,26 @@ To run the Electron clients, run: npm run action electron/start [windows|linux] ``` -### Windows +## Windows -To build for Windows on a macOS, you need to install minGW v11.0.1. +To build for Windows on a macOS, you need to first install [MinGW-w64](https://www.mingw-w64.org/) v11.0.1+. -With Homebrew (how to ensure consistent version?): +With [MacPorts](https://www.mingw-w64.org/downloads/#macports) (official channel): -``` -brew install mingw-w64 +```sh +sudo port install x86_64-w64-mingw32-gcc @11.0.1 ``` -With [MacPorts](https://www.mingw-w64.org/downloads/#macports): +With Homebrew (unofficial, how to ensure consistent version?): -``` -sudo port install mingw-w64 +```sh +brew install mingw-w64 ``` -On Ubuntu: +You can also build it on Ubuntu. To install MinGW-w64: -``` -apt update && apt install -y gcc-mingw-w64 +```sh +apt update && apt install -y gcc-mingw-w64-x86-64 ``` To build the _release_ version of Windows installer, you'll also need: