Merge "Provide platform build flag to R8/D8"
This commit is contained in:
10
java/dex.go
10
java/dex.go
@@ -200,6 +200,16 @@ func (d *dexer) dexCommonFlags(ctx android.ModuleContext,
|
|||||||
"--verbose")
|
"--verbose")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Supplying the platform build flag disables various features like API modeling and desugaring.
|
||||||
|
// For targets with a stable min SDK version (i.e., when the min SDK is both explicitly specified
|
||||||
|
// and managed+versioned), we suppress this flag to ensure portability.
|
||||||
|
// Note: Targets with a min SDK kind of core_platform (e.g., framework.jar) or unspecified (e.g.,
|
||||||
|
// services.jar), are not classified as stable, which is WAI.
|
||||||
|
// TODO(b/232073181): Expand to additional min SDK cases after validation.
|
||||||
|
if !minSdkVersion.Stable() {
|
||||||
|
flags = append(flags, "--android-platform-build")
|
||||||
|
}
|
||||||
|
|
||||||
effectiveVersion, err := minSdkVersion.EffectiveVersion(ctx)
|
effectiveVersion, err := minSdkVersion.EffectiveVersion(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.PropertyErrorf("min_sdk_version", "%s", err)
|
ctx.PropertyErrorf("min_sdk_version", "%s", err)
|
||||||
|
@@ -30,6 +30,19 @@ func TestR8(t *testing.T) {
|
|||||||
platform_apis: true,
|
platform_apis: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
android_app {
|
||||||
|
name: "stable_app",
|
||||||
|
srcs: ["foo.java"],
|
||||||
|
sdk_version: "current",
|
||||||
|
min_sdk_version: "31",
|
||||||
|
}
|
||||||
|
|
||||||
|
android_app {
|
||||||
|
name: "core_platform_app",
|
||||||
|
srcs: ["foo.java"],
|
||||||
|
sdk_version: "core_platform",
|
||||||
|
}
|
||||||
|
|
||||||
java_library {
|
java_library {
|
||||||
name: "lib",
|
name: "lib",
|
||||||
srcs: ["foo.java"],
|
srcs: ["foo.java"],
|
||||||
@@ -42,11 +55,15 @@ func TestR8(t *testing.T) {
|
|||||||
`)
|
`)
|
||||||
|
|
||||||
app := result.ModuleForTests("app", "android_common")
|
app := result.ModuleForTests("app", "android_common")
|
||||||
|
stableApp := result.ModuleForTests("stable_app", "android_common")
|
||||||
|
corePlatformApp := result.ModuleForTests("core_platform_app", "android_common")
|
||||||
lib := result.ModuleForTests("lib", "android_common")
|
lib := result.ModuleForTests("lib", "android_common")
|
||||||
staticLib := result.ModuleForTests("static_lib", "android_common")
|
staticLib := result.ModuleForTests("static_lib", "android_common")
|
||||||
|
|
||||||
appJavac := app.Rule("javac")
|
appJavac := app.Rule("javac")
|
||||||
appR8 := app.Rule("r8")
|
appR8 := app.Rule("r8")
|
||||||
|
stableAppR8 := stableApp.Rule("r8")
|
||||||
|
corePlatformAppR8 := corePlatformApp.Rule("r8")
|
||||||
libHeader := lib.Output("turbine-combined/lib.jar").Output
|
libHeader := lib.Output("turbine-combined/lib.jar").Output
|
||||||
staticLibHeader := staticLib.Output("turbine-combined/static_lib.jar").Output
|
staticLibHeader := staticLib.Output("turbine-combined/static_lib.jar").Output
|
||||||
|
|
||||||
@@ -61,6 +78,12 @@ func TestR8(t *testing.T) {
|
|||||||
appR8.Args["r8Flags"], staticLibHeader.String())
|
appR8.Args["r8Flags"], staticLibHeader.String())
|
||||||
android.AssertStringDoesContain(t, "expected -ignorewarnings in app r8 flags",
|
android.AssertStringDoesContain(t, "expected -ignorewarnings in app r8 flags",
|
||||||
appR8.Args["r8Flags"], "-ignorewarnings")
|
appR8.Args["r8Flags"], "-ignorewarnings")
|
||||||
|
android.AssertStringDoesContain(t, "expected --android-platform-build in app r8 flags",
|
||||||
|
appR8.Args["r8Flags"], "--android-platform-build")
|
||||||
|
android.AssertStringDoesNotContain(t, "expected no --android-platform-build in stable_app r8 flags",
|
||||||
|
stableAppR8.Args["r8Flags"], "--android-platform-build")
|
||||||
|
android.AssertStringDoesContain(t, "expected --android-platform-build in core_platform_app r8 flags",
|
||||||
|
corePlatformAppR8.Args["r8Flags"], "--android-platform-build")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestR8Flags(t *testing.T) {
|
func TestR8Flags(t *testing.T) {
|
||||||
@@ -88,7 +111,8 @@ func TestR8Flags(t *testing.T) {
|
|||||||
appR8.Args["r8Flags"], "-dontobfuscate")
|
appR8.Args["r8Flags"], "-dontobfuscate")
|
||||||
android.AssertStringDoesNotContain(t, "expected no -ignorewarnings in app r8 flags",
|
android.AssertStringDoesNotContain(t, "expected no -ignorewarnings in app r8 flags",
|
||||||
appR8.Args["r8Flags"], "-ignorewarnings")
|
appR8.Args["r8Flags"], "-ignorewarnings")
|
||||||
|
android.AssertStringDoesContain(t, "expected --android-platform-build in app r8 flags",
|
||||||
|
appR8.Args["r8Flags"], "--android-platform-build")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestD8(t *testing.T) {
|
func TestD8(t *testing.T) {
|
||||||
|
Reference in New Issue
Block a user