Skip to content

Commit

Permalink
Address review
Browse files Browse the repository at this point in the history
  • Loading branch information
fortuna committed Apr 12, 2024
1 parent cd49beb commit fb392eb
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 14 deletions.
5 changes: 5 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,8 @@ run: when_changed

includes:
client:tun2socks: ./client/src/tun2socks/Taskfile.yml

tasks:
clean:
deps:
- client:tun2socks:clean
26 changes: 17 additions & 9 deletions client/src/tun2socks/Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ version: '3'

vars:
# This needs to be updated if the file moves.
REPO_ROOT: '{{joinPath .TASKFILE_DIR "../../.."}}'
# TODO: Output to $REPO_ROOT/output/client/tun2socks instead.
OUT_DIR: '{{joinPath .TASKFILE_DIR "../../output/build"}}'
OUT_DIR: '{{joinPath .REPO_ROOT "client/output/build"}}'
BIN_DIR: "{{.OUT_DIR}}/build"
MOBILE_PKG: "{{.TASKFILE_DIR}}/outline/tun2socks"
GOMOBILE_BIND_CMD: "env PATH=\"{{.BIN_DIR}}:${PATH}\" '{{.BIN_DIR}}/gomobile' bind -ldflags='-s -w'"
Expand All @@ -24,7 +25,9 @@ tasks:
# -w Omit the DWARF symbol table.
# -X Set the value of the string variable.
- |
{{if ne OS "{{.TARGET_OS}}"}}GOOS={{.TARGET_OS}} GOARCH=amd64 CGO_ENABLED=1 CC='zig cc -target x86_64-{{.TARGET_OS}}'{{end}} \
{{if ne OS "{{.TARGET_OS}}" -}}
GOOS={{.TARGET_OS}} GOARCH=amd64 CGO_ENABLED=1 CC='zig cc -target x86_64-{{.TARGET_OS}}'
{{- end}} \
go build -trimpath -ldflags="-s -w -X=main.version={{.TUN2SOCKS_VERSION}}" -o '{{.OUTPUT}}' '{{.TASKFILE_DIR}}/outline/electron'
windows:
Expand All @@ -39,37 +42,42 @@ tasks:
desc: "Build the tun2socks.aar library for Android"
vars:
TARGET_DIR: "{{.OUT_DIR}}/android"
# ANDROID_API must match the minSdkVersion that the Android client supports.
ANDROID_API: 22
preconditions:
- sh: '[[ -d "$ANDROID_HOME" ]]'
msg: "Must set ANDROID_HOME"
- sh: '[[ -d "$ANDROID_NDK" ]]'
msg: "Must set ANDROID_NDK"
cmds:
- rm -rf "{{.TARGET_DIR}}" && mkdir -p "{{.TARGET_DIR}}"
# -androidapi should match the minSdkVersion that the Android client supports.
- "{{.GOMOBILE_BIND_CMD}} -target=android -androidapi 22 -o '{{.TARGET_DIR}}/tun2socks.aar' '{{.TASKFILE_DIR}}/outline/tun2socks' '{{.TASKFILE_DIR}}/outline/shadowsocks'"
- "{{.GOMOBILE_BIND_CMD}} -target=android -androidapi '{{.ANDROID_API}}' -o '{{.TARGET_DIR}}/tun2socks.aar' '{{.TASKFILE_DIR}}/outline/tun2socks' '{{.TASKFILE_DIR}}/outline/shadowsocks'"
deps: ["gomobile"]

ios-only:
desc: "Build the Tun2socks.xcframework library for iOS only"
internal: true
vars:
TARGET_DIR: '{{.OUT_DIR}}/ios'
# TARGET_IOS_VERSION must match the target version that the iOS client supports.
TARGET_IOS_VERSION: 12.0
cmds:
- rm -rf "{{.TARGET_DIR}}" && mkdir -p "{{.TARGET_DIR}}"
# -iosversion should match the target version that the iOS client supports.
- "{{.GOMOBILE_BIND_CMD}} -target=ios,iossimulator -iosversion=12.0 -bundleid org.outline.tun2socks -o '{{.TARGET_DIR}}/Tun2socks.xcframework' '{{.TASKFILE_DIR}}/outline/tun2socks' '{{.TASKFILE_DIR}}/outline/shadowsocks'"
- "{{.GOMOBILE_BIND_CMD}} -target=ios,iossimulator -iosversion={{.TARGET_IOS_VERSION}} -bundleid org.outline.tun2socks -o '{{.TARGET_DIR}}/Tun2socks.xcframework' '{{.TASKFILE_DIR}}/outline/tun2socks' '{{.TASKFILE_DIR}}/outline/shadowsocks'"
deps: ["gomobile"]

