From 34155e33636a412e41959307421b9637ddfe8c10 Mon Sep 17 00:00:00 2001 From: Jihoon Kang Date: Mon, 20 May 2024 19:08:49 +0000 Subject: [PATCH] Do not instrument the implementation library of sdk_library Currently, the implementation library of the java_sdk_library is always being instrumented due to the issue described in b/159241638. With https://r.android.com/3079425, all compilation actions of the java_sdk_library is delegated to the implementation library. Consequently, this has caused all java_sdk_library to be instrumented, leading to coverage builds failing due to double instrumentation (i.e. instrumenting an already instrumented class file). In order to prevent such error, this change modifies the property of the implementation library to not instrument during coverage builds. This change also copies some additional java library properties from that of the implementation library to the top level sdk library, in order to ensure that all non-null androidmk entries are correctly reflected in that of the sdk library. Test: lunch husky-trunk_staging-userdebug && EMMA_INSTRUMENT=true EMMA_INSTRUMENT_FRAMEWORK=true m droid dist Bug: 340174053 Bug: 341170242 Change-Id: I9d8f1c190205fa7a827649961ba5222293a945ad --- java/sdk_library.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/java/sdk_library.go b/java/sdk_library.go index 677b32a5e..45eeec1ef 100644 --- a/java/sdk_library.go +++ b/java/sdk_library.go @@ -1650,6 +1650,14 @@ func (module *SdkLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) module.dexpreopter.configPath = module.implLibraryModule.dexpreopter.configPath module.dexpreopter.outputProfilePathOnHost = module.implLibraryModule.dexpreopter.outputProfilePathOnHost + // Properties required for Library.AndroidMkEntries + module.logtagsSrcs = module.implLibraryModule.logtagsSrcs + module.dexpreopter.builtInstalled = module.implLibraryModule.dexpreopter.builtInstalled + module.jacocoReportClassesFile = module.implLibraryModule.jacocoReportClassesFile + module.dexer.proguardDictionary = module.implLibraryModule.dexer.proguardDictionary + module.dexer.proguardUsageZip = module.implLibraryModule.dexer.proguardUsageZip + module.linter.reports = module.implLibraryModule.linter.reports + if !module.Host() { module.hostdexInstallFile = module.implLibraryModule.hostdexInstallFile } @@ -1814,7 +1822,6 @@ func (module *SdkLibrary) createImplLibrary(mctx android.DefaultableHookContext) props := struct { Name *string Visibility []string - Instrument bool Libs []string Static_libs []string Apex_available []string @@ -1822,8 +1829,6 @@ func (module *SdkLibrary) createImplLibrary(mctx android.DefaultableHookContext) }{ Name: proptools.StringPtr(module.implLibraryModuleName()), Visibility: visibility, - // Set the instrument property to ensure it is instrumented when instrumentation is required. - Instrument: true, Libs: append(module.properties.Libs, module.sdkLibraryProperties.Impl_only_libs...),