karenluo | c031819 | 2019-10-10 21:26:26 -0400 | [diff] [blame] | 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 | |
| 15 | package android |
| 16 | |
karenluo | c031819 | 2019-10-10 21:26:26 -0400 | [diff] [blame] | 17 | func init() { |
Paul Duffin | 140a8e1 | 2021-03-16 19:21:14 +0000 | [diff] [blame] | 18 | registerCSuiteBuildComponents(InitRegistrationContext) |
| 19 | } |
| 20 | |
| 21 | func registerCSuiteBuildComponents(ctx RegistrationContext) { |
| 22 | ctx.RegisterModuleType("csuite_config", CSuiteConfigFactory) |
karenluo | c031819 | 2019-10-10 21:26:26 -0400 | [diff] [blame] | 23 | } |
| 24 | |
| 25 | type csuiteConfigProperties struct { |
| 26 | // Override the default (AndroidTest.xml) test manifest file name. |
| 27 | Test_config *string |
| 28 | } |
| 29 | |
| 30 | type CSuiteConfig struct { |
| 31 | ModuleBase |
| 32 | properties csuiteConfigProperties |
| 33 | OutputFilePath OutputPath |
| 34 | } |
| 35 | |
| 36 | func (me *CSuiteConfig) GenerateAndroidBuildActions(ctx ModuleContext) { |
| 37 | me.OutputFilePath = PathForModuleOut(ctx, me.BaseModuleName()).OutputPath |
| 38 | } |
| 39 | |
Liz Kammer | e2a17a5 | 2020-11-24 13:31:28 -0800 | [diff] [blame] | 40 | func (me *CSuiteConfig) AndroidMkEntries() []AndroidMkEntries { |
| 41 | androidMkEntries := AndroidMkEntries{ |
karenluo | c031819 | 2019-10-10 21:26:26 -0400 | [diff] [blame] | 42 | Class: "FAKE", |
| 43 | Include: "$(BUILD_SYSTEM)/suite_host_config.mk", |
| 44 | OutputFile: OptionalPathForPath(me.OutputFilePath), |
| 45 | } |
Liz Kammer | e2a17a5 | 2020-11-24 13:31:28 -0800 | [diff] [blame] | 46 | androidMkEntries.ExtraEntries = []AndroidMkExtraEntriesFunc{ |
Colin Cross | aa25553 | 2020-07-03 13:18:24 -0700 | [diff] [blame] | 47 | func(ctx AndroidMkExtraEntriesContext, entries *AndroidMkEntries) { |
karenluo | c031819 | 2019-10-10 21:26:26 -0400 | [diff] [blame] | 48 | if me.properties.Test_config != nil { |
Liz Kammer | e2a17a5 | 2020-11-24 13:31:28 -0800 | [diff] [blame] | 49 | entries.SetString("LOCAL_TEST_CONFIG", *me.properties.Test_config) |
karenluo | c031819 | 2019-10-10 21:26:26 -0400 | [diff] [blame] | 50 | } |
Liz Kammer | 57f5b33 | 2020-11-24 12:42:58 -0800 | [diff] [blame] | 51 | entries.AddCompatibilityTestSuites("csuite") |
karenluo | c031819 | 2019-10-10 21:26:26 -0400 | [diff] [blame] | 52 | }, |
| 53 | } |
Liz Kammer | e2a17a5 | 2020-11-24 13:31:28 -0800 | [diff] [blame] | 54 | return []AndroidMkEntries{androidMkEntries} |
karenluo | c031819 | 2019-10-10 21:26:26 -0400 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | func 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). |
| 63 | func CSuiteConfigFactory() Module { |
| 64 | module := &CSuiteConfig{} |
| 65 | InitCSuiteConfigModule(module) |
| 66 | InitAndroidArchModule(module, HostSupported, MultilibFirst) |
| 67 | return module |
| 68 | } |