1// Copyright 2025 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 android 16 17func init() { 18 InitRegistrationContext.RegisterSingletonType("test_mapping_zip_singleton", testMappingZipSingletonFactory) 19} 20 21func testMappingZipSingletonFactory() Singleton { 22 return &testMappingZipSingleton{} 23} 24 25type testMappingZipSingleton struct{} 26 27func (s *testMappingZipSingleton) GenerateBuildActions(ctx SingletonContext) { 28 fileListFile := PathForArbitraryOutput(ctx, ".module_paths", "TEST_MAPPING.list") 29 out := PathForOutput(ctx, "test_mappings.zip") 30 dep := PathForOutput(ctx, "test_mappings.zip.d") 31 32 // disabled-presubmit-tests used to be filled out based on modules that set 33 // LOCAL_PRESUBMIT_DISABLED. But that's no longer used and there was never a soong equivalent 34 // anyways, so just always create an empty file. 35 disabledPresubmitTestsFile := PathForOutput(ctx, "disabled-presubmit-tests") 36 WriteFileRule(ctx, disabledPresubmitTestsFile, "") 37 38 builder := NewRuleBuilder(pctx, ctx) 39 builder.Command().BuiltTool("soong_zip"). 40 FlagWithOutput("-o ", out). 41 FlagWithInput("-l ", fileListFile). 42 FlagWithArg("-e ", "disabled-presubmit-tests"). 43 FlagWithInput("-f ", disabledPresubmitTestsFile) 44 builder.Command().Textf("echo '%s : ' $(cat %s) > ", out, fileListFile).DepFile(dep) 45 builder.Build("test_mappings_zip", "build TEST_MAPPING zip") 46 47 ctx.Phony("test_mapping", out) 48 ctx.DistForGoals([]string{"dist_files", "test_mapping"}, out) 49} 50