blob: 825e63cc43b6e09636ad2dad90bc314414a78b4e [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"
Nan Zhang5323f8e2017-05-10 13:37:54 -070019)
20
21// This file contains the module types for building Python test.
22
23func init() {
24 android.RegisterModuleType("python_test_host", PythonTestHostFactory)
Nan Zhangd9ec5e72017-12-01 20:00:31 +000025 android.RegisterModuleType("python_test", PythonTestFactory)
Nan Zhang5323f8e2017-05-10 13:37:54 -070026}
27
Nan Zhangd4e641b2017-07-12 12:55:28 -070028type testDecorator struct {
29 *binaryDecorator
Nan Zhang5323f8e2017-05-10 13:37:54 -070030}
31
Nan Zhangd4e641b2017-07-12 12:55:28 -070032func (test *testDecorator) install(ctx android.ModuleContext, file android.Path) {
Nan Zhangd9ec5e72017-12-01 20:00:31 +000033 test.binaryDecorator.pythonInstaller.dir = "nativetest"
34 test.binaryDecorator.pythonInstaller.dir64 = "nativetest64"
35
36 test.binaryDecorator.pythonInstaller.relative = ctx.ModuleName()
37
38 test.binaryDecorator.pythonInstaller.install(ctx, file)
Nan Zhang5323f8e2017-05-10 13:37:54 -070039}
40
Nan Zhangd4e641b2017-07-12 12:55:28 -070041func NewTest(hod android.HostOrDeviceSupported) *Module {
42 module, binary := NewBinary(hod)
43
Nan Zhangd9ec5e72017-12-01 20:00:31 +000044 binary.pythonInstaller = NewPythonInstaller("nativetest", "nativetest64")
Nan Zhangd4e641b2017-07-12 12:55:28 -070045
46 test := &testDecorator{binaryDecorator: binary}
47
48 module.bootstrapper = test
49 module.installer = test
50
51 return module
Nan Zhang5323f8e2017-05-10 13:37:54 -070052}
53
Colin Cross36242852017-06-23 15:06:31 -070054func PythonTestHostFactory() android.Module {
Nan Zhangd4e641b2017-07-12 12:55:28 -070055 module := NewTest(android.HostSupportedNoCross)
Nan Zhang5323f8e2017-05-10 13:37:54 -070056
Nan Zhangd4e641b2017-07-12 12:55:28 -070057 return module.Init()
Nan Zhang5323f8e2017-05-10 13:37:54 -070058}
Nan Zhangd9ec5e72017-12-01 20:00:31 +000059
60func PythonTestFactory() android.Module {
61 module := NewTest(android.HostAndDeviceSupported)
62 module.multilib = android.MultilibBoth
63
64 return module.Init()
65}