summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/library.go19
1 files changed, 15 insertions, 4 deletions
diff --git a/python/library.go b/python/library.go
index c25519063..45fc00227 100644
--- a/python/library.go
+++ b/python/library.go
@@ -26,6 +26,7 @@ import (
func init() {
registerPythonLibraryComponents(android.InitRegistrationContext)
+ android.RegisterBp2BuildMutator("python_library_host", PythonLibraryHostBp2Build)
android.RegisterBp2BuildMutator("python_library", PythonLibraryBp2Build)
}
@@ -37,6 +38,8 @@ func registerPythonLibraryComponents(ctx android.RegistrationContext) {
func PythonLibraryHostFactory() android.Module {
module := newModule(android.HostSupported, android.MultilibFirst)
+ android.InitBazelModule(module)
+
return module.init()
}
@@ -46,14 +49,22 @@ type bazelPythonLibraryAttributes struct {
Srcs_version string
}
+func PythonLibraryHostBp2Build(ctx android.TopDownMutatorContext) {
+ pythonLibBp2Build(ctx, "python_library_host")
+}
+
func PythonLibraryBp2Build(ctx android.TopDownMutatorContext) {
+ pythonLibBp2Build(ctx, "python_library")
+}
+
+func pythonLibBp2Build(ctx android.TopDownMutatorContext, modType string) {
m, ok := ctx.Module().(*Module)
if !ok || !m.ConvertWithBp2build(ctx) {
return
}
- // a Module can be something other than a python_library
- if ctx.ModuleType() != "python_library" {
+ // a Module can be something other than a `modType`
+ if ctx.ModuleType() != modType {
return
}
@@ -70,8 +81,8 @@ func PythonLibraryBp2Build(ctx android.TopDownMutatorContext) {
python_version = "PY3"
} else if !py2Enabled && !py3Enabled {
panic(fmt.Errorf(
- "error for '%s' module: bp2build's python_library converter doesn't understand having "+
- "neither py2 nor py3 enabled", m.Name()))
+ "error for '%s' module: bp2build's %s converter doesn't understand having "+
+ "neither py2 nor py3 enabled", m.Name(), modType))
} else {
// do nothing, since python_version defaults to PY2ANDPY3
}