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" |
| 19 | "path/filepath" |
Nan Zhang | 5323f8e | 2017-05-10 13:37:54 -0700 | [diff] [blame] | 20 | ) |
| 21 | |
| 22 | // This file contains the module types for building Python test. |
| 23 | |
| 24 | func init() { |
| 25 | android.RegisterModuleType("python_test_host", PythonTestHostFactory) |
| 26 | } |
| 27 | |
| 28 | type PythonTestHost struct { |
| 29 | pythonBinaryBase |
| 30 | } |
| 31 | |
| 32 | var _ PythonSubModule = (*PythonTestHost)(nil) |
| 33 | |
| 34 | type pythonTestHostDecorator struct { |
| 35 | pythonDecorator |
| 36 | } |
| 37 | |
| 38 | func (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 Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame^] | 43 | func PythonTestHostFactory() android.Module { |
Nan Zhang | 5323f8e | 2017-05-10 13:37:54 -0700 | [diff] [blame] | 44 | decorator := &pythonTestHostDecorator{ |
| 45 | pythonDecorator: pythonDecorator{baseInstaller: NewPythonInstaller("nativetest")}} |
| 46 | |
| 47 | module := &PythonBinaryHost{} |
| 48 | module.pythonBaseModule.installer = decorator |
| 49 | |
Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame^] | 50 | module.AddProperties(&module.binaryProperties) |
| 51 | |
Nan Zhang | 5323f8e | 2017-05-10 13:37:54 -0700 | [diff] [blame] | 52 | return InitPythonBaseModule(&module.pythonBinaryBase.pythonBaseModule, |
Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame^] | 53 | &module.pythonBinaryBase, android.HostSupportedNoCross) |
Nan Zhang | 5323f8e | 2017-05-10 13:37:54 -0700 | [diff] [blame] | 54 | } |