Merge changes I0f2f0e41,Ib034140c,I4b2ca283
* changes: Add java_data parameter to python modules Use local variations for python version splits Support SourceFileProducer in android.OutputFilesForModule
This commit is contained in:
commit
d2d8fd6f51
|
@ -2578,6 +2578,15 @@ func outputFilesForModule(ctx PathContext, module blueprint.Module, tag string)
|
|||
return nil, fmt.Errorf("failed to get output files from module %q", pathContextName(ctx, module))
|
||||
}
|
||||
return paths, nil
|
||||
} else if sourceFileProducer, ok := module.(SourceFileProducer); ok {
|
||||
if tag != "" {
|
||||
return nil, fmt.Errorf("module %q is a SourceFileProducer, not an OutputFileProducer, and so does not support tag %q", pathContextName(ctx, module), tag)
|
||||
}
|
||||
paths := sourceFileProducer.Srcs()
|
||||
if len(paths) == 0 {
|
||||
return nil, fmt.Errorf("failed to get output files from module %q", pathContextName(ctx, module))
|
||||
}
|
||||
return paths, nil
|
||||
} else {
|
||||
return nil, fmt.Errorf("module %q is not an OutputFileProducer", pathContextName(ctx, module))
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
@ -86,6 +86,9 @@ type BaseProperties struct {
|
|||
// the test. the file extension can be arbitrary except for (.py).
|
||||
Data []string `android:"path,arch_variant"`
|
||||
|
||||
// list of java modules that provide data that should be installed alongside the test.
|
||||
Java_data []string
|
||||
|
||||
// list of the Python libraries compatible both with Python2 and Python3.
|
||||
Libs []string `android:"arch_variant"`
|
||||
|
||||
|
@ -216,6 +219,7 @@ type dependencyTag struct {
|
|||
|
||||
var (
|
||||
pythonLibTag = dependencyTag{name: "pythonLib"}
|
||||
javaDataTag = dependencyTag{name: "javaData"}
|
||||
launcherTag = dependencyTag{name: "launcher"}
|
||||
launcherSharedLibTag = dependencyTag{name: "launcherSharedLib"}
|
||||
pyIdentifierRegexp = regexp.MustCompile(`^[a-zA-Z_][a-zA-Z0-9_-]*$`)
|
||||
|
@ -248,7 +252,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 +310,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 +346,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() {
|
||||
|
@ -366,6 +374,11 @@ func (p *Module) DepsMutator(ctx android.BottomUpMutatorContext) {
|
|||
panic(fmt.Errorf("unknown Python Actual_version: %q for module: %q.",
|
||||
p.properties.Actual_version, ctx.ModuleName()))
|
||||
}
|
||||
|
||||
// Emulate the data property for java_data but with the arch variation overridden to "common"
|
||||
// so that it can point to java modules.
|
||||
javaDataVariation := []blueprint.Variation{{"arch", android.Common.String()}}
|
||||
ctx.AddVariationDependencies(javaDataVariation, javaDataTag, p.properties.Java_data...)
|
||||
}
|
||||
|
||||
func (p *Module) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
|
@ -412,6 +425,11 @@ func (p *Module) GeneratePythonBuildActions(ctx android.ModuleContext) {
|
|||
// expand data files from "data" property.
|
||||
expandedData := android.PathsForModuleSrc(ctx, p.properties.Data)
|
||||
|
||||
// Emulate the data property for java_data dependencies.
|
||||
for _, javaData := range ctx.GetDirectDepsWithTag(javaDataTag) {
|
||||
expandedData = append(expandedData, android.OutputFilesForModule(ctx, javaData, "")...)
|
||||
}
|
||||
|
||||
// sanitize pkg_path.
|
||||
pkgPath := String(p.properties.Pkg_path)
|
||||
if pkgPath != "" {
|
||||
|
|
|
@ -45,6 +45,9 @@ type TestProperties struct {
|
|||
// the test
|
||||
Data []string `android:"path,arch_variant"`
|
||||
|
||||
// list of java modules that provide data that should be installed alongside the test.
|
||||
Java_data []string
|
||||
|
||||
// Test options.
|
||||
Test_options TestOptions
|
||||
}
|
||||
|
@ -80,6 +83,13 @@ func (test *testDecorator) install(ctx android.ModuleContext, file android.Path)
|
|||
for _, dataSrcPath := range dataSrcPaths {
|
||||
test.data = append(test.data, android.DataPath{SrcPath: dataSrcPath})
|
||||
}
|
||||
|
||||
// Emulate the data property for java_data dependencies.
|
||||
for _, javaData := range ctx.GetDirectDepsWithTag(javaDataTag) {
|
||||
for _, javaDataSrcPath := range android.OutputFilesForModule(ctx, javaData, "") {
|
||||
test.data = append(test.data, android.DataPath{SrcPath: javaDataSrcPath})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func NewTest(hod android.HostOrDeviceSupported) *Module {
|
||||
|
|
Loading…
Reference in New Issue