blob: 320afae19d82868920ea46c3b9c2241f827f2f02 [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
31 sctx := ctx.SingletonContext()
32 sctx.VisitAllModules(func(module android.Module) {
33 dir := sctx.ModuleDir(module)
34 switch {
35 case strings.HasPrefix(dir, "prebuilts/sdk/current/extras"),
36 dir == "prebuilts/sdk/current/androidx",
37 dir == "prebuilts/sdk/current/car",
38 dir == "prebuilts/sdk/current/optional",
39 dir == "prebuilts/sdk/current/support":
40 // Support library
41 default:
42 // Not a support library
43 return
44 }
45
46 name := sctx.ModuleName(module)
47 if strings.HasSuffix(name, "-nodeps") {
48 return
49 }
50
51 switch module.(type) {
52 case *AndroidLibrary, *AARImport:
53 supportAars = append(supportAars, name)
54 case *Library, *Import:
55 supportJars = append(supportJars, name)
56 default:
57 sctx.ModuleErrorf(module, "unknown module type %t", module)
58 }
59 })
60
61 sort.Strings(supportAars)
62 sort.Strings(supportJars)
63
64 ctx.Strict("SUPPORT_LIBRARIES_AARS", strings.Join(supportAars, " "))
65 ctx.Strict("SUPPORT_LIBRARIES_JARS", strings.Join(supportJars, " "))
66}