Merge "Remove javalib special case in createDeapexerModuleIfNeeded"
This commit is contained in:
commit
6b592bdcdc
5 changed files with 50 additions and 10 deletions
|
@ -128,3 +128,12 @@ type RequiredFilesFromPrebuiltApex interface {
|
||||||
// can then be retrieved using the PrebuiltExportPath(name, tag) method.
|
// can then be retrieved using the PrebuiltExportPath(name, tag) method.
|
||||||
RequiredFilesFromPrebuiltApex(ctx BaseModuleContext) map[string]string
|
RequiredFilesFromPrebuiltApex(ctx BaseModuleContext) map[string]string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Marker interface that identifies dependencies on modules that may require files from a prebuilt
|
||||||
|
// apex.
|
||||||
|
type RequiresFilesFromPrebuiltApexTag interface {
|
||||||
|
blueprint.DependencyTag
|
||||||
|
|
||||||
|
// Method that differentiates this interface from others.
|
||||||
|
RequiresFilesFromPrebuiltApex()
|
||||||
|
}
|
||||||
|
|
|
@ -17,7 +17,6 @@ package apex
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"path/filepath"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
@ -560,15 +559,13 @@ func createDeapexerModuleIfNeeded(ctx android.TopDownMutatorContext, deapexerNam
|
||||||
ctx.WalkDeps(func(child, parent android.Module) bool {
|
ctx.WalkDeps(func(child, parent android.Module) bool {
|
||||||
tag := ctx.OtherModuleDependencyTag(child)
|
tag := ctx.OtherModuleDependencyTag(child)
|
||||||
|
|
||||||
|
// If the child is not in the same apex as the parent then ignore it and all its children.
|
||||||
|
if !android.IsDepInSameApex(ctx, parent, child) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
name := android.RemoveOptionalPrebuiltPrefix(ctx.OtherModuleName(child))
|
name := android.RemoveOptionalPrebuiltPrefix(ctx.OtherModuleName(child))
|
||||||
if java.IsBootclasspathFragmentContentDepTag(tag) || tag == exportedJavaLibTag {
|
if _, ok := tag.(android.RequiresFilesFromPrebuiltApexTag); ok {
|
||||||
commonModules = append(commonModules, name)
|
|
||||||
|
|
||||||
// Add the dex implementation jar to the set of exported files. The path here must match the
|
|
||||||
// path of the file in the APEX created by apexFileForJavaModule(...).
|
|
||||||
exportedFilesByKey[name+"{.dexjar}"] = filepath.Join("javalib", name+".jar")
|
|
||||||
|
|
||||||
} else if tag == exportedBootclasspathFragmentTag {
|
|
||||||
commonModules = append(commonModules, name)
|
commonModules = append(commonModules, name)
|
||||||
|
|
||||||
requiredFiles := child.(android.RequiredFilesFromPrebuiltApex).RequiredFilesFromPrebuiltApex(ctx)
|
requiredFiles := child.(android.RequiredFilesFromPrebuiltApex).RequiredFilesFromPrebuiltApex(ctx)
|
||||||
|
@ -583,7 +580,8 @@ func createDeapexerModuleIfNeeded(ctx android.TopDownMutatorContext, deapexerNam
|
||||||
requiringModulesByKey[k] = child
|
requiringModulesByKey[k] = child
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure to visit the children of the bootclasspath_fragment.
|
// Visit the dependencies of this module just in case they also require files from the
|
||||||
|
// prebuilt apex.
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -660,6 +658,10 @@ type exportedDependencyTag struct {
|
||||||
// incorrectly.
|
// incorrectly.
|
||||||
func (t exportedDependencyTag) ExcludeFromVisibilityEnforcement() {}
|
func (t exportedDependencyTag) ExcludeFromVisibilityEnforcement() {}
|
||||||
|
|
||||||
|
func (t exportedDependencyTag) RequiresFilesFromPrebuiltApex() {}
|
||||||
|
|
||||||
|
var _ android.RequiresFilesFromPrebuiltApexTag = exportedDependencyTag{}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
exportedJavaLibTag = exportedDependencyTag{name: "exported_java_libs"}
|
exportedJavaLibTag = exportedDependencyTag{name: "exported_java_libs"}
|
||||||
exportedBootclasspathFragmentTag = exportedDependencyTag{name: "exported_bootclasspath_fragments"}
|
exportedBootclasspathFragmentTag = exportedDependencyTag{name: "exported_bootclasspath_fragments"}
|
||||||
|
|
|
@ -81,6 +81,9 @@ func (b bootclasspathFragmentContentDependencyTag) ExportMember() bool {
|
||||||
// they were listed in java_libs.
|
// they were listed in java_libs.
|
||||||
func (b bootclasspathFragmentContentDependencyTag) CopyDirectlyInAnyApex() {}
|
func (b bootclasspathFragmentContentDependencyTag) CopyDirectlyInAnyApex() {}
|
||||||
|
|
||||||
|
// Contents of bootclasspath fragments require files from prebuilt apex files.
|
||||||
|
func (b bootclasspathFragmentContentDependencyTag) RequiresFilesFromPrebuiltApex() {}
|
||||||
|
|
||||||
// The tag used for the dependency between the bootclasspath_fragment module and its contents.
|
// The tag used for the dependency between the bootclasspath_fragment module and its contents.
|
||||||
var bootclasspathFragmentContentDepTag = bootclasspathFragmentContentDependencyTag{}
|
var bootclasspathFragmentContentDepTag = bootclasspathFragmentContentDependencyTag{}
|
||||||
|
|
||||||
|
@ -88,6 +91,7 @@ var _ android.ExcludeFromVisibilityEnforcementTag = bootclasspathFragmentContent
|
||||||
var _ android.ReplaceSourceWithPrebuilt = bootclasspathFragmentContentDepTag
|
var _ android.ReplaceSourceWithPrebuilt = bootclasspathFragmentContentDepTag
|
||||||
var _ android.SdkMemberTypeDependencyTag = bootclasspathFragmentContentDepTag
|
var _ android.SdkMemberTypeDependencyTag = bootclasspathFragmentContentDepTag
|
||||||
var _ android.CopyDirectlyInAnyApexTag = bootclasspathFragmentContentDepTag
|
var _ android.CopyDirectlyInAnyApexTag = bootclasspathFragmentContentDepTag
|
||||||
|
var _ android.RequiresFilesFromPrebuiltApexTag = bootclasspathFragmentContentDepTag
|
||||||
|
|
||||||
func IsBootclasspathFragmentContentDepTag(tag blueprint.DependencyTag) bool {
|
func IsBootclasspathFragmentContentDepTag(tag blueprint.DependencyTag) bool {
|
||||||
return tag == bootclasspathFragmentContentDepTag
|
return tag == bootclasspathFragmentContentDepTag
|
||||||
|
|
18
java/java.go
18
java/java.go
|
@ -1426,6 +1426,24 @@ func (j *Import) ShouldSupportSdkVersion(ctx android.BaseModuleContext,
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// requiredFilesFromPrebuiltApexForImport returns information about the files that a java_import or
|
||||||
|
// java_sdk_library_import with the specified base module name requires to be exported from a
|
||||||
|
// prebuilt_apex/apex_set.
|
||||||
|
func requiredFilesFromPrebuiltApexForImport(name string) map[string]string {
|
||||||
|
// Add the dex implementation jar to the set of exported files. The path here must match the
|
||||||
|
// path of the file in the APEX created by apexFileForJavaModule(...).
|
||||||
|
return map[string]string{
|
||||||
|
name + "{.dexjar}": filepath.Join("javalib", name+".jar"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var _ android.RequiredFilesFromPrebuiltApex = (*Import)(nil)
|
||||||
|
|
||||||
|
func (j *Import) RequiredFilesFromPrebuiltApex(ctx android.BaseModuleContext) map[string]string {
|
||||||
|
name := j.BaseModuleName()
|
||||||
|
return requiredFilesFromPrebuiltApexForImport(name)
|
||||||
|
}
|
||||||
|
|
||||||
// Add compile time check for interface implementation
|
// Add compile time check for interface implementation
|
||||||
var _ android.IDEInfo = (*Import)(nil)
|
var _ android.IDEInfo = (*Import)(nil)
|
||||||
var _ android.IDECustomizedModuleName = (*Import)(nil)
|
var _ android.IDECustomizedModuleName = (*Import)(nil)
|
||||||
|
|
|
@ -2269,6 +2269,13 @@ func (module *SdkLibraryImport) ImplementationAndResourcesJars() android.Paths {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ android.RequiredFilesFromPrebuiltApex = (*SdkLibraryImport)(nil)
|
||||||
|
|
||||||
|
func (module *SdkLibraryImport) RequiredFilesFromPrebuiltApex(ctx android.BaseModuleContext) map[string]string {
|
||||||
|
name := module.BaseModuleName()
|
||||||
|
return requiredFilesFromPrebuiltApexForImport(name)
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// java_sdk_library_xml
|
// java_sdk_library_xml
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in a new issue