Skip to content

Harden Xray lifecycle and build tooling#135

Merged
yiguodev merged 3 commits into
mainfrom
dev-26.7-5
Jul 11, 2026
Merged

Harden Xray lifecycle and build tooling#135
yiguodev merged 3 commits into
mainfrom
dev-26.7-5

Conversation

@yiguodev

Copy link
Copy Markdown
Collaborator

Summary

  • Harden Xray instance lifecycle handling and C ABI memory ownership.
  • Build the C bridge from committed source and simplify platform builders while preserving clean module state.
  • Add lifecycle tests and validation workflow coverage.
  • Resolve the latest gomobile release at build time and register the matching gobind tool dependency dynamically.

Validation

  • go test ./... -count=1
  • go mod tidy -diff
  • python3 build/main.py android
  • git diff --check

@yiguodev
yiguodev marked this pull request as ready for review July 11, 2026 02:05
Copilot AI review requested due to automatic review settings July 11, 2026 02:05

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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_bridge package and update builders to build that package directly while snapshotting/restoring go.mod/go.sum.
  • Add lifecycle tests and a validation workflow that checks the Linux C ABI includes CGoFree and 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.

Comment thread cgo_bridge/main.go
Copilot AI review requested due to automatic review settings July 11, 2026 02:15

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated no new comments.

@yiguodev
yiguodev merged commit d72d529 into main Jul 11, 2026
4 checks passed
@yiguodev
yiguodev deleted the dev-26.7-5 branch July 11, 2026 02:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants