diff options
author | Colin Cross <ccross@android.com> | 2015-12-17 18:00:23 -0800 |
---|---|---|
committer | Colin Cross <ccross@android.com> | 2015-12-18 13:13:15 -0800 |
commit | d779da4bb3a80133a085c1f229efb66516903d7c (patch) | |
tree | 3c5d0c5ce7e6afc224fce5b3e7101602c5e2d408 | |
parent | 6ff513835507ac628bae455fc6765bff059c574c (diff) | |
download | build_soong-d779da4bb3a80133a085c1f229efb66516903d7c.tar.gz build_soong-d779da4bb3a80133a085c1f229efb66516903d7c.tar.bz2 build_soong-d779da4bb3a80133a085c1f229efb66516903d7c.zip |
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
-rw-r--r-- | common/androidmk.go | 2 | ||||
-rw-r--r-- | common/module.go | 21 |
2 files changed, 23 insertions, 0 deletions
diff --git a/common/androidmk.go b/common/androidmk.go index 7006bb9d..9bd3a191 100644 --- a/common/androidmk.go +++ b/common/androidmk.go @@ -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 diff --git a/common/module.go b/common/module.go index a3de5f6b..a2b2efa3 100644 --- a/common/module.go +++ b/common/module.go @@ -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] } |