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 | |
| 17 | import ( |
| 18 | "fmt" |
| 19 | "io" |
| 20 | ) |
| 21 | |
| 22 | func init() { |
| 23 | RegisterModuleType("csuite_config", CSuiteConfigFactory) |
| 24 | } |
| 25 | |
| 26 | type csuiteConfigProperties struct { |
| 27 | // Override the default (AndroidTest.xml) test manifest file name. |
| 28 | Test_config *string |
| 29 | } |
| 30 | |
| 31 | type CSuiteConfig struct { |
| 32 | ModuleBase |
| 33 | properties csuiteConfigProperties |
| 34 | OutputFilePath OutputPath |
| 35 | } |
| 36 | |
| 37 | func (me *CSuiteConfig) GenerateAndroidBuildActions(ctx ModuleContext) { |
| 38 | me.OutputFilePath = PathForModuleOut(ctx, me.BaseModuleName()).OutputPath |
| 39 | } |
| 40 | |
| 41 | func (me *CSuiteConfig) AndroidMk() AndroidMkData { |
| 42 | androidMkData := AndroidMkData{ |
| 43 | Class: "FAKE", |
| 44 | Include: "$(BUILD_SYSTEM)/suite_host_config.mk", |
| 45 | OutputFile: OptionalPathForPath(me.OutputFilePath), |
| 46 | } |
| 47 | androidMkData.Extra = []AndroidMkExtraFunc{ |
| 48 | func(w io.Writer, outputFile Path) { |
| 49 | if me.properties.Test_config != nil { |
| 50 | fmt.Fprintf(w, "LOCAL_TEST_CONFIG := %s\n", |
| 51 | *me.properties.Test_config) |
| 52 | } |
| 53 | fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE := csuite") |
| 54 | }, |
| 55 | } |
| 56 | return androidMkData |
| 57 | } |
| 58 | |
| 59 | func InitCSuiteConfigModule(me *CSuiteConfig) { |
| 60 | me.AddProperties(&me.properties) |
| 61 | } |
| 62 | |
| 63 | // csuite_config generates an App Compatibility Test Suite (C-Suite) configuration file from the |
| 64 | // <test_config> xml file and stores it in a subdirectory of $(HOST_OUT). |
| 65 | func CSuiteConfigFactory() Module { |
| 66 | module := &CSuiteConfig{} |
| 67 | InitCSuiteConfigModule(module) |
| 68 | InitAndroidArchModule(module, HostSupported, MultilibFirst) |
| 69 | return module |
| 70 | } |