build: inject BuildTime + Commit ldflags into the mobile binary#8900
build: inject BuildTime + Commit ldflags into the mobile binary#8900myleshorton wants to merge 1 commit into
Conversation
Extend EXTRA_LDFLAGS (already carrying common.Version) with common.BuildTime (UTC) and common.Commit so gomobile/native builds stamp when and from what commit they were built. Pairs with radiance's build-info logging to make a stale build — one whose linked deps don't match go.mod — visible in logs and crash reports. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGpKfgkbfdJwwsTaouMDoR
There was a problem hiding this comment.
Pull request overview
This PR extends the existing Go linker flag injection for mobile builds so the produced binaries carry additional build-identifying metadata (build timestamp and git commit), helping correlate shipped artifacts with source and dependency state.
Changes:
- Adds a UTC RFC3339
BUILD_TIMEstamp (with a PowerShell branch for Windows). - Adds a short
GIT_COMMITstamp and injects both intoEXTRA_LDFLAGSalongside the existingcommon.Version.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ifeq ($(OS),Windows_NT) | ||
| BUILD_TIME ?= $(shell powershell -NoProfile -Command "[DateTime]::UtcNow.ToString('yyyy-MM-ddTHH:mm:ssZ')") | ||
| else | ||
| BUILD_TIME ?= $(shell date -u +%Y-%m-%dT%H:%M:%SZ) | ||
| endif | ||
| GIT_COMMIT ?= $(shell git rev-parse --short HEAD) | ||
| EXTRA_LDFLAGS ?= -X '$(RADIANCE_REPO)/common.Version=$(APP_VERSION_PUBSPEC)' -X '$(RADIANCE_REPO)/common.BuildTime=$(BUILD_TIME)' -X '$(RADIANCE_REPO)/common.Commit=$(GIT_COMMIT)' |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe Makefile's default EXTRA_LDFLAGS was expanded to stamp common.BuildTime and common.Commit in addition to common.Version. New variables BUILD_TIME (platform-dependent) and GIT_COMMIT (git short hash) were introduced to supply these values. ChangesBuild ldflags stamping
Estimated code review effort: 1 (Trivial) | ~5 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
What
Extend
EXTRA_LDFLAGS(already carryingcommon.Version) with:common.BuildTime— UTC RFC3339 build timestampcommon.Commit— short git SHABoth flow into the existing android/macOS/iOS gomobile-bind targets via
EXTRA_LDFLAGS. Windows-safe (powershellbranch for the timestamp).Why
Pairs with getlantern/radiance (getlantern/radiance#556) to make a shipped binary self-describing. A 9.1.14 TestFlight build linked a stale, pre-fix keepcurrent despite go.mod declaring the fix; a build-time + commit stamp (with radiance now logging linked dep versions) makes such a stale build obvious in logs and crash reports instead of silent.
🤖 Generated with Claude Code
https://claude.ai/code/session_01WGpKfgkbfdJwwsTaouMDoR
Summary by CodeRabbit