diff options
author | Nan Zhang <nanzhang@google.com> | 2017-05-10 13:37:54 -0700 |
---|---|---|
committer | Nan Zhang <nanzhang@google.com> | 2017-05-17 11:26:00 -0700 |
commit | 5323f8e32f9e08def4a68608510062c464ed4c1e (patch) | |
tree | 5c44e3cc7343a74e054171ee72c94856ce6257d1 /python/python.go | |
parent | 2c13abc95e3e2c6c12fff6aa42262ef3296c2a1b (diff) | |
download | android_build_soong-5323f8e32f9e08def4a68608510062c464ed4c1e.tar.gz android_build_soong-5323f8e32f9e08def4a68608510062c464ed4c1e.tar.bz2 android_build_soong-5323f8e32f9e08def4a68608510062c464ed4c1e.zip |
Add python_test_host module.
bug: 31676493
Test: created py_test modules in real folder. and ran 'mma'.
Change-Id: I22aa2fad74b11e4a31ea7a4c4a4f0ea64cd3fc94
Diffstat (limited to 'python/python.go')
-rw-r--r-- | python/python.go | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/python/python.go b/python/python.go index 1c74c9af..ab80e4d2 100644 --- a/python/python.go +++ b/python/python.go @@ -110,11 +110,15 @@ type pythonBaseModule struct { // the soong_zip arguments for zipping current module source/data files. parSpec parSpec + + // the installer might be nil. + installer installer + + subAndroidMkOnce map[subAndroidMkProvider]bool } type PythonSubModule interface { - GeneratePythonBuildActions(ctx android.ModuleContext) - GeneratePythonAndroidMk() (ret android.AndroidMkData, err error) + GeneratePythonBuildActions(ctx android.ModuleContext) android.OptionalPath } type PythonDependency interface { @@ -123,6 +127,14 @@ type PythonDependency interface { GetParSpec() parSpec } +type pythonDecorator struct { + baseInstaller *pythonInstaller +} + +type installer interface { + install(ctx android.ModuleContext, path android.Path) +} + func (p *pythonBaseModule) GetSrcsPathMappings() []pathMapping { return p.srcsPathMappings } @@ -246,10 +258,14 @@ func uniqueLibs(ctx android.BottomUpMutatorContext, } func (p *pythonBaseModule) GenerateAndroidBuildActions(ctx android.ModuleContext) { - p.subModule.GeneratePythonBuildActions(ctx) + installSource := p.subModule.GeneratePythonBuildActions(ctx) + + if p.installer != nil && installSource.Valid() { + p.installer.install(ctx, installSource.Path()) + } } -func (p *pythonBaseModule) GeneratePythonBuildActions(ctx android.ModuleContext) { +func (p *pythonBaseModule) GeneratePythonBuildActions(ctx android.ModuleContext) android.OptionalPath { // expand python files from "srcs" property. srcs := p.properties.Srcs switch p.properties.ActualVersion { @@ -277,7 +293,7 @@ func (p *pythonBaseModule) GeneratePythonBuildActions(ctx android.ModuleContext) strings.HasPrefix(pkg_path, "/") { ctx.PropertyErrorf("pkg_path", "%q is not a valid format.", p.properties.Pkg_path) - return + return android.OptionalPath{} } // pkg_path starts from "runfiles/" implicitly. pkg_path = filepath.Join(runFiles, pkg_path) @@ -291,6 +307,8 @@ func (p *pythonBaseModule) GeneratePythonBuildActions(ctx android.ModuleContext) p.parSpec = p.dumpFileList(ctx, pkg_path) p.uniqWholeRunfilesTree(ctx) + + return android.OptionalPath{} } // generate current module unique pathMappings: <dest: runfiles_path, src: source_path> @@ -409,7 +427,7 @@ func (p *pythonBaseModule) uniqWholeRunfilesTree(ctx android.ModuleContext) { } // binary needs the Python runfiles paths from all its // dependencies to fill __init__.py in each runfiles dir. - if sub, ok := p.subModule.(*PythonBinary); ok { + if sub, ok := p.subModule.(*pythonBinaryBase); ok { sub.depsPyRunfiles = append(sub.depsPyRunfiles, path.dest) } } @@ -421,7 +439,7 @@ func (p *pythonBaseModule) uniqWholeRunfilesTree(ctx android.ModuleContext) { } // binary needs the soong_zip arguments from all its // dependencies to generate executable par file. - if sub, ok := p.subModule.(*PythonBinary); ok { + if sub, ok := p.subModule.(*pythonBinaryBase); ok { sub.depsParSpecs = append(sub.depsParSpecs, dep.GetParSpec()) } } @@ -442,7 +460,3 @@ func fillInMap(ctx android.ModuleContext, m map[string]string, return true } - -func (p *pythonBaseModule) AndroidMk() (ret android.AndroidMkData, err error) { - return p.subModule.GeneratePythonAndroidMk() -} |