Jayant Chowdhary | 3e231fd | 2017-02-08 13:45:53 -0800 | [diff] [blame] | 1 | // Copyright 2017 Google Inc. All rights reserved. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | package cc |
| 16 | |
| 17 | import ( |
| 18 | "android/soong/android" |
| 19 | "github.com/google/blueprint" |
| 20 | |
| 21 | "android/soong/cc/config" |
| 22 | ) |
| 23 | |
| 24 | type SAbiProperties struct { |
Jayant Chowdhary | 715cac3 | 2017-04-20 06:53:59 -0700 | [diff] [blame] | 25 | CreateSAbiDumps bool `blueprint:"mutated"` |
| 26 | ReexportedIncludeFlags []string |
Jayant Chowdhary | 3e231fd | 2017-02-08 13:45:53 -0800 | [diff] [blame] | 27 | } |
| 28 | |
| 29 | type sabi struct { |
| 30 | Properties SAbiProperties |
| 31 | } |
| 32 | |
| 33 | func (sabimod *sabi) props() []interface{} { |
| 34 | return []interface{}{&sabimod.Properties} |
| 35 | } |
| 36 | |
| 37 | func (sabimod *sabi) begin(ctx BaseModuleContext) {} |
| 38 | |
| 39 | func (sabimod *sabi) deps(ctx BaseModuleContext, deps Deps) Deps { |
| 40 | return deps |
| 41 | } |
| 42 | |
| 43 | func (sabimod *sabi) flags(ctx ModuleContext, flags Flags) Flags { |
| 44 | return flags |
| 45 | } |
| 46 | |
| 47 | func sabiDepsMutator(mctx android.TopDownMutatorContext) { |
| 48 | if c, ok := mctx.Module().(*Module); ok && |
Jayant Chowdhary | 715cac3 | 2017-04-20 06:53:59 -0700 | [diff] [blame] | 49 | (Bool(c.Properties.Vendor_available) || (inList(c.Name(), config.LLndkLibraries())) || |
Jayant Chowdhary | 3e231fd | 2017-02-08 13:45:53 -0800 | [diff] [blame] | 50 | (c.sabi != nil && c.sabi.Properties.CreateSAbiDumps)) { |
| 51 | mctx.VisitDirectDeps(func(m blueprint.Module) { |
| 52 | tag := mctx.OtherModuleDependencyTag(m) |
| 53 | switch tag { |
| 54 | case staticDepTag, staticExportDepTag, lateStaticDepTag, wholeStaticDepTag: |
| 55 | |
| 56 | cc, _ := m.(*Module) |
| 57 | if cc == nil { |
| 58 | return |
| 59 | } |
| 60 | cc.sabi.Properties.CreateSAbiDumps = true |
| 61 | } |
| 62 | }) |
| 63 | } |
| 64 | } |