Merge "Do not override "-g:source,lines" for host java binaries when PRODUCT_MINIMIZE_JAVA_DEBUG_INFO is set."
This commit is contained in:
commit
c7f8b74365
|
@ -1167,9 +1167,9 @@ func (j *Module) collectBuilderFlags(ctx android.ModuleContext, deps deps) javaB
|
|||
if flags.javaVersion.usesJavaModules() {
|
||||
javacFlags = append(javacFlags, j.properties.Openjdk9.Javacflags...)
|
||||
}
|
||||
if ctx.Config().MinimizeJavaDebugInfo() {
|
||||
// Override the -g flag passed globally to remove local variable debug info to reduce
|
||||
// disk and memory usage.
|
||||
if ctx.Config().MinimizeJavaDebugInfo() && !ctx.Host() {
|
||||
// For non-host binaries, override the -g flag passed globally to remove
|
||||
// local variable debug info to reduce disk and memory usage.
|
||||
javacFlags = append(javacFlags, "-g:source,lines")
|
||||
}
|
||||
javacFlags = append(javacFlags, "-Xlint:-dep-ann")
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue