Harden Xray lifecycle and build tooling#135
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR hardens the libXray runtime lifecycle (preventing multiple concurrent starts) and streamlines build tooling by switching the C bridge to a committed Go entrypoint, ensuring the repository’s Go module state is restored after builds, and adding CI validation coverage for the C ABI.
Changes:
- Serialize Xray instance start/stop/state operations and reject duplicate starts with a stable error (
ErrAlreadyRunning). - Replace generated/rewritten C bridge sources with a committed
cgo_bridgepackage and update builders to build that package directly while snapshotting/restoringgo.mod/go.sum. - Add lifecycle tests and a validation workflow that checks the Linux C ABI includes
CGoFreeand that builds leave no tracked diffs behind.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
xray/xray.go |
Adds a mutex-protected singleton lifecycle and duplicate-start rejection. |
xray/xray_test.go |
Introduces lifecycle/concurrency tests around start/state/stop behavior. |
README.md |
Documents new C ABI ownership contract via CGoFree. |
readme/README.zh_CN.md |
Same as above for zh_CN documentation. |
cgo_bridge/main.go |
Adds committed C-export entrypoint (CGoInvoke/CGoFree) for C ABI builds. |
build/template/main.gotemplate |
Removes the previously templated/generated bridge entrypoint. |
build/app/build.py |
Implements Go module snapshot/restore; switches to building ./cgo_bridge; resolves matching gomobile/gobind. |
build/app/android.py |
Wraps build in snapshot/restore and relies on committed bridge package. |
build/app/apple_gomobile.py |
Wraps build in snapshot/restore to keep module state clean. |
build/app/apple_go.py |
Simplifies linker flags, builds committed bridge package, and wraps build in snapshot/restore. |
build/app/linux.py |
Builds committed bridge package and wraps build in snapshot/restore. |
build/app/windows.py |
Builds committed bridge package and wraps build in snapshot/restore. |
.github/workflows/validate.yml |
Adds CI validation (race tests + C ABI symbol checks + “no diffs after build”). |
.github/workflows/build.yml |
Pins toolchain versions used for release builds. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
gomobilerelease at build time and register the matchinggobindtool dependency dynamically.Validation
go test ./... -count=1go mod tidy -diffpython3 build/main.py androidgit diff --check