Skip to content
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

Merged
merged 16 commits into from
Apr 12, 2024
Merged

build(client): use Taskfile for tun2socks #1967

merged 16 commits into from
Apr 12, 2024

Conversation

fortuna
Copy link
Collaborator

@fortuna fortuna commented Apr 11, 2024

This is nice:
image

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 with go build github.com/go-task/task/v3/cmd/task, then just call task.

This PR doesn't move any files, including sources and build output.

@fortuna fortuna changed the title build(client): use Taskfile for tun2socks. build(client): use Taskfile for tun2socks Apr 11, 2024
@github-actions github-actions bot added size/L and removed size/M labels Apr 11, 2024
@fortuna fortuna marked this pull request as ready for review April 11, 2024 23:06
@fortuna fortuna requested a review from a team as a code owner April 11, 2024 23:06
run: when_changed

includes:
client:tun2socks: ./client/src/tun2socks/Taskfile.yml
Copy link
Contributor

@daniellacosse daniellacosse Apr 12, 2024

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

Copy link
Contributor

@daniellacosse daniellacosse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a few thoughts

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}}'
Copy link
Contributor

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}}'

Copy link
Contributor

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

Copy link
Collaborator Author

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.

msg: "Must set ANDROID_NDK"
cmds:
- rm -rf "{{.TARGET_DIR}}" && mkdir -p "{{.TARGET_DIR}}"
# -androidapi should match the minSdkVersion that the Android client supports.
Copy link
Contributor

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?

Copy link
Collaborator Author

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.

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same with iosversion

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

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'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and macosx deployment target

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


clean:
cmds:
- rm -r "{{.REPO_ROOT}}/output/client/tun2socks" .task
Copy link
Contributor

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. Done.

Copy link
Collaborator Author

@fortuna fortuna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments addressed

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}}'
Copy link
Collaborator Author

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.

msg: "Must set ANDROID_NDK"
cmds:
- rm -rf "{{.TARGET_DIR}}" && mkdir -p "{{.TARGET_DIR}}"
# -androidapi should match the minSdkVersion that the Android client supports.
Copy link
Collaborator Author

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.

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.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

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'
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


clean:
cmds:
- rm -r "{{.REPO_ROOT}}/output/client/tun2socks" .task
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. Done.

@daniellacosse
Copy link
Contributor

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 -}}
Copy link
Collaborator Author

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.

@fortuna fortuna merged commit 685ef88 into master Apr 12, 2024
19 checks passed
@fortuna fortuna deleted the fortuna-taskfile2 branch April 12, 2024 19:15
jyyi1 added a commit that referenced this pull request Apr 24, 2024
…file (#1997)

This PR fixes several path issues in electron caused by the recent source code movement and output path change in #1967 .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants