blob: 9405f2d2f37091ed90042a0afbd7d759af82a959 [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
Colin Cross635c3b02016-05-18 15:37:25 -070015package android
Colin Cross6362e272015-10-29 15:25:03 -070016
17import (
18 "android/soong"
19
20 "github.com/google/blueprint"
21)
22
Colin Cross635c3b02016-05-18 15:37:25 -070023type AndroidTopDownMutator func(TopDownMutatorContext)
Colin Cross6362e272015-10-29 15:25:03 -070024
Colin Cross635c3b02016-05-18 15:37:25 -070025type TopDownMutatorContext interface {
Colin Cross6362e272015-10-29 15:25:03 -070026 blueprint.TopDownMutatorContext
27 androidBaseContext
28}
29
30type androidTopDownMutatorContext struct {
31 blueprint.TopDownMutatorContext
32 androidBaseContextImpl
33}
34
Colin Cross635c3b02016-05-18 15:37:25 -070035type AndroidBottomUpMutator func(BottomUpMutatorContext)
Colin Cross6362e272015-10-29 15:25:03 -070036
Colin Cross635c3b02016-05-18 15:37:25 -070037type BottomUpMutatorContext interface {
Colin Cross6362e272015-10-29 15:25:03 -070038 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) {
Colin Cross635c3b02016-05-18 15:37:25 -070049 if a, ok := ctx.Module().(Module); ok {
Colin Cross6362e272015-10-29 15:25:03 -070050 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) {
Colin Cross635c3b02016-05-18 15:37:25 -070061 if a, ok := ctx.Module().(Module); ok {
Colin Cross6362e272015-10-29 15:25:03 -070062 actx := &androidTopDownMutatorContext{
63 TopDownMutatorContext: ctx,
64 androidBaseContextImpl: a.base().androidBaseContextFactory(ctx),
65 }
66 mutator(actx)
67 }
68 })
69}