diff options
author | 2021-11-01 15:32:43 -0400 | |
---|---|---|
committer | 2021-12-14 09:37:45 -0500 | |
commit | be46fccc404c18f7b90d370835cfa350db1debd7 (patch) | |
tree | af83853733f28b4ccc8a40c6afc81bb6f1a3463a /python/python.go | |
parent | d469eefcc30a879c28c440965bbc06683d3a9be3 (diff) |
Use one mutator for all bp2build conversion.
Each conversion required defining a separate mutator, which will each
operate on _all_ modules and requires each to repeat checks whether the
mutator should operator. Instead, we introduce a single mutator and
modules can define a ConvertWithBp2build to implement bp2build
conversion for that module.
Test: bp2build.sh
Bug: 183079158
Change-Id: I99d4b51f441c2903879092c5b56313d606d4338d
Diffstat (limited to 'python/python.go')
-rw-r--r-- | python/python.go | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/python/python.go b/python/python.go index 401d91fe3..734ac57f1 100644 --- a/python/python.go +++ b/python/python.go @@ -23,6 +23,7 @@ import ( "strings" "android/soong/bazel" + "github.com/google/blueprint" "github.com/google/blueprint/proptools" @@ -667,18 +668,25 @@ func (p *Module) createSrcsZip(ctx android.ModuleContext, pkgPath string) androi } // isPythonLibModule returns whether the given module is a Python library Module or not -// This is distinguished by the fact that Python libraries are not installable, while other Python -// modules are. func isPythonLibModule(module blueprint.Module) bool { if m, ok := module.(*Module); ok { - // Python library has no bootstrapper or installer - if m.bootstrapper == nil && m.installer == nil { - return true - } + return m.isLibrary() } return false } +// This is distinguished by the fact that Python libraries are not installable, while other Python +// modules are. +func (p *Module) isLibrary() bool { + // Python library has no bootstrapper or installer + return p.bootstrapper == nil && p.installer == nil +} + +func (p *Module) isBinary() bool { + _, ok := p.bootstrapper.(*binaryDecorator) + return ok +} + // collectPathsFromTransitiveDeps checks for source/data files for duplicate paths // for module and its transitive dependencies and collects list of data/source file // zips for transitive dependencies. @@ -752,6 +760,14 @@ func (p *Module) InstallInData() bool { return true } +func (p *Module) ConvertWithBp2build(ctx android.TopDownMutatorContext) { + if p.isLibrary() { + pythonLibBp2Build(ctx, p) + } else if p.isBinary() { + pythonBinaryBp2Build(ctx, p) + } +} + var Bool = proptools.Bool var BoolDefault = proptools.BoolDefault var String = proptools.String |