| Colin Cross | b2559a0 | 2018-04-19 15:26:10 -0700 | [diff] [blame] | 1 | // 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 |  | 
 | 15 | package java | 
 | 16 |  | 
 | 17 | import ( | 
 | 18 | 	"sort" | 
 | 19 | 	"strings" | 
 | 20 |  | 
 | 21 | 	"android/soong/android" | 
 | 22 | ) | 
 | 23 |  | 
 | 24 | func init() { | 
 | 25 | 	android.RegisterMakeVarsProvider(pctx, supportLibrariesMakeVarsProvider) | 
 | 26 | } | 
 | 27 |  | 
 | 28 | func supportLibrariesMakeVarsProvider(ctx android.MakeVarsContext) { | 
 | 29 | 	var supportAars, supportJars []string | 
 | 30 |  | 
| Colin Cross | 65494b9 | 2019-02-07 14:25:51 -0800 | [diff] [blame] | 31 | 	ctx.VisitAllModules(func(module android.Module) { | 
 | 32 | 		dir := ctx.ModuleDir(module) | 
| Colin Cross | b2559a0 | 2018-04-19 15:26:10 -0700 | [diff] [blame] | 33 | 		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 Cross | 65494b9 | 2019-02-07 14:25:51 -0800 | [diff] [blame] | 45 | 		name := ctx.ModuleName(module) | 
| Colin Cross | b2559a0 | 2018-04-19 15:26:10 -0700 | [diff] [blame] | 46 | 		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 Cross | b2559a0 | 2018-04-19 15:26:10 -0700 | [diff] [blame] | 55 | 		} | 
 | 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 | } |