<Hermetic> Replace Soong Python bootstrap process with embedded
launcher.
For Python2, we bundle embedded launcher as bootstrapper within every
.par file. This feature is only enabled for linux_x86_64 for now. We
provide a user flag: hermetic_enabled within bp file. By default, Pyhon2
still use classic bootstrapping way to construct .par file and relys on
host interpreter. Once embedded_launcher is enabled, launcher will be
used to bootstrap .par file and execute user program.
For Python3, the launcher will be ready soon, and for now it still relys
on classic bootstrapping.
Test: Real example is used to test.
Bug: b/63018041
Change-Id: I28deba413d8ad3af407595e46f77d663e79a3705
diff --git a/python/test.go b/python/test.go
index 837eb25..de2b13e 100644
--- a/python/test.go
+++ b/python/test.go
@@ -16,7 +16,6 @@
import (
"android/soong/android"
- "path/filepath"
)
// This file contains the module types for building Python test.
@@ -25,30 +24,29 @@
android.RegisterModuleType("python_test_host", PythonTestHostFactory)
}
-type PythonTestHost struct {
- pythonBinaryBase
+type testDecorator struct {
+ *binaryDecorator
}
-var _ PythonSubModule = (*PythonTestHost)(nil)
-
-type pythonTestHostDecorator struct {
- pythonDecorator
+func (test *testDecorator) install(ctx android.ModuleContext, file android.Path) {
+ test.binaryDecorator.baseInstaller.install(ctx, file)
}
-func (p *pythonTestHostDecorator) install(ctx android.ModuleContext, file android.Path) {
- p.pythonDecorator.baseInstaller.dir = filepath.Join("nativetest", ctx.ModuleName())
- p.pythonDecorator.baseInstaller.install(ctx, file)
+func NewTest(hod android.HostOrDeviceSupported) *Module {
+ module, binary := NewBinary(hod)
+
+ binary.baseInstaller = NewPythonInstaller("nativetest")
+
+ test := &testDecorator{binaryDecorator: binary}
+
+ module.bootstrapper = test
+ module.installer = test
+
+ return module
}
func PythonTestHostFactory() android.Module {
- decorator := &pythonTestHostDecorator{
- pythonDecorator: pythonDecorator{baseInstaller: NewPythonInstaller("nativetest")}}
+ module := NewTest(android.HostSupportedNoCross)
- module := &PythonBinaryHost{}
- module.pythonBaseModule.installer = decorator
-
- module.AddProperties(&module.binaryProperties)
-
- return InitPythonBaseModule(&module.pythonBinaryBase.pythonBaseModule,
- &module.pythonBinaryBase, android.HostSupportedNoCross)
+ return module.Init()
}