Fix nondeterminism in bp2build

This fixes two main sources of nondeterminism:

1. Fix a bug in the ConfigurationAxis comparator (which caused
   ConfigurationAxis sorting to be nondeterministic)
2. Process C++ dependencies using the sorted ConfigurationAxis order. In
   theory, the order in which dependencies are processed shouldn't
   matter (as they should end up in different select stanzas). However,
   in the case of InApex stubs, this is not the case; we now ensure
   that lists are concatenated in a predictable order.

Added bonus: Some cleanup with SortConfigurationAxes which
makes use of go generics (this made it easier to debug this issue).

Will follow-up with regression tests.

Test: Manually verified that build.ninja checksum and BUILD.bazel checksums do not change after running `m nothing` 6 times in AOSP (with comment-only Android.bp changes in between each run)

Change-Id: I81168e45bdbbcd61ea95ff665cf6c4bc180aa4e0
This commit is contained in:
Chris Parsons
2023-01-26 17:30:44 -05:00
committed by Christopher Parsons
parent 82a9e8fe03
commit 7b3289b471
4 changed files with 31 additions and 39 deletions

View File

@@ -343,8 +343,8 @@ type ConfigurationAxis struct {
}
func (ca *ConfigurationAxis) less(other ConfigurationAxis) bool {
if ca.configurationType < other.configurationType {
return true
if ca.configurationType == other.configurationType {
return ca.subType < other.subType
}
return ca.subType < other.subType
return ca.configurationType < other.configurationType
}