Fix androidmk module ordering
Java binary modules expect the order of modules in Soong's Android.mk to match the variant order. Instead of sorting by name and then subdir, which will alphabetize the variants, only sort by name and use sort.Stable to keep the ordering of modules with the same name. Test: m Change-Id: Icf3d22bdc9f9c73945d01c2c47468cc1c361035d
This commit is contained in:
@@ -72,7 +72,9 @@ func (c *androidMkSingleton) GenerateBuildActions(ctx SingletonContext) {
|
||||
androidMkModulesList = append(androidMkModulesList, module)
|
||||
})
|
||||
|
||||
sort.Sort(ModulesByName{androidMkModulesList, ctx})
|
||||
sort.SliceStable(androidMkModulesList, func(i, j int) bool {
|
||||
return ctx.ModuleName(androidMkModulesList[i]) < ctx.ModuleName(androidMkModulesList[j])
|
||||
})
|
||||
|
||||
transMk := PathForOutput(ctx, "Android"+String(ctx.Config().productVariables.Make_suffix)+".mk")
|
||||
if ctx.Failed() {
|
||||
|
@@ -1619,27 +1619,6 @@ func (c *buildTargetSingleton) GenerateBuildActions(ctx SingletonContext) {
|
||||
}
|
||||
}
|
||||
|
||||
type ModulesByName struct {
|
||||
slice []blueprint.Module
|
||||
ctx interface {
|
||||
ModuleName(blueprint.Module) string
|
||||
ModuleSubDir(blueprint.Module) string
|
||||
}
|
||||
}
|
||||
|
||||
func (s ModulesByName) Len() int { return len(s.slice) }
|
||||
func (s ModulesByName) Less(i, j int) bool {
|
||||
mi, mj := s.slice[i], s.slice[j]
|
||||
ni, nj := s.ctx.ModuleName(mi), s.ctx.ModuleName(mj)
|
||||
|
||||
if ni != nj {
|
||||
return ni < nj
|
||||
} else {
|
||||
return s.ctx.ModuleSubDir(mi) < s.ctx.ModuleSubDir(mj)
|
||||
}
|
||||
}
|
||||
func (s ModulesByName) Swap(i, j int) { s.slice[i], s.slice[j] = s.slice[j], s.slice[i] }
|
||||
|
||||
// Collect information for opening IDE project files in java/jdeps.go.
|
||||
type IDEInfo interface {
|
||||
IDEInfo(ideInfo *IdeInfo)
|
||||
|
Reference in New Issue
Block a user