Fix python_binary_host module in mixed build.
Test: USE_BAZEL_ANALYSIS=1 m genfunctosyscallnrs
Test: USE_BAZEL_ANALYSIS=1 m func_to_syscall_nrs
Test: USE_BAZEL_ANALYSIS=1 m libseccomp_policy
Bug: 201094425, 197135289
Change-Id: Ibc8b99a92149410c8a879b7a4facf6c8961a7b9f
diff --git a/python/binary.go b/python/binary.go
index bf6167c..304c9a9 100644
--- a/python/binary.go
+++ b/python/binary.go
@@ -143,7 +143,7 @@
func NewBinary(hod android.HostOrDeviceSupported) (*Module, *binaryDecorator) {
module := newModule(hod, android.MultilibFirst)
- decorator := &binaryDecorator{pythonInstaller: NewPythonInstaller("bin", "")}
+ decorator := &binaryDecorator{pythonInstaller: NewPythonInstaller("bin", "", module)}
module.bootstrapper = decorator
module.installer = decorator
diff --git a/python/installer.go b/python/installer.go
index 396f036..515cc47 100644
--- a/python/installer.go
+++ b/python/installer.go
@@ -36,12 +36,14 @@
path android.InstallPath
androidMkSharedLibs []string
+ module *Module
}
-func NewPythonInstaller(dir, dir64 string) *pythonInstaller {
+func NewPythonInstaller(dir, dir64 string, module *Module) *pythonInstaller {
return &pythonInstaller{
- dir: dir,
- dir64: dir64,
+ dir: dir,
+ dir64: dir64,
+ module: module,
}
}
@@ -59,7 +61,14 @@
}
func (installer *pythonInstaller) install(ctx android.ModuleContext, file android.Path) {
- installer.path = ctx.InstallFile(installer.installDir(ctx), file.Base(), file)
+ if ctx.ModuleType() == "python_binary_host" && installer.module.MixedBuildsEnabled(ctx) {
+ label := installer.module.BazelModuleBase.GetBazelLabel(ctx, installer.module)
+ binary, _ := ctx.Config().BazelContext.GetPythonBinary(label, android.GetConfigKey(ctx))
+ bazelBinaryOutPath := android.PathForBazelOut(ctx, binary)
+ installer.path = ctx.InstallFile(installer.installDir(ctx), bazelBinaryOutPath.Base(), bazelBinaryOutPath)
+ } else {
+ installer.path = ctx.InstallFile(installer.installDir(ctx), file.Base(), file)
+ }
}
func (installer *pythonInstaller) setAndroidMkSharedLibs(sharedLibs []string) {
diff --git a/python/test.go b/python/test.go
index 7413782..3cd900f 100644
--- a/python/test.go
+++ b/python/test.go
@@ -101,7 +101,7 @@
func NewTest(hod android.HostOrDeviceSupported) *Module {
module, binary := NewBinary(hod)
- binary.pythonInstaller = NewPythonInstaller("nativetest", "nativetest64")
+ binary.pythonInstaller = NewPythonInstaller("nativetest", "nativetest64", module)
test := &testDecorator{binaryDecorator: binary}
if hod == android.HostSupportedNoCross && test.testProperties.Test_options.Unit_test == nil {