blob: 43721eef03858e5ec051437576603753960132bc [file] [log] [blame]
Colin Cross6362e272015-10-29 15:25:03 -07001// Copyright 2015 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 common
16
17import (
18 "android/soong"
19
20 "github.com/google/blueprint"
21)
22
23type AndroidTopDownMutator func(AndroidTopDownMutatorContext)
24
25type AndroidTopDownMutatorContext interface {
26 blueprint.TopDownMutatorContext
27 androidBaseContext
28}
29
30type androidTopDownMutatorContext struct {
31 blueprint.TopDownMutatorContext
32 androidBaseContextImpl
33}
34
35type AndroidBottomUpMutator func(AndroidBottomUpMutatorContext)
36
37type AndroidBottomUpMutatorContext interface {
38 blueprint.BottomUpMutatorContext
39 androidBaseContext
40}
41
42type androidBottomUpMutatorContext struct {
43 blueprint.BottomUpMutatorContext
44 androidBaseContextImpl
45}
46
47func RegisterBottomUpMutator(name string, mutator AndroidBottomUpMutator) {
48 soong.RegisterBottomUpMutator(name, func(ctx blueprint.BottomUpMutatorContext) {
49 if a, ok := ctx.Module().(AndroidModule); ok {
50 actx := &androidBottomUpMutatorContext{
51 BottomUpMutatorContext: ctx,
52 androidBaseContextImpl: a.base().androidBaseContextFactory(ctx),
53 }
54 mutator(actx)
55 }
56 })
57}
58
59func RegisterTopDownMutator(name string, mutator AndroidTopDownMutator) {
60 soong.RegisterTopDownMutator(name, func(ctx blueprint.TopDownMutatorContext) {
61 if a, ok := ctx.Module().(AndroidModule); ok {
62 actx := &androidTopDownMutatorContext{
63 TopDownMutatorContext: ctx,
64 androidBaseContextImpl: a.base().androidBaseContextFactory(ctx),
65 }
66 mutator(actx)
67 }
68 })
69}