From 1a8c8565bd1f77eea5caf9368594f132ccaa5faf Mon Sep 17 00:00:00 2001 From: Dan Willemsen Date: Mon, 29 Jun 2020 23:49:34 -0700 Subject: [PATCH] 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 --- android/override_module.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/android/override_module.go b/android/override_module.go index 6b246db41..3994084a8 100644 --- a/android/override_module.go +++ b/android/override_module.go @@ -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 }