Skip to content

Commit

Permalink
Improve
Browse files Browse the repository at this point in the history
  • Loading branch information
fortuna committed Apr 11, 2024
1 parent d173d1a commit b808880
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 86 deletions.
69 changes: 0 additions & 69 deletions Makefile

This file was deleted.

24 changes: 19 additions & 5 deletions client/src/tun2socks/Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@ vars:
sh: "readlink -f '{{.TASKFILE_DIR}}/../../output/build'"
BIN_DIR: "{{.OUT_DIR}}/build"
VERSION: "v1.16.11"
# -w disable DWARF generation
LD_FLAGS: "-static -w -X main.version={{.VERSION}}"
# 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 '-w'"
GOMOBILE_BIND_CMD: "env PATH=\"{{.BIN_DIR}}:${PATH}\" '{{.BIN_DIR}}/gomobile' bind -ldflags='-s -w'"

tasks:
windows:
Expand All @@ -22,20 +25,31 @@ tasks:
TARGET_DIR: "{{.OUT_DIR}}/windows"
cmds:
- rm -rf "{{.TARGET_DIR}}" && mkdir -p "{{.TARGET_DIR}}"
- GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC='zig cc -target x86_64-windows' go build -trimpath -ldflags=--extldflags='{{.LD_FLAGS}}' -o '{{.TARGET_DIR}}/tun2socks.exe' '{{.ELECTRON_MAIN_PKG}}'
- cmd: go build {{.ELECTRON_BUILD_FLAGS}} -o '{{.TARGET_DIR}}/tun2socks.exe' '{{.ELECTRON_MAIN_PKG}}'
platforms: [windows]
- cmd: GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC='zig cc -target x86_64-windows' go build {{.ELECTRON_BUILD_FLAGS}} -o '{{.TARGET_DIR}}/tun2socks.exe' '{{.ELECTRON_MAIN_PKG}}'
platforms: [darwin, linux]

linux:
desc: "Build the tun2socks binary for Linux"
vars:
TARGET_DIR: '{{.OUT_DIR}}/linux'
cmds:
- rm -rf "{{.TARGET_DIR}}" && mkdir -p "{{.TARGET_DIR}}"
- GOOS=linux GOARCH=amd64 CGO_ENABLED=1 CC='zig cc -target x86_64-linux' go build -trimpath -ldflags=--extldflags='{{.LD_FLAGS}}' -o '{{.TARGET_DIR}}/tun2socks' '{{.ELECTRON_MAIN_PKG}}'
- cmd: go build {{.ELECTRON_BUILD_FLAGS}} -o '{{.TARGET_DIR}}/tun2socks' '{{.ELECTRON_MAIN_PKG}}'
platforms: [linux]
- cmd: GOOS=linux GOARCH=amd64 CGO_ENABLED=1 CC='zig cc -target x86_64-linux' go build {{.ELECTRON_BUILD_FLAGS}} -o '{{.TARGET_DIR}}/tun2socks' '{{.ELECTRON_MAIN_PKG}}'
platforms: [darwin, windows]

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.
Expand Down
12 changes: 0 additions & 12 deletions client/src/tun2socks/build.action.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,10 @@ import {getBuildParameters} from '../build/get_build_parameters.mjs';
export async function main(...parameters) {
const {platform: targetPlatform} = getBuildParameters(parameters);

const currentPlatform = os.platform() === 'win32' ? 'windows' : os.platform();

if (targetPlatform === 'browser') {
return;
}

if (targetPlatform === currentPlatform && ['linux', 'windows'].includes(targetPlatform)) {
return spawnStream(
'go',
'build',
'-o',
`output/build/${targetPlatform}/tun2socks${targetPlatform === 'windows' ? '.exe' : ''}`,
'github.com/Jigsaw-Code/outline-apps/client/src/tun2socks/outline/electron'
);
}

const taskName = ['ios', 'macos', 'maccatalyst'].includes(targetPlatform) ? 'apple' : targetPlatform
await spawnStream('go', 'run', 'github.com/go-task/task/v3/cmd/task', '-v', `client:tun2socks:${taskName}`);
}
Expand Down

0 comments on commit b808880

Please sign in to comment.