From 7e9d295807dea08033e88dde6a5d8b3d2a2ff4a4 Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Thu, 4 Aug 2016 13:02:36 -0700 Subject: [PATCH] Auto-fill ndkMigratedLibs. Change-Id: Ifb91f62eccb17dedb71c1a9a0f5c1471edbcbd44 --- cc/cc.go | 19 ++++++++++++++++++- cc/ndk_library.go | 12 ++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/cc/cc.go b/cc/cc.go index 62d02c597..54d9a94d5 100644 --- a/cc/cc.go +++ b/cc/cc.go @@ -43,6 +43,7 @@ func init() { android.RegisterBottomUpMutator("link", linkageMutator) android.RegisterBottomUpMutator("ndk_api", ndkApiMutator) android.RegisterBottomUpMutator("test_per_src", testPerSrcMutator) + android.RegisterBottomUpMutator("begin", beginMutator) android.RegisterBottomUpMutator("deps", depsMutator) android.RegisterTopDownMutator("asan_deps", sanitizerDepsMutator(asan)) @@ -527,7 +528,7 @@ func (c *Module) deps(ctx BaseModuleContext) Deps { return deps } -func (c *Module) depsMutator(actx android.BottomUpMutatorContext) { +func (c *Module) beginMutator(actx android.BottomUpMutatorContext) { ctx := &baseModuleContext{ BaseContext: actx, moduleContextImpl: moduleContextImpl{ @@ -537,6 +538,16 @@ func (c *Module) depsMutator(actx android.BottomUpMutatorContext) { ctx.ctx = ctx c.begin(ctx) +} + +func (c *Module) depsMutator(actx android.BottomUpMutatorContext) { + ctx := &baseModuleContext{ + BaseContext: actx, + moduleContextImpl: moduleContextImpl{ + mod: c, + }, + } + ctx.ctx = ctx deps := c.deps(ctx) @@ -623,6 +634,12 @@ func (c *Module) depsMutator(actx android.BottomUpMutatorContext) { {"ndk_api", version}, {"link", "shared"}}, ndkLateStubDepTag, variantLateNdkLibs...) } +func beginMutator(ctx android.BottomUpMutatorContext) { + if c, ok := ctx.Module().(*Module); ok && c.Enabled() { + c.beginMutator(ctx) + } +} + func depsMutator(ctx android.BottomUpMutatorContext) { if c, ok := ctx.Module().(*Module); ok && c.Enabled() { c.depsMutator(ctx) diff --git a/cc/ndk_library.go b/cc/ndk_library.go index d681b772b..1dd02de26 100644 --- a/cc/ndk_library.go +++ b/cc/ndk_library.go @@ -164,6 +164,18 @@ func ndkApiMutator(mctx android.BottomUpMutatorContext) { } } +func (c *stubCompiler) compilerInit(ctx BaseModuleContext) { + c.baseCompiler.compilerInit(ctx) + + name := strings.TrimSuffix(ctx.ModuleName(), ".ndk") + for _, lib := range ndkMigratedLibs { + if lib == name { + return + } + } + ndkMigratedLibs = append(ndkMigratedLibs, name) +} + func (c *stubCompiler) compile(ctx ModuleContext, flags Flags, deps PathDeps) android.Paths { arch := ctx.Arch().ArchType.String()