| Nan Zhang | 5323f8e | 2017-05-10 13:37:54 -0700 | [diff] [blame] | 1 | // 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 |  | 
|  | 15 | package python | 
|  | 16 |  | 
|  | 17 | import ( | 
|  | 18 | "android/soong/android" | 
| Nan Zhang | 5323f8e | 2017-05-10 13:37:54 -0700 | [diff] [blame] | 19 | ) | 
|  | 20 |  | 
|  | 21 | // This file contains the module types for building Python test. | 
|  | 22 |  | 
|  | 23 | func init() { | 
|  | 24 | android.RegisterModuleType("python_test_host", PythonTestHostFactory) | 
|  | 25 | } | 
|  | 26 |  | 
| Nan Zhang | d4e641b | 2017-07-12 12:55:28 -0700 | [diff] [blame] | 27 | type testDecorator struct { | 
|  | 28 | *binaryDecorator | 
| Nan Zhang | 5323f8e | 2017-05-10 13:37:54 -0700 | [diff] [blame] | 29 | } | 
|  | 30 |  | 
| Nan Zhang | d4e641b | 2017-07-12 12:55:28 -0700 | [diff] [blame] | 31 | func (test *testDecorator) install(ctx android.ModuleContext, file android.Path) { | 
|  | 32 | test.binaryDecorator.baseInstaller.install(ctx, file) | 
| Nan Zhang | 5323f8e | 2017-05-10 13:37:54 -0700 | [diff] [blame] | 33 | } | 
|  | 34 |  | 
| Nan Zhang | d4e641b | 2017-07-12 12:55:28 -0700 | [diff] [blame] | 35 | func NewTest(hod android.HostOrDeviceSupported) *Module { | 
|  | 36 | module, binary := NewBinary(hod) | 
|  | 37 |  | 
|  | 38 | binary.baseInstaller = NewPythonInstaller("nativetest") | 
|  | 39 |  | 
|  | 40 | test := &testDecorator{binaryDecorator: binary} | 
|  | 41 |  | 
|  | 42 | module.bootstrapper = test | 
|  | 43 | module.installer = test | 
|  | 44 |  | 
|  | 45 | return module | 
| Nan Zhang | 5323f8e | 2017-05-10 13:37:54 -0700 | [diff] [blame] | 46 | } | 
|  | 47 |  | 
| Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 48 | func PythonTestHostFactory() android.Module { | 
| Nan Zhang | d4e641b | 2017-07-12 12:55:28 -0700 | [diff] [blame] | 49 | module := NewTest(android.HostSupportedNoCross) | 
| Nan Zhang | 5323f8e | 2017-05-10 13:37:54 -0700 | [diff] [blame] | 50 |  | 
| Nan Zhang | d4e641b | 2017-07-12 12:55:28 -0700 | [diff] [blame] | 51 | return module.Init() | 
| Nan Zhang | 5323f8e | 2017-05-10 13:37:54 -0700 | [diff] [blame] | 52 | } |