macos-only:
desc: "Build the Tun2socks.xcframework library for macOS only"
internal: true
vars:
TARGET_DIR: '{{.OUT_DIR}}/macos'
# MACOSX_DEPLOYMENT_TARGET must match the version the version set in the XCode project.
MACOSX_DEPLOYMENT_TARGET: 10.14
# TARGET_IOS_VERSION must be at least 13.1 for macCatalyst and >= the iOS TARGET_IOS_VERSION.
TARGET_IOS_VERSION: 13.1
cmds:
- rm -rf "{{.TARGET_DIR}}" && mkdir -p "{{.TARGET_DIR}}"
# MACOSX_DEPLOYMENT_TARGET and -iosversion should match the versions that the macOS client supports.
- export MACOSX_DEPLOYMENT_TARGET=10.14; {{.GOMOBILE_BIND_CMD}} -target=macos,maccatalyst -iosversion=13.1 -bundleid org.outline.tun2socks -o '{{.TARGET_DIR}}/Tun2socks.xcframework' '{{.TASKFILE_DIR}}/outline/tun2socks' '{{.TASKFILE_DIR}}/outline/shadowsocks'
- export MACOSX_DEPLOYMENT_TARGET={{.MACOSX_DEPLOYMENT_TARGET}}; {{.GOMOBILE_BIND_CMD}} -target=macos,maccatalyst -iosversion={{.TARGET_IOS_VERSION}} -bundleid org.outline.tun2socks -o '{{.TARGET_DIR}}/Tun2socks.xcframework' '{{.TASKFILE_DIR}}/outline/tun2socks' '{{.TASKFILE_DIR}}/outline/shadowsocks'
deps: ["gomobile"]

apple:
Expand Down Expand Up @@ -99,5 +107,5 @@ tasks:

clean:
cmds:
- rm -r "{{.REPO_ROOT}}/output/client/tun2socks" .task
- rm -r '{{.OUT_DIR}}'
- go clean -i -r '{{.TASKFILE_DIR}}/outline/tun2socks' '{{.TASKFILE_DIR}}/outline/shadowsocks'
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ go 1.21
require (
github.com/Jigsaw-Code/outline-sdk v0.0.14-0.20240216220040-f741c57bf854
github.com/Jigsaw-Code/outline-sdk/x v0.0.0-20240223000159-142376ee10ea
github.com/crazy-max/xgo v0.30.0
github.com/eycorsican/go-tun2socks v1.16.11
github.com/go-task/task/v3 v3.36.0
github.com/stretchr/testify v1.9.0
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ github.com/Jigsaw-Code/outline-sdk/x v0.0.0-20240223000159-142376ee10ea h1:SAzKK
github.com/Jigsaw-Code/outline-sdk/x v0.0.0-20240223000159-142376ee10ea/go.mod h1:lYYruRIG1B5nVqkGQZajQK5jS2BIkMaEBM7yjzl5fIo=
github.com/Masterminds/semver/v3 v3.2.1 h1:RN9w6+7QoMeJVGyfmbcgs28Br8cvmnucEXnY0rYXWg0=
github.com/Masterminds/semver/v3 v3.2.1/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ=
github.com/crazy-max/xgo v0.30.0 h1:2uunjwLBrVu5LKIS1dIDXz9U5OIX4H5LEsC3P6wFTto=
github.com/crazy-max/xgo v0.30.0/go.mod h1:m/aqfKaN/cYzfw+Pzk7Mk0tkmShg3/rCS4Zdhdugi4o=
github.com/creack/pty v1.1.21 h1:1/QdRyBaHHJP61QkWMXlOIBfsgdDeeKfK8SYVUWJKf0=
github.com/creack/pty v1.1.21/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"action:help": "npm run action list",
"action:list": "npm run action list",
"action": "node ./src/build/run_action.mjs",
"clean": "rimraf .task client/build client/output node_modules client/node_modules client/www client/platforms client/plugins third_party/jsign/*.jar",
"clean": "rimraf client/build client/output node_modules client/node_modules client/www client/platforms client/plugins third_party/jsign/*.jar && go run github.com/go-task/task/v3/cmd/task clean",
"format:all": "prettier --write \"**/*.{cjs,mjs,html,js,json,md,ts}\"",
"format": "pretty-quick --staged --pattern \"**/*.{cjs,mjs,html,js,json,md,ts}\"",
"lint:ts": "eslint --ext ts,mjs client/src",
Expand Down
1 change: 0 additions & 1 deletion tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
package tools

import (
_ "github.com/crazy-max/xgo"
_ "github.com/go-task/task/v3/cmd/task"
_ "golang.org/x/mobile/cmd/gobind"
_ "golang.org/x/mobile/cmd/gomobile"
Expand Down

0 comments on commit fb392eb

Please sign in to comment.