Add -a flag to llgo build to force package rebuilds#1437
Conversation
- Add ForceRebuild flag to cmd/internal/flags/flags.go - Register -a flag with description in AddBuildFlags() - Add ForceRebuild field to Config struct in internal/build/build.go - Modify tryLoadFromCache() to skip cache when ForceRebuild is set - Add comprehensive test TestTryLoadFromCache_ForceRebuild This mirrors the go build -a behavior, forcing a rebuild of all packages even when cached artifacts are up to date. This helps during development when compiler/runtime changes need to take effect without manually removing build caches. Fixes #1436 Generated with [codeagent](https://github.com/qbox/codeagent) Co-authored-by: cpunion <8459+cpunion@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1437 +/- ##
=======================================
Coverage 90.63% 90.63%
=======================================
Files 43 43
Lines 11400 11400
=======================================
Hits 10332 10332
Misses 907 907
Partials 161 161 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@xgopilot flag redefined: a |
Fixed flag redefinition issue ✅AnalysisFound the issue! The
Commands like base.PassBuildFlags(Cmd)
flags.AddBuildFlags(&Cmd.Flag)This caused the flag to be registered twice on the same FlagSet, resulting in the "flag redefined: a" error. Fix AppliedRemoved the Testing
The |
The -a flag was being registered twice: 1. In base.PassBuildFlags() as a pass-through flag 2. In flags.AddBuildFlags() with full functionality Commands calling both functions caused 'flag redefined: a' error. Removed the -a flag from PassBuildFlags() since it's now properly implemented in AddBuildFlags() with ForceRebuild functionality. Generated with [codeagent](https://github.com/qbox/codeagent) Co-authored-by: cpunion <8459+cpunion@users.noreply.github.com>
Requested by @cpunion
This PR adds the
-aflag tollgo build, mirroring thego build -abehavior to force rebuilding of all packages even when cached artifacts are up to date.Summary
-aflag to the CLI that forces package rebuilds by skipping cachego build -abehavior for consistency with Go toolchainLLGO_BUILD_CACHE=0Changes
ForceRebuildflag variable incmd/internal/flags/flags.go-aflag with description "Force rebuilding of packages that are already up-to-date"ForceRebuildfield toConfigstruct ininternal/build/build.gotryLoadFromCache()ininternal/build/collect.goto skip cache when flag is setTestTryLoadFromCache_ForceRebuildincollect_test.goTesting
-aflag is enabledgo fmtUsage
Fixes #1436