Sasha Smundak | ff36da0 | 2019-02-12 17:12:08 -0800 | [diff] [blame^] | 1 | // Copyright 2016 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 | // Implements vts_config module |
| 23 | |
| 24 | func init() { |
| 25 | RegisterModuleType("vts_config", VtsConfigFactory) |
| 26 | } |
| 27 | |
| 28 | type vtsConfigProperties struct { |
| 29 | // Test manifest file name if different from AndroidTest.xml. |
| 30 | Test_config *string |
| 31 | } |
| 32 | |
| 33 | type VtsConfig struct { |
| 34 | ModuleBase |
| 35 | properties vtsConfigProperties |
| 36 | OutputFilePath OutputPath |
| 37 | } |
| 38 | |
| 39 | func (me *VtsConfig) GenerateAndroidBuildActions(ctx ModuleContext) { |
| 40 | me.OutputFilePath = PathForModuleOut(ctx, me.BaseModuleName()).OutputPath |
| 41 | } |
| 42 | |
| 43 | func (me *VtsConfig) AndroidMk() AndroidMkData { |
| 44 | androidMkData := AndroidMkData{ |
| 45 | Class: "FAKE", |
| 46 | Include: "$(BUILD_SYSTEM)/android_vts_host_config.mk", |
| 47 | OutputFile: OptionalPathForPath(me.OutputFilePath), |
| 48 | } |
| 49 | if me.properties.Test_config != nil { |
| 50 | androidMkData.Extra = []AndroidMkExtraFunc{ |
| 51 | func(w io.Writer, outputFile Path) { |
| 52 | fmt.Fprintf(w, "LOCAL_TEST_CONFIG := %s\n", |
| 53 | *me.properties.Test_config) |
| 54 | }, |
| 55 | } |
| 56 | } |
| 57 | return androidMkData |
| 58 | } |
| 59 | |
| 60 | func InitVtsConfigModule(me *VtsConfig) { |
| 61 | me.AddProperties(&me.properties) |
| 62 | } |
| 63 | |
| 64 | // Defines VTS configuration. |
| 65 | func VtsConfigFactory() Module { |
| 66 | module := &VtsConfig{} |
| 67 | InitVtsConfigModule(module) |
| 68 | InitAndroidArchModule(module /*TODO: or HostAndDeviceSupported? */, HostSupported, MultilibFirst) |
| 69 | return module |
| 70 | } |