1// Copyright 2019 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 registerCSuiteBuildComponents(InitRegistrationContext) 19} 20 21func registerCSuiteBuildComponents(ctx RegistrationContext) { 22 ctx.RegisterModuleType("csuite_config", CSuiteConfigFactory) 23} 24 25type csuiteConfigProperties struct { 26 // Override the default (AndroidTest.xml) test manifest file name. 27 Test_config *string 28} 29 30type CSuiteConfig struct { 31 ModuleBase 32 properties csuiteConfigProperties 33 OutputFilePath OutputPath 34} 35 36func (me *CSuiteConfig) GenerateAndroidBuildActions(ctx ModuleContext) { 37 me.OutputFilePath = PathForModuleOut(ctx, me.BaseModuleName()).OutputPath 38} 39 40func (me *CSuiteConfig) AndroidMkEntries() []AndroidMkEntries { 41 androidMkEntries := AndroidMkEntries{ 42 Class: "FAKE", 43 Include: "$(BUILD_SYSTEM)/suite_host_config.mk", 44 OutputFile: OptionalPathForPath(me.OutputFilePath), 45 } 46 androidMkEntries.ExtraEntries = []AndroidMkExtraEntriesFunc{ 47 func(ctx AndroidMkExtraEntriesContext, entries *AndroidMkEntries) { 48 if me.properties.Test_config != nil { 49 entries.SetString("LOCAL_TEST_CONFIG", *me.properties.Test_config) 50 } 51 entries.AddCompatibilityTestSuites("csuite") 52 }, 53 } 54 return []AndroidMkEntries{androidMkEntries} 55} 56 57func InitCSuiteConfigModule(me *CSuiteConfig) { 58 me.AddProperties(&me.properties) 59} 60 61// csuite_config generates an App Compatibility Test Suite (C-Suite) configuration file from the 62// <test_config> xml file and stores it in a subdirectory of $(HOST_OUT). 63func CSuiteConfigFactory() Module { 64 module := &CSuiteConfig{} 65 InitCSuiteConfigModule(module) 66 InitAndroidArchModule(module, HostSupported, MultilibFirst) 67 return module 68} 69