Replace SortedStringKeys with SortedKeys

Now that we have generics.

Bug: 193460475
Test: presubmits
Change-Id: I1594fd8feb505175d5c09c03ef397e5ffd5b09cb
This commit is contained in:
Cole Faust 2023-02-28 16:02:16 -08:00
parent 20eed826fd
commit 18994c73f1
34 changed files with 104 additions and 85 deletions

View file

@ -817,7 +817,7 @@ func (d *ApexBundleDepsInfo) BuildDepsInfoLists(ctx ModuleContext, minSdkVersion
var flatContent strings.Builder
fmt.Fprintf(&fullContent, "%s(minSdkVersion:%s):\n", ctx.ModuleName(), minSdkVersion)
for _, key := range FirstUniqueStrings(SortedStringKeys(depInfos)) {
for _, key := range FirstUniqueStrings(SortedKeys(depInfos)) {
info := depInfos[key]
toName := fmt.Sprintf("%s(minSdkVersion:%s)", info.To, info.MinSdkVersion)
if info.IsExternal {

View file

@ -302,7 +302,7 @@ func InitDefaultsModule(module DefaultsModule) {
delete(propertiesSet, "visibility")
// Replace the "*" with the names of all the properties that have been set.
protectedProperties = SortedStringKeys(propertiesSet)
protectedProperties = SortedKeys(propertiesSet)
module.setProtectedProperties(protectedProperties)
} else {
for _, property := range protectedProperties {

View file

@ -3675,7 +3675,7 @@ func AddAncestors(ctx SingletonContext, dirMap map[string]Paths, mmName func(str
// Ensure ancestor directories are in dirMap
// Make directories build their direct subdirectories
// Returns a slice of all directories and a slice of top-level directories.
dirs := SortedStringKeys(dirMap)
dirs := SortedKeys(dirMap)
for _, dir := range dirs {
dir := parentDir(dir)
for dir != "." && dir != "/" {
@ -3686,7 +3686,7 @@ func AddAncestors(ctx SingletonContext, dirMap map[string]Paths, mmName func(str
dir = parentDir(dir)
}
}
dirs = SortedStringKeys(dirMap)
dirs = SortedKeys(dirMap)
var topDirs []string
for _, dir := range dirs {
p := parentDir(dir)
@ -3696,7 +3696,7 @@ func AddAncestors(ctx SingletonContext, dirMap map[string]Paths, mmName func(str
topDirs = append(topDirs, dir)
}
}
return SortedStringKeys(dirMap), topDirs
return SortedKeys(dirMap), topDirs
}
func (c *buildTargetSingleton) GenerateBuildActions(ctx SingletonContext) {
@ -3782,7 +3782,7 @@ func (c *buildTargetSingleton) GenerateBuildActions(ctx SingletonContext) {
}
// Wrap those into host|host-cross|target phony rules
for _, class := range SortedStringKeys(osClass) {
for _, class := range SortedKeys(osClass) {
ctx.Phony(class, osClass[class]...)
}
}

View file

@ -542,7 +542,7 @@ func (r *rule) String() string {
s = append(s, fmt.Sprintf("properties matching: %s", r.props))
}
if len(r.directDeps) > 0 {
s = append(s, fmt.Sprintf("dep(s): %q", SortedStringKeys(r.directDeps)))
s = append(s, fmt.Sprintf("dep(s): %q", SortedKeys(r.directDeps)))
}
if len(r.osClasses) > 0 {
s = append(s, fmt.Sprintf("os class(es): %q", r.osClasses))

View file

@ -240,7 +240,7 @@ func (p *PackagingBase) GatherPackagingSpecs(ctx ModuleContext) map[string]Packa
// entries into the specified directory.
func (p *PackagingBase) CopySpecsToDir(ctx ModuleContext, builder *RuleBuilder, specs map[string]PackagingSpec, dir ModuleOutPath) (entries []string) {
seenDir := make(map[string]bool)
for _, k := range SortedStringKeys(specs) {
for _, k := range SortedKeys(specs) {
ps := specs[k]
destPath := dir.Join(ctx, ps.relPathInPackage).String()
destDir := filepath.Dir(destPath)

View file

@ -48,7 +48,7 @@ var _ SingletonMakeVarsProvider = (*phonySingleton)(nil)
func (p *phonySingleton) GenerateBuildActions(ctx SingletonContext) {
p.phonyMap = getPhonyMap(ctx.Config())
p.phonyList = SortedStringKeys(p.phonyMap)
p.phonyList = SortedKeys(p.phonyMap)
for _, phony := range p.phonyList {
p.phonyMap[phony] = SortedUniquePaths(p.phonyMap[phony])
}

View file

@ -301,23 +301,6 @@ func (defs *Bp2BuildSoongConfigDefinitions) AddVars(mtDef SoongConfigDefinition)
}
}
// This is a copy of the one available in soong/android/util.go, but depending
// on the android package causes a cyclic dependency. A refactoring here is to
// extract common utils out from android/utils.go for other packages like this.
func sortedStringKeys(m interface{}) []string {
v := reflect.ValueOf(m)
if v.Kind() != reflect.Map {
panic(fmt.Sprintf("%#v is not a map", m))
}
keys := v.MapKeys()
s := make([]string, 0, len(keys))
for _, key := range keys {
s = append(s, key.String())
}
sort.Strings(s)
return s
}
// String emits the Soong config variable definitions as Starlark dictionaries.
func (defs Bp2BuildSoongConfigDefinitions) String() string {
ret := ""

View file

@ -57,7 +57,7 @@ func (t *testSuiteFiles) MakeVars(ctx MakeVarsContext) {
func robolectricTestSuite(ctx SingletonContext, files map[string]InstallPaths) WritablePath {
var installedPaths InstallPaths
for _, module := range SortedStringKeys(files) {
for _, module := range SortedKeys(files) {
installedPaths = append(installedPaths, files[module]...)
}
testCasesDir := pathForInstall(ctx, ctx.Config().BuildOS, X86, "testcases", false)

View file

@ -62,25 +62,9 @@ func JoinWithPrefixAndSeparator(strs []string, prefix string, sep string) string
return buf.String()
}
// JoinWithSuffix appends the suffix to each string in the list and
// returns them joined together with given separator.
func JoinWithSuffix(strs []string, suffix string, separator string) string {
if len(strs) == 0 {
return ""
}
var buf strings.Builder
buf.WriteString(strs[0])
buf.WriteString(suffix)
for i := 1; i < len(strs); i++ {
buf.WriteString(separator)
buf.WriteString(strs[i])
buf.WriteString(suffix)
}
return buf.String()
}
// SorterStringKeys returns the keys of the given string-keyed map in the ascending order.
// SortedStringKeys returns the keys of the given map in the ascending order.
//
// Deprecated: Use SortedKeys instead.
func SortedStringKeys(m interface{}) []string {
v := reflect.ValueOf(m)
if v.Kind() != reflect.Map {
@ -98,6 +82,28 @@ func SortedStringKeys(m interface{}) []string {
return s
}
type Ordered interface {
~string |
~float32 | ~float64 |
~int | ~int8 | ~int16 | ~int32 | ~int64 |
~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
}
// SortedKeys returns the keys of the given map in the ascending order.
func SortedKeys[T Ordered, V any](m map[T]V) []T {
if len(m) == 0 {
return nil
}
ret := make([]T, 0, len(m))
for k := range m {
ret = append(ret, k)
}
sort.Slice(ret, func(i, j int) bool {
return ret[i] < ret[j]
})
return ret
}
// stringValues returns the values of the given string-valued map in randomized map order.
func stringValues(m interface{}) []string {
v := reflect.ValueOf(m)

View file

@ -641,6 +641,36 @@ func BenchmarkFirstUniqueStrings(b *testing.B) {
}
}
func testSortedKeysHelper[K Ordered, V any](t *testing.T, name string, input map[K]V, expected []K) {
t.Helper()
t.Run(name, func(t *testing.T) {
actual := SortedKeys(input)
if !reflect.DeepEqual(actual, expected) {
t.Errorf("expected %q, got %q", expected, actual)
}
})
}
func TestSortedKeys(t *testing.T) {
testSortedKeysHelper(t, "simple", map[string]string{
"b": "bar",
"a": "foo",
}, []string{
"a",
"b",
})
testSortedKeysHelper(t, "ints", map[int]interface{}{
10: nil,
5: nil,
}, []int{
5,
10,
})
testSortedKeysHelper(t, "nil", map[string]string(nil), nil)
testSortedKeysHelper(t, "empty", map[string]string{}, nil)
}
func TestSortedStringKeys(t *testing.T) {
testCases := []struct {
name string

View file

@ -543,7 +543,7 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) {
if len(installMapSet) > 0 {
var installs []string
installs = append(installs, android.SortedStringKeys(installMapSet)...)
installs = append(installs, android.SortedKeys(installMapSet)...)
a.SetLicenseInstallMap(installs)
}

View file

@ -227,7 +227,7 @@ func NewCodegenContext(config android.Config, context *android.Context, mode Cod
// the generated attributes are sorted to ensure determinism.
func propsToAttributes(props map[string]string) string {
var attributes string
for _, propName := range android.SortedStringKeys(props) {
for _, propName := range android.SortedKeys(props) {
attributes += fmt.Sprintf(" %s = %s,\n", propName, props[propName])
}
return attributes

View file

@ -83,7 +83,7 @@ func CreateRuleShims(moduleTypeFactories map[string]android.ModuleFactory) map[s
func generateSoongModuleBzl(bzlLoads map[string]RuleShim) string {
var loadStmts string
var moduleRuleMap string
for _, bzlFileName := range android.SortedStringKeys(bzlLoads) {
for _, bzlFileName := range android.SortedKeys(bzlLoads) {
loadStmt := "load(\"//build/bazel/queryview_rules:"
loadStmt += bzlFileName
loadStmt += ".bzl\""
@ -104,7 +104,7 @@ func generateRules(moduleTypeFactories map[string]android.ModuleFactory) map[str
rules := make(map[string][]rule)
// TODO: allow registration of a bzl rule when registring a factory
for _, moduleType := range android.SortedStringKeys(moduleTypeFactories) {
for _, moduleType := range android.SortedKeys(moduleTypeFactories) {
factory := moduleTypeFactories[moduleType]
factoryName := runtime.FuncForPC(reflect.ValueOf(factory).Pointer()).Name()
pkg := strings.Split(factoryName, ".")[0]
@ -221,7 +221,7 @@ func getPropertyDescriptions(props []interface{}) []property {
}
properties := make([]property, 0, len(propertiesByName))
for _, key := range android.SortedStringKeys(propertiesByName) {
for _, key := range android.SortedKeys(propertiesByName) {
properties = append(properties, propertiesByName[key])
}

View file

@ -256,7 +256,7 @@ func prettyPrintSelectMap(selectMap map[string]reflect.Value, defaultValue *stri
}
var selects string
for _, selectKey := range android.SortedStringKeys(selectMap) {
for _, selectKey := range android.SortedKeys(selectMap) {
if selectKey == bazel.ConditionsDefaultSelectKey {
// Handle default condition later.
continue

View file

@ -105,7 +105,7 @@ func CreateBazelFiles(
func createBuildFiles(buildToTargets map[string]BazelTargets, mode CodegenMode) []BazelFile {
files := make([]BazelFile, 0, len(buildToTargets))
for _, dir := range android.SortedStringKeys(buildToTargets) {
for _, dir := range android.SortedKeys(buildToTargets) {
targets := buildToTargets[dir]
targets.sort()

View file

@ -51,7 +51,7 @@ func (metrics *CodegenMetrics) Serialize() *bp2build_metrics_proto.Bp2BuildMetri
// Print the codegen metrics to stdout.
func (metrics *CodegenMetrics) Print() {
generatedTargetCount := uint64(0)
for _, ruleClass := range android.SortedStringKeys(metrics.serialized.RuleClassCount) {
for _, ruleClass := range android.SortedKeys(metrics.serialized.RuleClassCount) {
count := metrics.serialized.RuleClassCount[ruleClass]
fmt.Printf("[bp2build] %s: %d targets\n", ruleClass, count)
generatedTargetCount += count

View file

@ -230,11 +230,11 @@ func (b BazelTestResult) CompareAllBazelTargets(t *testing.T, description string
actualTargets := b.buildFileToTargets
// Generate the sorted set of directories to check.
dirsToCheck := android.SortedStringKeys(expectedTargets)
dirsToCheck := android.SortedKeys(expectedTargets)
if !ignoreUnexpected {
// This needs to perform an exact match so add the directories in which targets were
// produced to the list of directories to check.
dirsToCheck = append(dirsToCheck, android.SortedStringKeys(actualTargets)...)
dirsToCheck = append(dirsToCheck, android.SortedKeys(actualTargets)...)
dirsToCheck = android.SortedUniqueStrings(dirsToCheck)
}
@ -579,7 +579,7 @@ func makeBazelTargetHostOrDevice(typ, name string, attrs AttrNameToString, hod a
if name != "" {
attrStrings = append(attrStrings, fmt.Sprintf(` name = "%s",`, name))
}
for _, k := range android.SortedStringKeys(attrs) {
for _, k := range android.SortedKeys(attrs) {
attrStrings = append(attrStrings, fmt.Sprintf(" %s = %s,", k, attrs[k]))
}
return fmt.Sprintf(`%s(

View file

@ -1263,7 +1263,7 @@ func (la *linkerAttributes) finalize(ctx android.BazelConversionPathContext) {
// result in duplicate library errors for bionic OSes. Here, we explicitly exclude those libraries
// from bionic OSes and the no config case as these libraries only build for bionic OSes.
if la.systemDynamicDeps.IsNil() && len(la.usedSystemDynamicDepAsDynamicDep) > 0 {
toRemove := bazelLabelForSharedDeps(ctx, android.SortedStringKeys(la.usedSystemDynamicDepAsDynamicDep))
toRemove := bazelLabelForSharedDeps(ctx, android.SortedKeys(la.usedSystemDynamicDepAsDynamicDep))
la.dynamicDeps.Exclude(bazel.NoConfigAxis, "", toRemove)
la.dynamicDeps.Exclude(bazel.OsConfigurationAxis, "android", toRemove)
la.dynamicDeps.Exclude(bazel.OsConfigurationAxis, "linux_bionic", toRemove)

View file

@ -3930,7 +3930,7 @@ func assertArrayString(t *testing.T, got, expected []string) {
func assertMapKeys(t *testing.T, m map[string]string, expected []string) {
t.Helper()
assertArrayString(t, android.SortedStringKeys(m), expected)
assertArrayString(t, android.SortedKeys(m), expected)
}
func TestDefaults(t *testing.T) {

View file

@ -405,7 +405,7 @@ func addPossiblyArchSpecificProperties(sdkModuleContext android.ModuleContext, b
}
// Add the collated include dir properties to the output.
for _, property := range android.SortedStringKeys(includeDirs) {
for _, property := range android.SortedKeys(includeDirs) {
outputProperties.AddProperty(property, includeDirs[property])
}

View file

@ -1716,9 +1716,9 @@ func (s *sanitizerStaticLibsMap) add(c LinkableInterface, name string) {
// These are to be used by use_soong_sanitized_static_libraries.
// See build/make/core/binary.mk for more details.
func (s *sanitizerStaticLibsMap) exportToMake(ctx android.MakeVarsContext) {
for _, image := range android.SortedStringKeys(s.libsMap) {
for _, image := range android.SortedKeys(s.libsMap) {
archMap := s.libsMap[ImageVariantType(image)]
for _, arch := range android.SortedStringKeys(archMap) {
for _, arch := range android.SortedKeys(archMap) {
libs := archMap[arch]
sort.Strings(libs)

View file

@ -73,7 +73,7 @@ func stubLibrariesSingleton() android.Singleton {
func (s *stubLibraries) MakeVars(ctx android.MakeVarsContext) {
// Convert stub library file names into Makefile variable.
ctx.Strict("STUB_LIBRARIES", strings.Join(android.SortedStringKeys(s.stubLibraryMap), " "))
ctx.Strict("STUB_LIBRARIES", strings.Join(android.SortedKeys(s.stubLibraryMap), " "))
// Export the list of API XML files to Make.
sort.Strings(s.apiListCoverageXmlPaths)

View file

@ -118,7 +118,7 @@ func combineNoticesRule(ctx android.SingletonContext, paths android.Paths, out s
// ...
func installMapListFileRule(ctx android.SingletonContext, m map[string]string, path string) android.OutputPath {
var txtBuilder strings.Builder
for idx, k := range android.SortedStringKeys(m) {
for idx, k := range android.SortedKeys(m) {
if idx > 0 {
txtBuilder.WriteString("\n")
}

View file

@ -876,7 +876,7 @@ func (c *vndkSnapshotSingleton) MakeVars(ctx android.MakeVarsContext) {
})
ctx.Strict("LLNDK_MOVED_TO_APEX_LIBRARIES",
strings.Join(android.SortedStringKeys(movedToApexLlndkLibraries), " "))
strings.Join(android.SortedKeys(movedToApexLlndkLibraries), " "))
ctx.Strict("VNDK_LIBRARIES_FILE", c.vndkLibrariesFile.String())
ctx.Strict("SOONG_VNDK_SNAPSHOT_ZIP", c.vndkSnapshotZipFile.String())

View file

@ -1003,7 +1003,7 @@ func (j *Module) collectJavacFlags(
topLevelDirs[srcFileParts[0]] = true
}
}
patchPaths = append(patchPaths, android.SortedStringKeys(topLevelDirs)...)
patchPaths = append(patchPaths, android.SortedKeys(topLevelDirs)...)
classPath := flags.classpath.FormJavaClassPath("")
if classPath != "" {

View file

@ -440,7 +440,7 @@ func (i BootclasspathFragmentApexContentInfo) DexBootJarPathForContentModule(mod
return dexJar, nil
} else {
return nil, fmt.Errorf("unknown bootclasspath_fragment content module %s, expected one of %s",
name, strings.Join(android.SortedStringKeys(i.contentModuleDexJarPaths), ", "))
name, strings.Join(android.SortedKeys(i.contentModuleDexJarPaths), ", "))
}
}
@ -709,7 +709,7 @@ func (b *BootclasspathFragmentModule) getImageConfig(ctx android.EarlyModuleCont
imageName := *imageNamePtr
imageConfig := imageConfigs[imageName]
if imageConfig == nil {
ctx.PropertyErrorf("image_name", "Unknown image name %q, expected one of %s", imageName, strings.Join(android.SortedStringKeys(imageConfigs), ", "))
ctx.PropertyErrorf("image_name", "Unknown image name %q, expected one of %s", imageName, strings.Join(android.SortedKeys(imageConfigs), ", "))
return nil
}
return imageConfig

View file

@ -111,7 +111,7 @@ func gatherPossibleApexModuleNamesAndStems(ctx android.ModuleContext, contents [
ctx.PropertyErrorf("contents", "%v is not a ModuleWithStem", name)
}
}
return android.SortedStringKeys(set)
return android.SortedKeys(set)
}
// Converts android.ConfiguredJarList into a list of classpathJars for each given classpathType.

View file

@ -538,8 +538,8 @@ func shouldBuildBootImages(config android.Config, global *dexpreopt.GlobalConfig
func copyBootJarsToPredefinedLocations(ctx android.ModuleContext, srcBootDexJarsByModule bootDexJarByModule, dstBootJarsByModule map[string]android.WritablePath) {
// Create the super set of module names.
names := []string{}
names = append(names, android.SortedStringKeys(srcBootDexJarsByModule)...)
names = append(names, android.SortedStringKeys(dstBootJarsByModule)...)
names = append(names, android.SortedKeys(srcBootDexJarsByModule)...)
names = append(names, android.SortedKeys(dstBootJarsByModule)...)
names = android.SortedUniqueStrings(names)
for _, name := range names {
src := srcBootDexJarsByModule[name]

View file

@ -697,7 +697,7 @@ func (s StubDexJarsByModule) addStubDexJarsByModule(other StubDexJarsByModule) {
// The relative width of APIs is determined by their order in hiddenAPIScopes.
func (s StubDexJarsByModule) StubDexJarsForWidestAPIScope() android.Paths {
stubDexJars := android.Paths{}
modules := android.SortedStringKeys(s)
modules := android.SortedKeys(s)
for _, module := range modules {
stubDexJarsByScope := s[module]
@ -714,7 +714,7 @@ func (s StubDexJarsByModule) StubDexJarsForWidestAPIScope() android.Paths {
// the returned list.
func (s StubDexJarsByModule) StubDexJarsForScope(scope *HiddenAPIScope) android.Paths {
stubDexJars := android.Paths{}
modules := android.SortedStringKeys(s)
modules := android.SortedKeys(s)
for _, module := range modules {
stubDexJarsByScope := s[module]
// Not every module will have the same set of
@ -917,7 +917,7 @@ func (b bootDexJarByModule) addPath(module android.Module, path android.Path) {
// bootDexJars returns the boot dex jar paths sorted by their keys.
func (b bootDexJarByModule) bootDexJars() android.Paths {
paths := android.Paths{}
for _, k := range android.SortedStringKeys(b) {
for _, k := range android.SortedKeys(b) {
paths = append(paths, b[k])
}
return paths
@ -927,7 +927,7 @@ func (b bootDexJarByModule) bootDexJars() android.Paths {
// libraries if present.
func (b bootDexJarByModule) bootDexJarsWithoutCoverage() android.Paths {
paths := android.Paths{}
for _, k := range android.SortedStringKeys(b) {
for _, k := range android.SortedKeys(b) {
if k == "jacocoagent" {
continue
}
@ -1217,7 +1217,7 @@ func hiddenAPIEncodeRulesForBootclasspathFragment(ctx android.ModuleContext, boo
// Encode the flags into the boot dex files.
encodedBootDexJarsByModule := bootDexJarByModule{}
outputDir := android.PathForModuleOut(ctx, "hiddenapi-modular/encoded").OutputPath
for _, name := range android.SortedStringKeys(bootDexInfoByModule) {
for _, name := range android.SortedKeys(bootDexInfoByModule) {
bootDexInfo := bootDexInfoByModule[name]
unencodedDex := bootDexInfo.path
encodedDex := hiddenAPIEncodeDex(ctx, unencodedDex, allFlagsCSV, bootDexInfo.uncompressDex, bootDexInfo.minSdkVersion, outputDir)
@ -1288,7 +1288,7 @@ type bootDexInfoByModule map[string]bootDexInfo
// bootDexJars returns the boot dex jar paths sorted by their keys.
func (b bootDexInfoByModule) bootDexJars() android.Paths {
paths := android.Paths{}
for _, m := range android.SortedStringKeys(b) {
for _, m := range android.SortedKeys(b) {
paths = append(paths, b[m].path)
}
return paths

View file

@ -264,7 +264,7 @@ func prebuiltApiFiles(mctx android.LoadHookContext, p *prebuiltApis) {
}
// Sort the keys in order to make build.ninja stable
for _, k := range android.SortedStringKeys(latest) {
for _, k := range android.SortedKeys(latest) {
info := latest[k]
name := PrebuiltApiModuleName(info.module, info.scope, "latest")
createApiModule(mctx, name, info.path)
@ -284,7 +284,7 @@ func prebuiltApiFiles(mctx android.LoadHookContext, p *prebuiltApis) {
}
}
// Create empty incompatibilities files for remaining modules
for _, k := range android.SortedStringKeys(latest) {
for _, k := range android.SortedKeys(latest) {
if _, ok := incompatibilities[k]; !ok {
createEmptyFile(mctx, PrebuiltApiModuleName(latest[k].module+"-incompatibilities", latest[k].scope, "latest"))
}

View file

@ -1379,7 +1379,7 @@ func (module *SdkLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext)
})
// Make the set of components exported by this module available for use elsewhere.
exportedComponentInfo := android.ExportedComponentsInfo{Components: android.SortedStringKeys(exportedComponents)}
exportedComponentInfo := android.ExportedComponentsInfo{Components: android.SortedKeys(exportedComponents)}
ctx.SetProvider(android.ExportedComponentsInfoProvider, exportedComponentInfo)
// Provide additional information for inclusion in an sdk's generated .info file.

View file

@ -198,7 +198,7 @@ func FixtureWithPrebuiltApisAndExtensions(apiLevel2Modules map[string][]string,
imports_sdk_version: "none",
imports_compile_dex: true,
}
`, strings.Join(android.SortedStringKeys(apiLevel2Modules), `", "`))
`, strings.Join(android.SortedKeys(apiLevel2Modules), `", "`))
for release, modules := range apiLevel2Modules {
mockFS.Merge(prebuiltApisFilesForModules([]string{release}, modules))

View file

@ -532,7 +532,7 @@ func (p *PythonLibraryModule) createSrcsZip(ctx android.ModuleContext, pkgPath s
if len(relativeRootMap) > 0 {
// in order to keep stable order of soong_zip params, we sort the keys here.
roots := android.SortedStringKeys(relativeRootMap)
roots := android.SortedKeys(relativeRootMap)
// Use -symlinks=false so that the symlinks in the bazel output directory are followed
parArgs := []string{"-symlinks=false"}

View file

@ -565,7 +565,7 @@ func (m *moduleInfo) MarshalJSON() ([]byte, error) {
if m.deps != nil {
writeObjectPair("@deps", m.deps)
}
for _, k := range android.SortedStringKeys(m.memberSpecific) {
for _, k := range android.SortedKeys(m.memberSpecific) {
v := m.memberSpecific[k]
writeObjectPair(k, v)
}
@ -626,7 +626,7 @@ func (s *sdk) generateInfoData(ctx android.ModuleContext, memberVariantDeps []sd
getModuleInfo(memberVariantDep.variant)
}
for _, memberName := range android.SortedStringKeys(name2Info) {
for _, memberName := range android.SortedKeys(name2Info) {
info := name2Info[memberName]
modules = append(modules, info)
}
@ -1708,7 +1708,7 @@ func newArchSpecificInfo(ctx android.SdkMemberContext, archId archId, osType and
}
// Create the image variant info in a fixed order.
for _, imageVariantName := range android.SortedStringKeys(variantsByImage) {
for _, imageVariantName := range android.SortedKeys(variantsByImage) {
variants := variantsByImage[imageVariantName]
archInfo.imageVariantInfos = append(archInfo.imageVariantInfos, newImageVariantSpecificInfo(ctx, imageVariantName, variantPropertiesFactory, variants))
}