Do not override "-g:source,lines" for host java binaries when PRODUCT_MINIMIZE_JAVA_DEBUG_INFO is set.

Test: Ran unittests
Change-Id: Ic061b4bf107bcd931813d69f6d72b521d79fbc35
This commit is contained in:
Alex Humesky
2020-06-09 20:23:08 -04:00
parent c9d83d25bb
commit 2070e32eb9
2 changed files with 37 additions and 3 deletions

View File

@@ -466,7 +466,41 @@ func TestBinary(t *testing.T) {
t.Errorf("expected binary wrapper implicits [%q], got %v",
barJar, barWrapperDeps)
}
}
func TestHostBinaryNoJavaDebugInfoOverride(t *testing.T) {
bp := `
java_library {
name: "target_library",
srcs: ["a.java"],
}
java_binary_host {
name: "host_binary",
srcs: ["b.java"],
}
`
config := testConfig(nil, bp, nil)
config.TestProductVariables.MinimizeJavaDebugInfo = proptools.BoolPtr(true)
ctx, _ := testJavaWithConfig(t, config)
// first, sanity check that the -g flag is added to target modules
targetLibrary := ctx.ModuleForTests("target_library", "android_common")
targetJavaFlags := targetLibrary.Module().VariablesForTests()["javacFlags"]
if !strings.Contains(targetJavaFlags, "-g:source,lines") {
t.Errorf("target library javac flags %v should contain "+
"-g:source,lines override with MinimizeJavaDebugInfo", targetJavaFlags)
}
// check that -g is not overridden for host modules
buildOS := android.BuildOs.String()
hostBinary := ctx.ModuleForTests("host_binary", buildOS+"_common")
hostJavaFlags := hostBinary.Module().VariablesForTests()["javacFlags"]
if strings.Contains(hostJavaFlags, "-g:source,lines") {
t.Errorf("java_binary_host javac flags %v should not have "+
"-g:source,lines override with MinimizeJavaDebugInfo", hostJavaFlags)
}
}
func TestPrebuilts(t *testing.T) {