Sort modules before writing to Android.mk
Sort the modules before writing them to the Android.mk file to prevent it changing every time soong rebuilts itself. Avoids unnecessary makefile reparses by kati when it sees Android.mk change. Change-Id: Ie2cebb25a82d131ee5b556f8e4b3b317d080692c
This commit is contained in:
parent
6ff5138355
commit
d779da4bb3
|
@ -99,6 +99,8 @@ func (c *androidMkSingleton) GenerateBuildActions(ctx blueprint.SingletonContext
|
|||
}
|
||||
}
|
||||
|
||||
sort.Sort(AndroidModulesByName{androidMkModulesList, ctx})
|
||||
|
||||
transMk := PathForOutput(ctx, "Android.mk")
|
||||
if ctx.Failed() {
|
||||
return
|
||||
|
|
|
@ -632,3 +632,24 @@ func (c *buildTargetSingleton) GenerateBuildActions(ctx blueprint.SingletonConte
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
type AndroidModulesByName struct {
|
||||
slice []AndroidModule
|
||||
ctx interface {
|
||||
ModuleName(blueprint.Module) string
|
||||
ModuleSubDir(blueprint.Module) string
|
||||
}
|
||||
}
|
||||
|
||||
func (s AndroidModulesByName) Len() int { return len(s.slice) }
|
||||
func (s AndroidModulesByName) 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 AndroidModulesByName) Swap(i, j int) { s.slice[i], s.slice[j] = s.slice[j], s.slice[i] }
|
||||
|
|
Loading…
Reference in New Issue