-
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): use Taskfile for tun2socks #1967
Changes from 9 commits
abcc450
d173d1a
b808880
0d64343
ede26cd
3688bb0
c31df07
3c4a5d2
f6216c2
cd49beb
fb392eb
0626979
d98760d
43fdc9a
90133f8
c9eb496
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
node_modules | ||
.idea | ||
.task | ||
.vs/ | ||
.vscode | ||
*.DS_Store | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
version: '3' | ||
|
||
set: [pipefail] | ||
|
||
run: when_changed | ||
|
||
includes: | ||
client:tun2socks: ./client/src/tun2socks/Taskfile.yml | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
version: '3' | ||
|
||
vars: | ||
# This needs to be updated if the file moves. | ||
# TODO: Output to $REPO_ROOT/output/client/tun2socks instead. | ||
OUT_DIR: '{{joinPath .TASKFILE_DIR "../../output/build"}}' | ||
BIN_DIR: "{{.OUT_DIR}}/build" | ||
VERSION: "v1.16.11" | ||
# Linker flags: https://pkg.go.dev/cmd/link | ||
# -s Omit the symbol table and debug information. | ||
# -w Omit the DWARF symbol table. | ||
# -X Set the value of the string variable. | ||
ELECTRON_BUILD_FLAGS: -trimpath -ldflags="-s -w -X=main.version={{.VERSION}}" | ||
ELECTRON_MAIN_PKG: "{{.TASKFILE_DIR}}/outline/electron" | ||
MOBILE_PKG: "{{.TASKFILE_DIR}}/outline/tun2socks" | ||
GOMOBILE_BIND_CMD: "env PATH=\"{{.BIN_DIR}}:${PATH}\" '{{.BIN_DIR}}/gomobile' bind -ldflags='-s -w'" | ||
|
||
tasks: | ||
windows: | ||
desc: "Build the tun2socks binary for Windows" | ||
vars: | ||
TARGET_DIR: "{{.OUT_DIR}}/windows" | ||
cmds: | ||
- rm -rf "{{.TARGET_DIR}}" && mkdir -p "{{.TARGET_DIR}}" | ||
- | | ||
{{if ne OS "windows"}}GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC='zig cc -target x86_64-windows' {{end}}go build {{.ELECTRON_BUILD_FLAGS}} -o '{{.TARGET_DIR}}/tun2socks.exe' '{{.ELECTRON_MAIN_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. Is there a way we can space this out to make it more readable? ie
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. or maybe it makes sense to load env or taskfiles based on the environment in a "setup environment" task 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. I did the reformatting you suggested. |
||
|
||
linux: | ||
desc: "Build the tun2socks binary for Linux" | ||
vars: | ||
TARGET_DIR: '{{.OUT_DIR}}/linux' | ||
cmds: | ||
- rm -rf "{{.TARGET_DIR}}" && mkdir -p "{{.TARGET_DIR}}" | ||
- | | ||
{{if ne OS "linux"}}GOOS=linux GOARCH=amd64 CGO_ENABLED=1 CC='zig cc -target x86_64-linux' {{end}}go build {{.ELECTRON_BUILD_FLAGS}} -o '{{.TARGET_DIR}}/tun2socks' '{{.ELECTRON_MAIN_PKG}}' | ||
|
||
android: | ||
desc: "Build the tun2socks.aar library for Android" | ||
vars: | ||
TARGET_DIR: "{{.OUT_DIR}}/android" | ||
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. | ||
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. should we hoist the androidapi into a var? 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. I like that, it's cleaner. Done. |
||
- "{{.GOMOBILE_BIND_CMD}} -target=android -androidapi 22 -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' | ||
cmds: | ||
- rm -rf "{{.TARGET_DIR}}" && mkdir -p "{{.TARGET_DIR}}" | ||
# -iosversion should match the target version that the iOS client supports. | ||
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. same with iosversion 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 |
||
- "{{.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'" | ||
deps: ["gomobile"] | ||
|
||
macos-only: | ||
desc: "Build the Tun2socks.xcframework library for macOS only" | ||
internal: true | ||
vars: | ||
TARGET_DIR: '{{.OUT_DIR}}/macos' | ||
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' | ||
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. and macosx deployment target 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 |
||
deps: ["gomobile"] | ||
|
||
apple: | ||
desc: "Build combined Tun2socks.xcframework library for Apple platforms" | ||
aliases: [ios, macos, maccatalyst] | ||
vars: | ||
TARGET_DIR: '{{.OUT_DIR}}/apple' | ||
cmds: | ||
- rm -rf "{{.TARGET_DIR}}" && mkdir -p "{{.TARGET_DIR}}" | ||
- | | ||
find '{{.OUT_DIR}}/macos/Tun2socks.xcframework' '{{.OUT_DIR}}/ios/Tun2socks.xcframework' -name "Tun2socks.framework" -type d | | ||
xargs -I {} echo " -framework {} " | | ||
xargs xcrun xcodebuild -create-xcframework -output '{{.TARGET_DIR}}/Tun2socks.xcframework' | ||
deps: ["ios-only", "macos-only"] | ||
|
||
browser: | ||
desc: "Placeholder for the browser build. Does nothing" | ||
|
||
gomobile: | ||
desc: "Build Go Mobile" | ||
internal: true | ||
cmds: | ||
- mkdir -p "{{.BIN_DIR}}" | ||
- go build -o "{{.BIN_DIR}}" golang.org/x/mobile/cmd/gomobile golang.org/x/mobile/cmd/gobind | ||
sources: ["{{.REPO_ROOT}}/go.sum"] | ||
generates: ["{{.BIN_DIR}}/gomobile", "{{.BIN_DIR}}/gobind"] | ||
|
||
clean: | ||
cmds: | ||
- rm -r "{{.REPO_ROOT}}/output/client/tun2socks" .task | ||
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. can we add this clean to the root package.json clean? 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. Good idea. Done. |
||
- go clean -i -r '{{.TASKFILE_DIR}}/outline/tun2socks' '{{.TASKFILE_DIR}}/outline/shadowsocks' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,42 @@ | ||
module github.com/Jigsaw-Code/outline-apps | ||
|
||
go 1.20 | ||
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/stretchr/testify v1.8.2 | ||
github.com/go-task/task/v3 v3.36.0 | ||
github.com/stretchr/testify v1.9.0 | ||
golang.org/x/mobile v0.0.0-20231127183840-76ac6878050a | ||
golang.org/x/sys v0.15.0 | ||
golang.org/x/sys v0.19.0 | ||
) | ||
|
||
require ( | ||
github.com/Masterminds/semver/v3 v3.2.1 // indirect | ||
github.com/davecgh/go-spew v1.1.1 // indirect | ||
github.com/fatih/color v1.16.0 // indirect | ||
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect | ||
github.com/joho/godotenv v1.5.1 // indirect | ||
github.com/klauspost/cpuid/v2 v2.0.9 // indirect | ||
github.com/mattn/go-colorable v0.1.13 // indirect | ||
github.com/mattn/go-isatty v0.0.20 // indirect | ||
github.com/mattn/go-zglob v0.0.4 // indirect | ||
github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect | ||
github.com/pmezard/go-difflib v1.0.0 // indirect | ||
github.com/radovskyb/watcher v1.0.7 // indirect | ||
github.com/sajari/fuzzy v1.0.0 // indirect | ||
github.com/shadowsocks/go-shadowsocks2 v0.1.5 // indirect | ||
github.com/songgao/water v0.0.0-20200317203138-2b4b6d7c09d8 // indirect | ||
golang.org/x/crypto v0.17.0 // indirect | ||
github.com/spf13/pflag v1.0.5 // indirect | ||
github.com/zeebo/xxh3 v1.0.2 // indirect | ||
golang.org/x/crypto v0.18.0 // indirect | ||
golang.org/x/mod v0.14.0 // indirect | ||
golang.org/x/net v0.19.0 // indirect | ||
golang.org/x/sync v0.5.0 // indirect | ||
golang.org/x/tools v0.16.0 // indirect | ||
golang.org/x/net v0.20.0 // indirect | ||
golang.org/x/sync v0.7.0 // indirect | ||
golang.org/x/term v0.19.0 // indirect | ||
golang.org/x/tools v0.17.0 // indirect | ||
gopkg.in/yaml.v3 v3.0.1 // indirect | ||
mvdan.cc/sh/v3 v3.8.0 // indirect | ||
) |
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.
note to self that we'll need to change this to "backend" if that other PR is merged