blob: af7c3c2a0e9899cde55f6055a72a09b9c7a567e9 [file] [log] [blame]
Colin Crossb2559a02018-04-19 15:26:10 -07001// Copyright 2018 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 java
16
17import (
18 "sort"
19 "strings"
20
21 "android/soong/android"
22)
23
24func init() {
25 android.RegisterMakeVarsProvider(pctx, supportLibrariesMakeVarsProvider)
26}
27
28func supportLibrariesMakeVarsProvider(ctx android.MakeVarsContext) {
29 var supportAars, supportJars []string
30
Colin Cross65494b92019-02-07 14:25:51 -080031 ctx.VisitAllModules(func(module android.Module) {
32 dir := ctx.ModuleDir(module)
Colin Crossb2559a02018-04-19 15:26:10 -070033 switch {
34 case strings.HasPrefix(dir, "prebuilts/sdk/current/extras"),
35 dir == "prebuilts/sdk/current/androidx",
36 dir == "prebuilts/sdk/current/car",
37 dir == "prebuilts/sdk/current/optional",
38 dir == "prebuilts/sdk/current/support":
39 // Support library
40 default:
41 // Not a support library
42 return
43 }
44
Colin Cross65494b92019-02-07 14:25:51 -080045 name := ctx.ModuleName(module)
Colin Crossb2559a02018-04-19 15:26:10 -070046 if strings.HasSuffix(name, "-nodeps") {
47 return
48 }
49
50 switch module.(type) {
51 case *AndroidLibrary, *AARImport:
52 supportAars = append(supportAars, name)
53 case *Library, *Import:
54 supportJars = append(supportJars, name)
Colin Crossb2559a02018-04-19 15:26:10 -070055 }
56 })
57
58 sort.Strings(supportAars)
59 sort.Strings(supportJars)
60
61 ctx.Strict("SUPPORT_LIBRARIES_AARS", strings.Join(supportAars, " "))
62 ctx.Strict("SUPPORT_LIBRARIES_JARS", strings.Join(supportJars, " "))
63}