blob: 837eb259e57b7d016ec2a6e187dc6dd5764da3f8 [file] [log] [blame]
Nan Zhang5323f8e2017-05-10 13:37:54 -07001// Copyright 2017 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 python
16
17import (
18 "android/soong/android"
19 "path/filepath"
Nan Zhang5323f8e2017-05-10 13:37:54 -070020)
21
22// This file contains the module types for building Python test.
23
24func init() {
25 android.RegisterModuleType("python_test_host", PythonTestHostFactory)
26}
27
28type PythonTestHost struct {
29 pythonBinaryBase
30}
31
32var _ PythonSubModule = (*PythonTestHost)(nil)
33
34type pythonTestHostDecorator struct {
35 pythonDecorator
36}
37
38func (p *pythonTestHostDecorator) install(ctx android.ModuleContext, file android.Path) {
39 p.pythonDecorator.baseInstaller.dir = filepath.Join("nativetest", ctx.ModuleName())
40 p.pythonDecorator.baseInstaller.install(ctx, file)
41}
42
Colin Cross36242852017-06-23 15:06:31 -070043func PythonTestHostFactory() android.Module {
Nan Zhang5323f8e2017-05-10 13:37:54 -070044 decorator := &pythonTestHostDecorator{
45 pythonDecorator: pythonDecorator{baseInstaller: NewPythonInstaller("nativetest")}}
46
47 module := &PythonBinaryHost{}
48 module.pythonBaseModule.installer = decorator
49
Colin Cross36242852017-06-23 15:06:31 -070050 module.AddProperties(&module.binaryProperties)
51
Nan Zhang5323f8e2017-05-10 13:37:54 -070052 return InitPythonBaseModule(&module.pythonBinaryBase.pythonBaseModule,
Colin Cross36242852017-06-23 15:06:31 -070053 &module.pythonBinaryBase, android.HostSupportedNoCross)
Nan Zhang5323f8e2017-05-10 13:37:54 -070054}