Fix out/soong/Android-<>.mk reproducibility

When there were multiple modules overriding a single module, sometimes
we would create the list in different orders, which would trigger some
of the later mutators to write the Android-<>.mk out in different
orders.

Bug: 160207422
Test: diff out/soong/Android-<>.mk between multiple runs on internal master
Change-Id: I321db706dd34aa20a0b1556fd282d54b826a4a97
This commit is contained in:
Dan Willemsen
2020-06-29 23:49:34 -07:00
parent a66f571e01
commit 1a8c8565bd

View File

@@ -28,6 +28,7 @@ package android
// module based on it.
import (
"sort"
"sync"
"github.com/google/blueprint"
@@ -161,6 +162,11 @@ func (b *OverridableModuleBase) addOverride(o OverrideModule) {
// Should NOT be used in the same mutator as addOverride.
func (b *OverridableModuleBase) getOverrides() []OverrideModule {
b.overridesLock.Lock()
sort.Slice(b.overrides, func(i, j int) bool {
return b.overrides[i].Name() < b.overrides[j].Name()
})
b.overridesLock.Unlock()
return b.overrides
}