blob: 7ae31c97da8e25fabd38ec91be1d999ffd534cb7 [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 {
25 CreateSAbiDumps bool `blueprint:"mutated"`
26}
27
28type sabi struct {
29 Properties SAbiProperties
30}
31
32func (sabimod *sabi) props() []interface{} {
33 return []interface{}{&sabimod.Properties}
34}
35
36func (sabimod *sabi) begin(ctx BaseModuleContext) {}
37
38func (sabimod *sabi) deps(ctx BaseModuleContext, deps Deps) Deps {
39 return deps
40}
41
42func (sabimod *sabi) flags(ctx ModuleContext, flags Flags) Flags {
43 return flags
44}
45
46func sabiDepsMutator(mctx android.TopDownMutatorContext) {
47 if c, ok := mctx.Module().(*Module); ok &&
48 ((inList(c.Name(), config.VndkLibraries())) || (inList(c.Name(), config.LLndkLibraries())) ||
49 (c.sabi != nil && c.sabi.Properties.CreateSAbiDumps)) {
50 mctx.VisitDirectDeps(func(m blueprint.Module) {
51 tag := mctx.OtherModuleDependencyTag(m)
52 switch tag {
53 case staticDepTag, staticExportDepTag, lateStaticDepTag, wholeStaticDepTag:
54
55 cc, _ := m.(*Module)
56 if cc == nil {
57 return
58 }
59 cc.sabi.Properties.CreateSAbiDumps = true
60 }
61 })
62 }
63}