Skip to content

Commit

Permalink
Simplify build.action.mjs
Browse files Browse the repository at this point in the history
  • Loading branch information
fortuna committed Apr 12, 2024
1 parent c31df07 commit 3c4a5d2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
17 changes: 12 additions & 5 deletions client/src/tun2socks/Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ tasks:
- "{{.GOMOBILE_BIND_CMD}} -target=android -androidapi 22 -o '{{.TARGET_DIR}}/tun2socks.aar' '{{.TASKFILE_DIR}}/outline/tun2socks' '{{.TASKFILE_DIR}}/outline/shadowsocks'"
deps: ["gomobile"]

ios:
desc: "Build the Tun2socks.xcframework library for iOS"
ios-only:
desc: "Build the Tun2socks.xcframework library for iOS only"
internal: true
vars:
TARGET_DIR: '{{.OUT_DIR}}/ios'
cmds:
Expand All @@ -61,8 +62,9 @@ tasks:
- "{{.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:
desc: "Build the Tun2socks.xcframework library for macOS"
macos-only:
desc: "Build the Tun2socks.xcframework library for macOS only"
internal: true
vars:
TARGET_DIR: '{{.OUT_DIR}}/macos'
cmds:
Expand All @@ -73,6 +75,7 @@ tasks:

apple:
desc: "Build combined Tun2socks.xcframework library for Apple platforms"
aliases: [ios, macos, maccatalyst]
vars:
TARGET_DIR: '{{.OUT_DIR}}/apple'
cmds:
Expand All @@ -81,10 +84,14 @@ tasks:
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", "macos"]
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
Expand Down
8 changes: 1 addition & 7 deletions client/src/tun2socks/build.action.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,7 @@ import {getBuildParameters} from '../build/get_build_parameters.mjs';
*/
export async function main(...parameters) {
const {platform: targetPlatform} = getBuildParameters(parameters);

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

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}`);
await spawnStream('go', 'run', 'github.com/go-task/task/v3/cmd/task', '-v', `client:tun2socks:${targetPlatform}`);
}

if (import.meta.url === url.pathToFileURL(process.argv[1]).href) {
Expand Down

0 comments on commit 3c4a5d2

Please sign in to comment.