Merge changes Iecf7edd6,Iaca5cf23,I01d57919 am: 8a0dd0265b am: 87feed1f91 am: 68527d510f

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1901600

Change-Id: Ie7261e5c9a165d83e9b4858f1c83a56d35b6094d
This commit is contained in:
Treehugger Robot
2021-11-25 13:06:34 +00:00
committed by Automerger Merge Worker
2 changed files with 14 additions and 13 deletions

View File

@@ -2522,7 +2522,8 @@ func formattedOptionalSdkLevelAttribute(ctx android.ModuleContext, attrName stri
} }
apiLevel, err := android.ApiLevelFromUser(ctx, *value) apiLevel, err := android.ApiLevelFromUser(ctx, *value)
if err != nil { if err != nil {
ctx.PropertyErrorf(attrName, err.Error()) // attributes in bp files have underscores but in the xml have dashes.
ctx.PropertyErrorf(strings.ReplaceAll(attrName, "-", "_"), err.Error())
return "" return ""
} }
intStr := strconv.Itoa(apiLevel.FinalOrPreviewInt()) intStr := strconv.Itoa(apiLevel.FinalOrPreviewInt())
@@ -2543,10 +2544,10 @@ func (module *sdkLibraryXml) permissionsContents(ctx android.ModuleContext) stri
libNameAttr := formattedOptionalAttribute("name", &libName) libNameAttr := formattedOptionalAttribute("name", &libName)
filePath := module.implPath(ctx) filePath := module.implPath(ctx)
filePathAttr := formattedOptionalAttribute("file", &filePath) filePathAttr := formattedOptionalAttribute("file", &filePath)
implicitFromAttr := formattedOptionalSdkLevelAttribute(ctx, "on_bootclasspath_since", module.properties.On_bootclasspath_since) implicitFromAttr := formattedOptionalSdkLevelAttribute(ctx, "on-bootclasspath-since", module.properties.On_bootclasspath_since)
implicitUntilAttr := formattedOptionalSdkLevelAttribute(ctx, "on_bootclasspath_before", module.properties.On_bootclasspath_before) implicitUntilAttr := formattedOptionalSdkLevelAttribute(ctx, "on-bootclasspath-before", module.properties.On_bootclasspath_before)
minSdkAttr := formattedOptionalSdkLevelAttribute(ctx, "min_device_sdk", module.properties.Min_device_sdk) minSdkAttr := formattedOptionalSdkLevelAttribute(ctx, "min-device-sdk", module.properties.Min_device_sdk)
maxSdkAttr := formattedOptionalSdkLevelAttribute(ctx, "max_device_sdk", module.properties.Max_device_sdk) maxSdkAttr := formattedOptionalSdkLevelAttribute(ctx, "max-device-sdk", module.properties.Max_device_sdk)
// <library> is understood in all android versions whereas <updatable-library> is only understood from API T (and ignored before that). // <library> is understood in all android versions whereas <updatable-library> is only understood from API T (and ignored before that).
// similarly, min_device_sdk is only understood from T. So if a library is using that, we need to use the updatable-library to make sure this library is not loaded before T // similarly, min_device_sdk is only understood from T. So if a library is using that, we need to use the updatable-library to make sure this library is not loaded before T
var libraryTag string var libraryTag string

View File

@@ -195,18 +195,18 @@ func TestJavaSdkLibrary_UpdatableLibrary(t *testing.T) {
`) `)
// test that updatability attributes are passed on correctly // test that updatability attributes are passed on correctly
fooUpdatable := result.ModuleForTests("fooUpdatable.xml", "android_common").Rule("java_sdk_xml") fooUpdatable := result.ModuleForTests("fooUpdatable.xml", "android_common").Rule("java_sdk_xml")
android.AssertStringDoesContain(t, "fooUpdatable.xml java_sdk_xml command", fooUpdatable.RuleParams.Command, `on_bootclasspath_since=\"9001\"`) android.AssertStringDoesContain(t, "fooUpdatable.xml java_sdk_xml command", fooUpdatable.RuleParams.Command, `on-bootclasspath-since=\"9001\"`)
android.AssertStringDoesContain(t, "fooUpdatable.xml java_sdk_xml command", fooUpdatable.RuleParams.Command, `on_bootclasspath_before=\"9002\"`) android.AssertStringDoesContain(t, "fooUpdatable.xml java_sdk_xml command", fooUpdatable.RuleParams.Command, `on-bootclasspath-before=\"9002\"`)
android.AssertStringDoesContain(t, "fooUpdatable.xml java_sdk_xml command", fooUpdatable.RuleParams.Command, `min_device_sdk=\"9003\"`) android.AssertStringDoesContain(t, "fooUpdatable.xml java_sdk_xml command", fooUpdatable.RuleParams.Command, `min-device-sdk=\"9003\"`)
android.AssertStringDoesContain(t, "fooUpdatable.xml java_sdk_xml command", fooUpdatable.RuleParams.Command, `max_device_sdk=\"10000\"`) android.AssertStringDoesContain(t, "fooUpdatable.xml java_sdk_xml command", fooUpdatable.RuleParams.Command, `max-device-sdk=\"10000\"`)
// double check that updatability attributes are not written if they don't exist in the bp file // double check that updatability attributes are not written if they don't exist in the bp file
// the permissions file for the foo library defined above // the permissions file for the foo library defined above
fooPermissions := result.ModuleForTests("foo.xml", "android_common").Rule("java_sdk_xml") fooPermissions := result.ModuleForTests("foo.xml", "android_common").Rule("java_sdk_xml")
android.AssertStringDoesNotContain(t, "foo.xml java_sdk_xml command", fooPermissions.RuleParams.Command, `on_bootclasspath_since`) android.AssertStringDoesNotContain(t, "foo.xml java_sdk_xml command", fooPermissions.RuleParams.Command, `on-bootclasspath-since`)
android.AssertStringDoesNotContain(t, "foo.xml java_sdk_xml command", fooPermissions.RuleParams.Command, `on_bootclasspath_before`) android.AssertStringDoesNotContain(t, "foo.xml java_sdk_xml command", fooPermissions.RuleParams.Command, `on-bootclasspath-before`)
android.AssertStringDoesNotContain(t, "foo.xml java_sdk_xml command", fooPermissions.RuleParams.Command, `min_device_sdk`) android.AssertStringDoesNotContain(t, "foo.xml java_sdk_xml command", fooPermissions.RuleParams.Command, `min-device-sdk`)
android.AssertStringDoesNotContain(t, "foo.xml java_sdk_xml command", fooPermissions.RuleParams.Command, `max_device_sdk`) android.AssertStringDoesNotContain(t, "foo.xml java_sdk_xml command", fooPermissions.RuleParams.Command, `max-device-sdk`)
} }
func TestJavaSdkLibrary_UpdatableLibrary_Validation_ValidVersion(t *testing.T) { func TestJavaSdkLibrary_UpdatableLibrary_Validation_ValidVersion(t *testing.T) {