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