Add python_test_host module.

bug: 31676493
Test: created py_test modules in real folder. and ran 'mma'.
Change-Id: I22aa2fad74b11e4a31ea7a4c4a4f0ea64cd3fc94
This commit is contained in:
Nan Zhang
2017-05-10 13:37:54 -07:00
parent 2c13abc95e
commit 5323f8e32f
8 changed files with 227 additions and 61 deletions

View File

@@ -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()
}