summaryrefslogtreecommitdiff
path: root/sdk/update.go
diff options
context:
space:
mode:
author Sam Delmerico <delmerico@google.com> 2023-06-30 14:40:10 -0400
committer Sam Delmerico <delmerico@google.com> 2023-06-30 15:25:16 -0400
commit35881365b49235b2311f48bfcbaff8f873f19b88 (patch)
tree9925d40e1320aada2107e4bf93468e3e3a4db90a /sdk/update.go
parenta56663f6954de78f82d7862c2e86bb1932e6c6da (diff)
don't export systemserverclasspath_fragment if contents are empty
If a systemserverclasspath_fragment only contains libraries that have a higher min_sdk_version than the target build release version, then we should not export the systemserverclasspath_fragment. Before this change, the fragment was exported with an empty `contents` property which caused errors after being dropped as a prebuilt. Bug: 289183551 Test: go test ./sdk Change-Id: Ifefc6880228e4dd37f5e42b2bda31a83df785375
Diffstat (limited to 'sdk/update.go')
-rw-r--r--sdk/update.go36
1 files changed, 30 insertions, 6 deletions
diff --git a/sdk/update.go b/sdk/update.go
index d3c59b0e4..4c39faea1 100644
--- a/sdk/update.go
+++ b/sdk/update.go
@@ -455,11 +455,14 @@ be unnecessary as every module in the sdk already has its own licenses property.
for _, module := range builder.prebuiltOrder {
// Prune any empty property sets.
- module = module.transform(pruneEmptySetTransformer{})
+ module = transformModule(module, pruneEmptySetTransformer{})
// Transform the module module to make it suitable for use in the snapshot.
- module.transform(snapshotTransformer)
- bpFile.AddModule(module)
+ module = transformModule(module, snapshotTransformer)
+ module = transformModule(module, emptyClasspathContentsTransformation{})
+ if module != nil {
+ bpFile.AddModule(module)
+ }
}
// generate Android.bp
@@ -835,9 +838,11 @@ type snapshotTransformation struct {
}
func (t snapshotTransformation) transformModule(module *bpModule) *bpModule {
- // If the module is an internal member then use a unique name for it.
- name := module.Name()
- module.setProperty("name", t.builder.snapshotSdkMemberName(name, true))
+ if module != nil {
+ // If the module is an internal member then use a unique name for it.
+ name := module.Name()
+ module.setProperty("name", t.builder.snapshotSdkMemberName(name, true))
+ }
return module
}
@@ -850,6 +855,25 @@ func (t snapshotTransformation) transformProperty(_ string, value interface{}, t
}
}
+type emptyClasspathContentsTransformation struct {
+ identityTransformation
+}
+
+func (t emptyClasspathContentsTransformation) transformModule(module *bpModule) *bpModule {
+ classpathModuleTypes := []string{
+ "prebuilt_bootclasspath_fragment",
+ "prebuilt_systemserverclasspath_fragment",
+ }
+ if module != nil && android.InList(module.moduleType, classpathModuleTypes) {
+ if contents, ok := module.bpPropertySet.properties["contents"].([]string); ok {
+ if len(contents) == 0 {
+ return nil
+ }
+ }
+ }
+ return module
+}
+
type pruneEmptySetTransformer struct {
identityTransformation
}