Merge "Use classpath elements in platform_bootclasspath" am: 9d31361873
am: 5805a4f34a
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1738975 Change-Id: Ia072fc05e1f63b409ba8e837bd809af505b4f4e6
This commit is contained in:
@@ -43,22 +43,37 @@ type MonolithicHiddenAPIInfo struct {
|
||||
|
||||
// The paths to the generated all-flags.csv files.
|
||||
AllFlagsPaths android.Paths
|
||||
|
||||
// The classes jars from the libraries on the platform bootclasspath.
|
||||
ClassesJars android.Paths
|
||||
}
|
||||
|
||||
// newMonolithicHiddenAPIInfo creates a new MonolithicHiddenAPIInfo from the flagFilesByCategory
|
||||
// plus information provided by each of the fragments.
|
||||
func newMonolithicHiddenAPIInfo(ctx android.ModuleContext, flagFilesByCategory FlagFilesByCategory, fragments []android.Module) MonolithicHiddenAPIInfo {
|
||||
func newMonolithicHiddenAPIInfo(ctx android.ModuleContext, flagFilesByCategory FlagFilesByCategory, classpathElements ClasspathElements) MonolithicHiddenAPIInfo {
|
||||
monolithicInfo := MonolithicHiddenAPIInfo{}
|
||||
|
||||
monolithicInfo.FlagsFilesByCategory = flagFilesByCategory
|
||||
|
||||
// Merge all the information from the fragments. The fragments form a DAG so it is possible that
|
||||
// this will introduce duplicates so they will be resolved after processing all the fragments.
|
||||
for _, fragment := range fragments {
|
||||
if ctx.OtherModuleHasProvider(fragment, HiddenAPIInfoProvider) {
|
||||
info := ctx.OtherModuleProvider(fragment, HiddenAPIInfoProvider).(HiddenAPIInfo)
|
||||
monolithicInfo.append(&info)
|
||||
// Merge all the information from the classpathElements. The fragments form a DAG so it is possible that
|
||||
// this will introduce duplicates so they will be resolved after processing all the classpathElements.
|
||||
for _, element := range classpathElements {
|
||||
var classesJars android.Paths
|
||||
switch e := element.(type) {
|
||||
case *ClasspathLibraryElement:
|
||||
classesJars = retrieveClassesJarsFromModule(e.Module())
|
||||
|
||||
case *ClasspathFragmentElement:
|
||||
fragment := e.Module()
|
||||
if ctx.OtherModuleHasProvider(fragment, HiddenAPIInfoProvider) {
|
||||
info := ctx.OtherModuleProvider(fragment, HiddenAPIInfoProvider).(HiddenAPIInfo)
|
||||
monolithicInfo.append(&info)
|
||||
}
|
||||
|
||||
classesJars = extractClassesJarsFromModules(e.Contents)
|
||||
}
|
||||
|
||||
monolithicInfo.ClassesJars = append(monolithicInfo.ClassesJars, classesJars...)
|
||||
}
|
||||
|
||||
// Dedup paths.
|
||||
|
@@ -44,13 +44,9 @@ type platformBootclasspathModule struct {
|
||||
properties platformBootclasspathProperties
|
||||
|
||||
// The apex:module pairs obtained from the configured modules.
|
||||
//
|
||||
// Currently only for testing.
|
||||
configuredModules []android.Module
|
||||
|
||||
// The apex:module pairs obtained from the fragments.
|
||||
//
|
||||
// Currently only for testing.
|
||||
fragments []android.Module
|
||||
|
||||
// Path to the monolithic hiddenapi-flags.csv file.
|
||||
@@ -280,7 +276,15 @@ func (b *platformBootclasspathModule) generateHiddenAPIBuildActions(ctx android.
|
||||
return nil
|
||||
}
|
||||
|
||||
monolithicInfo := b.createAndProvideMonolithicHiddenAPIInfo(ctx, fragments)
|
||||
// Construct a list of ClasspathElement objects from the modules and fragments.
|
||||
classpathElements := CreateClasspathElements(ctx, modules, fragments)
|
||||
|
||||
monolithicInfo := b.createAndProvideMonolithicHiddenAPIInfo(ctx, classpathElements)
|
||||
|
||||
// Extract the classes jars only from those libraries that do not have corresponding fragments as
|
||||
// the fragments will have already provided the flags that are needed.
|
||||
classesJars := monolithicInfo.ClassesJars
|
||||
|
||||
// Create the input to pass to ruleToGenerateHiddenAPIStubFlagsFile
|
||||
input := newHiddenAPIFlagInput()
|
||||
|
||||
@@ -297,9 +301,6 @@ func (b *platformBootclasspathModule) generateHiddenAPIBuildActions(ctx android.
|
||||
rule := ruleToGenerateHiddenAPIStubFlagsFile(ctx, stubFlags, bootDexJarByModule.bootDexJars(), input)
|
||||
rule.Build("platform-bootclasspath-monolithic-hiddenapi-stub-flags", "monolithic hidden API stub flags")
|
||||
|
||||
// Extract the classes jars from the contents.
|
||||
classesJars := extractClassesJarsFromModules(modules)
|
||||
|
||||
// Generate the annotation-flags.csv file from all the module annotations.
|
||||
annotationFlags := android.PathForModuleOut(ctx, "hiddenapi-monolithic", "annotation-flags.csv")
|
||||
buildRuleToGenerateAnnotationFlags(ctx, "monolithic hiddenapi flags", classesJars, stubFlags, annotationFlags)
|
||||
@@ -329,7 +330,7 @@ func (b *platformBootclasspathModule) generateHiddenAPIBuildActions(ctx android.
|
||||
|
||||
// createAndProvideMonolithicHiddenAPIInfo creates a MonolithicHiddenAPIInfo and provides it for
|
||||
// testing.
|
||||
func (b *platformBootclasspathModule) createAndProvideMonolithicHiddenAPIInfo(ctx android.ModuleContext, fragments []android.Module) MonolithicHiddenAPIInfo {
|
||||
func (b *platformBootclasspathModule) createAndProvideMonolithicHiddenAPIInfo(ctx android.ModuleContext, classpathElements ClasspathElements) MonolithicHiddenAPIInfo {
|
||||
// Create a temporary input structure in which to collate information provided directly by this
|
||||
// module, either through properties or direct dependencies.
|
||||
temporaryInput := newHiddenAPIFlagInput()
|
||||
@@ -339,7 +340,7 @@ func (b *platformBootclasspathModule) createAndProvideMonolithicHiddenAPIInfo(ct
|
||||
|
||||
// Create the monolithic info, by starting with the flag files specified on this and then merging
|
||||
// in information from all the fragment dependencies of this.
|
||||
monolithicInfo := newMonolithicHiddenAPIInfo(ctx, temporaryInput.FlagFilesByCategory, fragments)
|
||||
monolithicInfo := newMonolithicHiddenAPIInfo(ctx, temporaryInput.FlagFilesByCategory, classpathElements)
|
||||
|
||||
// Store the information for testing.
|
||||
ctx.SetProvider(MonolithicHiddenAPIInfoProvider, monolithicInfo)
|
||||
|
Reference in New Issue
Block a user