Revert "Dynamically assemble the list of python launcher shared libs for precompiling"
This reverts commit aa5b377ee9
.
Reason for revert: this broke musl builds by removing the install dependency from python binaries to the launcher shared libraries: https://android-build.googleplex.com/builds/submitted/9600042/unit_tests_x86_64_musl/latest/view/logs/build_error.log
Change-Id: I4e13f333f287831ba13724f13ab2be789a92b476
This commit is contained in:
parent
aa5b377ee9
commit
909d237c84
3 changed files with 58 additions and 49 deletions
|
@ -73,10 +73,6 @@ func (p *PackagingSpec) Partition() string {
|
||||||
return p.partition
|
return p.partition
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PackagingSpec) SrcPath() Path {
|
|
||||||
return p.srcPath
|
|
||||||
}
|
|
||||||
|
|
||||||
type PackageModule interface {
|
type PackageModule interface {
|
||||||
Module
|
Module
|
||||||
packagingBase() *PackagingBase
|
packagingBase() *PackagingBase
|
||||||
|
|
|
@ -125,25 +125,6 @@ func (p *PythonBinaryModule) buildBinary(ctx android.ModuleContext) {
|
||||||
launcherPath = provider.IntermPathForModuleOut()
|
launcherPath = provider.IntermPathForModuleOut()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// TODO: get the list of shared libraries directly from the launcher module somehow
|
|
||||||
var sharedLibs []string
|
|
||||||
sharedLibs = append(sharedLibs, "libsqlite")
|
|
||||||
if ctx.Target().Os.Bionic() {
|
|
||||||
sharedLibs = append(sharedLibs, "libc", "libdl", "libm")
|
|
||||||
}
|
|
||||||
if ctx.Target().Os == android.LinuxMusl && !ctx.Config().HostStaticBinaries() {
|
|
||||||
sharedLibs = append(sharedLibs, "libc_musl")
|
|
||||||
}
|
|
||||||
switch p.properties.Actual_version {
|
|
||||||
case pyVersion2:
|
|
||||||
sharedLibs = append(sharedLibs, "libc++")
|
|
||||||
case pyVersion3:
|
|
||||||
if ctx.Device() {
|
|
||||||
sharedLibs = append(sharedLibs, "liblog")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
p.androidMkSharedLibs = sharedLibs
|
|
||||||
}
|
}
|
||||||
srcsZips := make(android.Paths, 0, len(depsSrcsZips)+1)
|
srcsZips := make(android.Paths, 0, len(depsSrcsZips)+1)
|
||||||
if embeddedLauncher {
|
if embeddedLauncher {
|
||||||
|
@ -155,6 +136,14 @@ func (p *PythonBinaryModule) buildBinary(ctx android.ModuleContext) {
|
||||||
p.installSource = registerBuildActionForParFile(ctx, embeddedLauncher, launcherPath,
|
p.installSource = registerBuildActionForParFile(ctx, embeddedLauncher, launcherPath,
|
||||||
p.getHostInterpreterName(ctx, p.properties.Actual_version),
|
p.getHostInterpreterName(ctx, p.properties.Actual_version),
|
||||||
main, p.getStem(ctx), srcsZips)
|
main, p.getStem(ctx), srcsZips)
|
||||||
|
|
||||||
|
var sharedLibs []string
|
||||||
|
// if embedded launcher is enabled, we need to collect the shared library dependencies of the
|
||||||
|
// launcher
|
||||||
|
for _, dep := range ctx.GetDirectDepsWithTag(launcherSharedLibTag) {
|
||||||
|
sharedLibs = append(sharedLibs, ctx.OtherModuleName(dep))
|
||||||
|
}
|
||||||
|
p.androidMkSharedLibs = sharedLibs
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PythonBinaryModule) AndroidMkEntries() []android.AndroidMkEntries {
|
func (p *PythonBinaryModule) AndroidMkEntries() []android.AndroidMkEntries {
|
||||||
|
@ -187,7 +176,7 @@ func (p *PythonBinaryModule) DepsMutator(ctx android.BottomUpMutatorContext) {
|
||||||
p.PythonLibraryModule.DepsMutator(ctx)
|
p.PythonLibraryModule.DepsMutator(ctx)
|
||||||
|
|
||||||
if p.isEmbeddedLauncherEnabled() {
|
if p.isEmbeddedLauncherEnabled() {
|
||||||
p.AddDepsOnPythonLauncherAndStdlib(ctx, pythonLibTag, launcherTag, p.autorun(), ctx.Target())
|
p.AddDepsOnPythonLauncherAndStdlib(ctx, pythonLibTag, launcherTag, launcherSharedLibTag, p.autorun(), ctx.Target())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -226,18 +226,20 @@ var (
|
||||||
pythonLibTag = dependencyTag{name: "pythonLib"}
|
pythonLibTag = dependencyTag{name: "pythonLib"}
|
||||||
javaDataTag = dependencyTag{name: "javaData"}
|
javaDataTag = dependencyTag{name: "javaData"}
|
||||||
// The python interpreter, with soong module name "py3-launcher" or "py3-launcher-autorun".
|
// The python interpreter, with soong module name "py3-launcher" or "py3-launcher-autorun".
|
||||||
launcherTag = dependencyTag{name: "launcher"}
|
launcherTag = dependencyTag{name: "launcher"}
|
||||||
|
launcherSharedLibTag = installDependencyTag{name: "launcherSharedLib"}
|
||||||
// The python interpreter built for host so that we can precompile python sources.
|
// The python interpreter built for host so that we can precompile python sources.
|
||||||
// This only works because the precompiled sources don't vary by architecture.
|
// This only works because the precompiled sources don't vary by architecture.
|
||||||
// The soong module name is "py3-launcher".
|
// The soong module name is "py3-launcher".
|
||||||
hostLauncherTag = dependencyTag{name: "hostLauncher"}
|
hostLauncherTag = dependencyTag{name: "hostLauncher"}
|
||||||
hostStdLibTag = dependencyTag{name: "hostStdLib"}
|
hostlauncherSharedLibTag = dependencyTag{name: "hostlauncherSharedLib"}
|
||||||
pathComponentRegexp = regexp.MustCompile(`^[a-zA-Z_][a-zA-Z0-9_-]*$`)
|
hostStdLibTag = dependencyTag{name: "hostStdLib"}
|
||||||
pyExt = ".py"
|
pathComponentRegexp = regexp.MustCompile(`^[a-zA-Z_][a-zA-Z0-9_-]*$`)
|
||||||
protoExt = ".proto"
|
pyExt = ".py"
|
||||||
pyVersion2 = "PY2"
|
protoExt = ".proto"
|
||||||
pyVersion3 = "PY3"
|
pyVersion2 = "PY2"
|
||||||
internalPath = "internal"
|
pyVersion3 = "PY3"
|
||||||
|
internalPath = "internal"
|
||||||
)
|
)
|
||||||
|
|
||||||
type basePropertiesProvider interface {
|
type basePropertiesProvider interface {
|
||||||
|
@ -321,21 +323,35 @@ func (p *PythonLibraryModule) DepsMutator(ctx android.BottomUpMutatorContext) {
|
||||||
javaDataVariation := []blueprint.Variation{{"arch", android.Common.String()}}
|
javaDataVariation := []blueprint.Variation{{"arch", android.Common.String()}}
|
||||||
ctx.AddVariationDependencies(javaDataVariation, javaDataTag, p.properties.Java_data...)
|
ctx.AddVariationDependencies(javaDataVariation, javaDataTag, p.properties.Java_data...)
|
||||||
|
|
||||||
p.AddDepsOnPythonLauncherAndStdlib(ctx, hostStdLibTag, hostLauncherTag, false, ctx.Config().BuildOSTarget)
|
p.AddDepsOnPythonLauncherAndStdlib(ctx, hostStdLibTag, hostLauncherTag, hostlauncherSharedLibTag, false, ctx.Config().BuildOSTarget)
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddDepsOnPythonLauncherAndStdlib will make the current module depend on the python stdlib
|
// AddDepsOnPythonLauncherAndStdlib will make the current module depend on the python stdlib,
|
||||||
// and launcher (interpreter). If autorun is true, it will use the autorun launcher instead of the
|
// launcher (interpreter), and the launcher's shared libraries. If autorun is true, it will use
|
||||||
// regular one. This function accepts a targetForDeps argument as the target to use for these
|
// the autorun launcher instead of the regular one. This function acceps a targetForDeps argument
|
||||||
// dependencies. For embedded launcher python binaries, the launcher that will be embedded will be
|
// as the target to use for these dependencies. For embedded launcher python binaries, the launcher
|
||||||
// under the same target as the python module itself. But when precompiling python code, we need to
|
// that will be embedded will be under the same target as the python module itself. But when
|
||||||
// get the python launcher built for host, even if we're compiling the python module for device, so
|
// precompiling python code, we need to get the python launcher built for host, even if we're
|
||||||
// we pass a different target to this function.
|
// compiling the python module for device, so we pass a different target to this function.
|
||||||
func (p *PythonLibraryModule) AddDepsOnPythonLauncherAndStdlib(ctx android.BottomUpMutatorContext,
|
func (p *PythonLibraryModule) AddDepsOnPythonLauncherAndStdlib(ctx android.BottomUpMutatorContext,
|
||||||
stdLibTag, launcherTag blueprint.DependencyTag,
|
stdLibTag, launcherTag, launcherSharedLibTag blueprint.DependencyTag,
|
||||||
autorun bool, targetForDeps android.Target) {
|
autorun bool, targetForDeps android.Target) {
|
||||||
var stdLib string
|
var stdLib string
|
||||||
var launcherModule string
|
var launcherModule string
|
||||||
|
// Add launcher shared lib dependencies. Ideally, these should be
|
||||||
|
// derived from the `shared_libs` property of the launcher. TODO: read these from
|
||||||
|
// the python launcher itself using ctx.OtherModuleProvider() or similar on the result
|
||||||
|
// of ctx.AddFarVariationDependencies()
|
||||||
|
launcherSharedLibDeps := []string{
|
||||||
|
"libsqlite",
|
||||||
|
}
|
||||||
|
// Add launcher-specific dependencies for bionic
|
||||||
|
if targetForDeps.Os.Bionic() {
|
||||||
|
launcherSharedLibDeps = append(launcherSharedLibDeps, "libc", "libdl", "libm")
|
||||||
|
}
|
||||||
|
if targetForDeps.Os == android.LinuxMusl && !ctx.Config().HostStaticBinaries() {
|
||||||
|
launcherSharedLibDeps = append(launcherSharedLibDeps, "libc_musl")
|
||||||
|
}
|
||||||
|
|
||||||
switch p.properties.Actual_version {
|
switch p.properties.Actual_version {
|
||||||
case pyVersion2:
|
case pyVersion2:
|
||||||
|
@ -346,6 +362,7 @@ func (p *PythonLibraryModule) AddDepsOnPythonLauncherAndStdlib(ctx android.Botto
|
||||||
launcherModule = "py2-launcher-autorun"
|
launcherModule = "py2-launcher-autorun"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
launcherSharedLibDeps = append(launcherSharedLibDeps, "libc++")
|
||||||
case pyVersion3:
|
case pyVersion3:
|
||||||
stdLib = "py3-stdlib"
|
stdLib = "py3-stdlib"
|
||||||
|
|
||||||
|
@ -356,6 +373,9 @@ func (p *PythonLibraryModule) AddDepsOnPythonLauncherAndStdlib(ctx android.Botto
|
||||||
if ctx.Config().HostStaticBinaries() && targetForDeps.Os == android.LinuxMusl {
|
if ctx.Config().HostStaticBinaries() && targetForDeps.Os == android.LinuxMusl {
|
||||||
launcherModule += "-static"
|
launcherModule += "-static"
|
||||||
}
|
}
|
||||||
|
if ctx.Device() {
|
||||||
|
launcherSharedLibDeps = append(launcherSharedLibDeps, "liblog")
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
panic(fmt.Errorf("unknown Python Actual_version: %q for module: %q.",
|
panic(fmt.Errorf("unknown Python Actual_version: %q for module: %q.",
|
||||||
p.properties.Actual_version, ctx.ModuleName()))
|
p.properties.Actual_version, ctx.ModuleName()))
|
||||||
|
@ -371,6 +391,7 @@ func (p *PythonLibraryModule) AddDepsOnPythonLauncherAndStdlib(ctx android.Botto
|
||||||
ctx.AddFarVariationDependencies(stdLibVariations, stdLibTag, stdLib)
|
ctx.AddFarVariationDependencies(stdLibVariations, stdLibTag, stdLib)
|
||||||
}
|
}
|
||||||
ctx.AddFarVariationDependencies(targetVariations, launcherTag, launcherModule)
|
ctx.AddFarVariationDependencies(targetVariations, launcherTag, launcherModule)
|
||||||
|
ctx.AddFarVariationDependencies(targetVariations, launcherSharedLibTag, launcherSharedLibDeps...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GenerateAndroidBuildActions performs build actions common to all Python modules
|
// GenerateAndroidBuildActions performs build actions common to all Python modules
|
||||||
|
@ -574,19 +595,22 @@ func (p *PythonLibraryModule) precompileSrcs(ctx android.ModuleContext) android.
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
var launcherSharedLibs android.Paths
|
|
||||||
var ldLibraryPath []string
|
|
||||||
ctx.VisitDirectDepsWithTag(hostLauncherTag, func(module android.Module) {
|
ctx.VisitDirectDepsWithTag(hostLauncherTag, func(module android.Module) {
|
||||||
if dep, ok := module.(IntermPathProvider); ok {
|
if dep, ok := module.(IntermPathProvider); ok {
|
||||||
optionalLauncher := dep.IntermPathForModuleOut()
|
optionalLauncher := dep.IntermPathForModuleOut()
|
||||||
if optionalLauncher.Valid() {
|
if optionalLauncher.Valid() {
|
||||||
launcher = optionalLauncher.Path()
|
launcher = optionalLauncher.Path()
|
||||||
}
|
}
|
||||||
for _, spec := range module.TransitivePackagingSpecs() {
|
}
|
||||||
if strings.HasSuffix(spec.SrcPath().String(), ".so") {
|
})
|
||||||
launcherSharedLibs = append(launcherSharedLibs, spec.SrcPath())
|
var launcherSharedLibs android.Paths
|
||||||
ldLibraryPath = append(ldLibraryPath, filepath.Dir(spec.SrcPath().String()))
|
var ldLibraryPath []string
|
||||||
}
|
ctx.VisitDirectDepsWithTag(hostlauncherSharedLibTag, func(module android.Module) {
|
||||||
|
if dep, ok := module.(IntermPathProvider); ok {
|
||||||
|
optionalPath := dep.IntermPathForModuleOut()
|
||||||
|
if optionalPath.Valid() {
|
||||||
|
launcherSharedLibs = append(launcherSharedLibs, optionalPath.Path())
|
||||||
|
ldLibraryPath = append(ldLibraryPath, filepath.Dir(optionalPath.Path().String()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue