blob: c44b3a32ece1c9a7d4e33ff3839e2729c79a7f42 [file] [log] [blame]
Sasha Smundakff36da02019-02-12 17:12:08 -08001// 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
15package android
16
17import (
18 "fmt"
19 "io"
20)
21
Sasha Smundakff36da02019-02-12 17:12:08 -080022func init() {
23 RegisterModuleType("vts_config", VtsConfigFactory)
24}
25
26type vtsConfigProperties struct {
Patrice Arruda3cec2722019-03-13 14:01:12 -070027 // Override the default (AndroidTest.xml) test manifest file name.
Sasha Smundakff36da02019-02-12 17:12:08 -080028 Test_config *string
29}
30
31type VtsConfig struct {
32 ModuleBase
33 properties vtsConfigProperties
34 OutputFilePath OutputPath
35}
36
37func (me *VtsConfig) GenerateAndroidBuildActions(ctx ModuleContext) {
38 me.OutputFilePath = PathForModuleOut(ctx, me.BaseModuleName()).OutputPath
39}
40
41func (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
58func InitVtsConfigModule(me *VtsConfig) {
59 me.AddProperties(&me.properties)
60}
61
Patrice Arruda3cec2722019-03-13 14:01:12 -070062// 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 Smundakff36da02019-02-12 17:12:08 -080064func VtsConfigFactory() Module {
65 module := &VtsConfig{}
66 InitVtsConfigModule(module)
67 InitAndroidArchModule(module /*TODO: or HostAndDeviceSupported? */, HostSupported, MultilibFirst)
68 return module
69}