1// Copyright 2023 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 aconfig 16 17import ( 18 "strconv" 19 20 "android/soong/android" 21) 22 23func ExportedJavaDeclarationsLibraryFactory() android.Singleton { 24 return &exportedJavaDeclarationsLibrarySingleton{} 25} 26 27type exportedJavaDeclarationsLibrarySingleton struct { 28 intermediatePath android.OutputPath 29} 30 31func (this *exportedJavaDeclarationsLibrarySingleton) GenerateBuildActions(ctx android.SingletonContext) { 32 // Find all of the aconfig_declarations modules 33 var cacheFiles android.Paths 34 ctx.VisitAllModuleProxies(func(module android.ModuleProxy) { 35 decl, ok := android.OtherModuleProvider(ctx, module, android.AconfigDeclarationsProviderKey) 36 if !ok { 37 return 38 } 39 cacheFiles = append(cacheFiles, decl.IntermediateCacheOutputPath) 40 }) 41 42 var newExported bool 43 if useNewExported, ok := ctx.Config().GetBuildFlag("RELEASE_ACONFIG_NEW_EXPORTED"); ok { 44 newExported = useNewExported == "true" 45 } 46 47 var newStorage bool 48 if useNewStorage, ok := ctx.Config().GetBuildFlag("RELEASE_READ_FROM_NEW_STORAGE"); ok { 49 newStorage = useNewStorage == "true" 50 } 51 52 // Generate build action for aconfig 53 this.intermediatePath = android.PathForIntermediates(ctx, "exported_java_aconfig_library.jar") 54 ctx.Build(pctx, android.BuildParams{ 55 Rule: exportedJavaRule, 56 Inputs: cacheFiles, 57 Output: this.intermediatePath, 58 Description: "exported_java_aconfig_library", 59 Args: map[string]string{ 60 "cache_files": android.JoinPathsWithPrefix(cacheFiles, " "), 61 "use_new_storage": strconv.FormatBool(newStorage), 62 "use_new_exported": strconv.FormatBool(newExported), 63 "check_api_level": strconv.FormatBool(ctx.Config().ReleaseAconfigCheckApiLevel()), 64 }, 65 }) 66 ctx.Phony("exported_java_aconfig_library", this.intermediatePath) 67 ctx.DistForGoalWithFilename("sdk", this.intermediatePath, "android-flags.jar") 68} 69