-
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
Conversation
run: when_changed | ||
|
||
includes: | ||
client:tun2socks: ./client/src/tun2socks/Taskfile.yml |
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
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.
a few thoughts
client/src/tun2socks/Taskfile.yml
Outdated
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 comment
The 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
{{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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
I did the reformatting you suggested.
client/src/tun2socks/Taskfile.yml
Outdated
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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
I like that, it's cleaner. Done.
client/src/tun2socks/Taskfile.yml
Outdated
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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Done
client/src/tun2socks/Taskfile.yml
Outdated
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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Done
client/src/tun2socks/Taskfile.yml
Outdated
|
||
clean: | ||
cmds: | ||
- rm -r "{{.REPO_ROOT}}/output/client/tun2socks" .task |
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.
can we add this clean to the root package.json clean?
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.
Good idea. Done.
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.
Comments addressed
client/src/tun2socks/Taskfile.yml
Outdated
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 comment
The reason will be displayed to describe this comment to others. Learn more.
I did the reformatting you suggested.
client/src/tun2socks/Taskfile.yml
Outdated
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 comment
The reason will be displayed to describe this comment to others. Learn more.
I like that, it's cleaner. Done.
client/src/tun2socks/Taskfile.yml
Outdated
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Done
client/src/tun2socks/Taskfile.yml
Outdated
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Done
client/src/tun2socks/Taskfile.yml
Outdated
|
||
clean: | ||
cmds: | ||
- rm -r "{{.REPO_ROOT}}/output/client/tun2socks" .task |
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.
Good idea. Done.
Just make sure to fix the breaking build |
# -w Omit the DWARF symbol table. | ||
# -X Set the value of the string variable. | ||
- | | ||
{{if ne OS .TARGET_OS -}} |
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.
Ugh, it turns out OS is a function, not a variable, so it doesn't take the .
. That was breaking the build.
This is nice:
Also, we can have different behavior based on the host platform very easily. And test preconditions as well. See my code.
I believe we can replace our run_action with Taskfile instead.
Details: https://taskfile.dev/
You can run the tasks with
go run github.com/go-task/task/v3/cmd/task
, or we can build it withgo build github.com/go-task/task/v3/cmd/task
, then just calltask
.This PR doesn't move any files, including sources and build output.