blob: 20bd03563d043be891345f75b64576659261dc2d [file] [log] [blame]
karenluoc0318192019-10-10 21:26:26 -04001// 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
karenluoc0318192019-10-10 21:26:26 -040017func init() {
Paul Duffin140a8e12021-03-16 19:21:14 +000018 registerCSuiteBuildComponents(InitRegistrationContext)
19}
20
21func registerCSuiteBuildComponents(ctx RegistrationContext) {
22 ctx.RegisterModuleType("csuite_config", CSuiteConfigFactory)
karenluoc0318192019-10-10 21:26:26 -040023}
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
Liz Kammere2a17a52020-11-24 13:31:28 -080040func (me *CSuiteConfig) AndroidMkEntries() []AndroidMkEntries {
41 androidMkEntries := AndroidMkEntries{
karenluoc0318192019-10-10 21:26:26 -040042 Class: "FAKE",
43 Include: "$(BUILD_SYSTEM)/suite_host_config.mk",
44 OutputFile: OptionalPathForPath(me.OutputFilePath),
45 }
Liz Kammere2a17a52020-11-24 13:31:28 -080046 androidMkEntries.ExtraEntries = []AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -070047 func(ctx AndroidMkExtraEntriesContext, entries *AndroidMkEntries) {
karenluoc0318192019-10-10 21:26:26 -040048 if me.properties.Test_config != nil {
Liz Kammere2a17a52020-11-24 13:31:28 -080049 entries.SetString("LOCAL_TEST_CONFIG", *me.properties.Test_config)
karenluoc0318192019-10-10 21:26:26 -040050 }
Liz Kammer57f5b332020-11-24 12:42:58 -080051 entries.AddCompatibilityTestSuites("csuite")
karenluoc0318192019-10-10 21:26:26 -040052 },
53 }
Liz Kammere2a17a52020-11-24 13:31:28 -080054 return []AndroidMkEntries{androidMkEntries}
karenluoc0318192019-10-10 21:26:26 -040055}
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}