blob: 01ef737fb44e3d62eb9bdddd83bdbf8e732f587b [file] [log] [blame]
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -08001// 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
15package cc
16
17import (
18 "android/soong/android"
19 "github.com/google/blueprint"
20
21 "android/soong/cc/config"
22)
23
24type SAbiProperties struct {
Jayant Chowdhary715cac32017-04-20 06:53:59 -070025 CreateSAbiDumps bool `blueprint:"mutated"`
26 ReexportedIncludeFlags []string
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -080027}
28
29type sabi struct {
30 Properties SAbiProperties
31}
32
33func (sabimod *sabi) props() []interface{} {
34 return []interface{}{&sabimod.Properties}
35}
36
37func (sabimod *sabi) begin(ctx BaseModuleContext) {}
38
39func (sabimod *sabi) deps(ctx BaseModuleContext, deps Deps) Deps {
40 return deps
41}
42
43func (sabimod *sabi) flags(ctx ModuleContext, flags Flags) Flags {
44 return flags
45}
46
47func sabiDepsMutator(mctx android.TopDownMutatorContext) {
48 if c, ok := mctx.Module().(*Module); ok &&
Jayant Chowdhary715cac32017-04-20 06:53:59 -070049 (Bool(c.Properties.Vendor_available) || (inList(c.Name(), config.LLndkLibraries())) ||
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -080050 (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}