Add custom java_sdk_library info to the SDK info file
Previously the SDK info file only contained basic common information about each member. This change adds support for each member to provide custom information to add to the info file. It uses that mechanism to add the following: * "dist_stem" * "scopes" object containing: * for each scope a: "<scope>" object containing: * "current_api" - the path within the snapshot for the API's .txt file. * "removed_api" - the path within the snapshot for the removed API's .txt file. * "latest_api" - the path within the build to the latest finalized API .txt file. * "latest_removed_api" - the path within the build to the latest finalized removed API .txt file. In order to access the latest API files it was necessary to add and resolve dependencies on the module that makes them available. In order to do that safely the code for creating the names of the modules was refactored to avoid duplicating the name creation logic. Bug: 204763318 Test: m nothing Change-Id: Ica68abbd2b2c7c2b2b7877b502f96cc89f06fd68
This commit is contained in:
@@ -566,8 +566,9 @@ type moduleInfo struct {
|
||||
name string
|
||||
// A list of additional dependencies of the module.
|
||||
deps []string
|
||||
// Additional dynamic properties.
|
||||
dynamic map[string]interface{}
|
||||
// Additional member specific properties.
|
||||
// These will be added into the generated JSON alongside the above properties.
|
||||
memberSpecific map[string]interface{}
|
||||
}
|
||||
|
||||
func (m *moduleInfo) MarshalJSON() ([]byte, error) {
|
||||
@@ -590,8 +591,8 @@ func (m *moduleInfo) MarshalJSON() ([]byte, error) {
|
||||
if m.deps != nil {
|
||||
writeObjectPair("@deps", m.deps)
|
||||
}
|
||||
for _, k := range android.SortedStringKeys(m.dynamic) {
|
||||
v := m.dynamic[k]
|
||||
for _, k := range android.SortedStringKeys(m.memberSpecific) {
|
||||
v := m.memberSpecific[k]
|
||||
writeObjectPair(k, v)
|
||||
}
|
||||
buffer.WriteString("}")
|
||||
@@ -604,9 +605,9 @@ var _ json.Marshaler = (*moduleInfo)(nil)
|
||||
func (s *sdk) generateInfoData(ctx android.ModuleContext, memberVariantDeps []sdkMemberVariantDep) interface{} {
|
||||
modules := []*moduleInfo{}
|
||||
sdkInfo := moduleInfo{
|
||||
moduleType: "sdk",
|
||||
name: ctx.ModuleName(),
|
||||
dynamic: map[string]interface{}{},
|
||||
moduleType: "sdk",
|
||||
name: ctx.ModuleName(),
|
||||
memberSpecific: map[string]interface{}{},
|
||||
}
|
||||
modules = append(modules, &sdkInfo)
|
||||
|
||||
@@ -622,6 +623,10 @@ func (s *sdk) generateInfoData(ctx android.ModuleContext, memberVariantDeps []sd
|
||||
moduleType: moduleType,
|
||||
name: name,
|
||||
}
|
||||
|
||||
additionalSdkInfo := ctx.OtherModuleProvider(module, android.AdditionalSdkInfoProvider).(android.AdditionalSdkInfo)
|
||||
info.memberSpecific = additionalSdkInfo.Properties
|
||||
|
||||
name2Info[name] = info
|
||||
}
|
||||
return info
|
||||
@@ -630,13 +635,13 @@ func (s *sdk) generateInfoData(ctx android.ModuleContext, memberVariantDeps []sd
|
||||
for _, memberVariantDep := range memberVariantDeps {
|
||||
propertyName := memberVariantDep.memberType.SdkPropertyName()
|
||||
var list []string
|
||||
if v, ok := sdkInfo.dynamic[propertyName]; ok {
|
||||
if v, ok := sdkInfo.memberSpecific[propertyName]; ok {
|
||||
list = v.([]string)
|
||||
}
|
||||
|
||||
memberName := memberVariantDep.variant.Name()
|
||||
list = append(list, memberName)
|
||||
sdkInfo.dynamic[propertyName] = android.SortedUniqueStrings(list)
|
||||
sdkInfo.memberSpecific[propertyName] = android.SortedUniqueStrings(list)
|
||||
|
||||
if memberVariantDep.container != nil {
|
||||
containerInfo := getModuleInfo(memberVariantDep.container)
|
||||
@@ -1217,6 +1222,7 @@ type snapshotBuilder struct {
|
||||
// The target build release for which the snapshot is to be generated.
|
||||
targetBuildRelease *buildRelease
|
||||
|
||||
// The contents of the .info file that describes the sdk contents.
|
||||
infoContents string
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user