From e20113d8ab84d0965d10df00832bac94cbd396f3 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Sun, 22 Nov 2020 19:37:44 -0800 Subject: [PATCH] Use local variations for python version splits Use a local variation for python version splits. This causes dependencies from python modules not to look for variations that match the version split, which will simplify a python module depending on a java module (for example for test data) because Soong won't look for a python version variant of the java module. Bug: 173977903 Test: go test ./python Change-Id: Ib034140c478ffbc7467ab830d3cfa5683c31d05c --- python/python.go | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/python/python.go b/python/python.go index e4c8e9481..770ea4d14 100644 --- a/python/python.go +++ b/python/python.go @@ -34,7 +34,7 @@ func init() { } func RegisterPythonPreDepsMutators(ctx android.RegisterMutatorsContext) { - ctx.BottomUp("version_split", versionSplitMutator()).Parallel() + ctx.BottomUp("python_version", versionSplitMutator()).Parallel() } // the version properties that apply to python libraries and binaries. @@ -248,7 +248,7 @@ func versionSplitMutator() func(android.BottomUpMutatorContext) { versionNames = append(versionNames, pyVersion2) versionProps = append(versionProps, base.properties.Version.Py2) } - modules := mctx.CreateVariations(versionNames...) + modules := mctx.CreateLocalVariations(versionNames...) if len(versionNames) > 0 { mctx.AliasVariation(versionNames[0]) } @@ -306,16 +306,20 @@ func (p *Module) hasSrcExt(ctx android.BottomUpMutatorContext, ext string) bool func (p *Module) DepsMutator(ctx android.BottomUpMutatorContext) { android.ProtoDeps(ctx, &p.protoProperties) - if p.hasSrcExt(ctx, protoExt) && p.Name() != "libprotobuf-python" { - ctx.AddVariationDependencies(nil, pythonLibTag, "libprotobuf-python") + versionVariation := []blueprint.Variation{ + {"python_version", p.properties.Actual_version}, } - ctx.AddVariationDependencies(nil, pythonLibTag, android.LastUniqueStrings(p.properties.Libs)...) + + if p.hasSrcExt(ctx, protoExt) && p.Name() != "libprotobuf-python" { + ctx.AddVariationDependencies(versionVariation, pythonLibTag, "libprotobuf-python") + } + ctx.AddVariationDependencies(versionVariation, pythonLibTag, android.LastUniqueStrings(p.properties.Libs)...) switch p.properties.Actual_version { case pyVersion2: if p.bootstrapper != nil && p.isEmbeddedLauncherEnabled() { - ctx.AddVariationDependencies(nil, pythonLibTag, "py2-stdlib") + ctx.AddVariationDependencies(versionVariation, pythonLibTag, "py2-stdlib") launcherModule := "py2-launcher" if p.bootstrapper.autorun() { @@ -338,7 +342,7 @@ func (p *Module) DepsMutator(ctx android.BottomUpMutatorContext) { case pyVersion3: if p.bootstrapper != nil && p.isEmbeddedLauncherEnabled() { - ctx.AddVariationDependencies(nil, pythonLibTag, "py3-stdlib") + ctx.AddVariationDependencies(versionVariation, pythonLibTag, "py3-stdlib") launcherModule := "py3-launcher" if p.bootstrapper.autorun() {