From 6cf2c0c19751a42b18dd316e92a054822a1202b0 Mon Sep 17 00:00:00 2001 From: Ulya Trafimovich Date: Fri, 24 Apr 2020 12:15:20 +0100 Subject: [PATCH] Fix host path for dexpreopted system server modules defined in Make. Previously there was a discrepancy between the generated paths for Soong modules that used "out/soong/system_server_jars" and Make modules that used "out/system_server_jars". This happened because the default output directory is $OUT/soong for the normal Soong config and jsut $OUT for the reduced "null config" created by dexpreopt_gen. As a result, class loader context for system server jars defined in Make was referring to nonexistent jars, which caused non-fatal dex2oat errors (the build was not broken, so the errors remained unnoticed): Failed to determine oat file name for dex location out/system_server_dexjars/[...] Could not open dex files from location: out/system_server_dexjars/[...] Test: aosp_walleye-userdebug boots Test: cherry-picked in master-arc-dev that has a Make system server jar arc-services, `lunch lunch cheets_x86-userdebug && m`, check that the generated dexpreopt.sh for arc-services contains paths starting with "out/soong/system_server_jars" rather than "out/system_server_jars". Bug: 140712566 Change-Id: Ia7ea8ac383e32042c31d64971cdc8101ea3068cd --- dexpreopt/dexpreopt.go | 11 ++++++++++- java/dexpreopt.go | 4 ++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/dexpreopt/dexpreopt.go b/dexpreopt/dexpreopt.go index 0e1bfc615..f984966b4 100644 --- a/dexpreopt/dexpreopt.go +++ b/dexpreopt/dexpreopt.go @@ -47,6 +47,8 @@ import ( const SystemPartition = "/system/" const SystemOtherPartition = "/system_other/" +var DexpreoptRunningInSoong = false + // GenerateDexpreoptRule generates a set of commands that will preopt a module based on a GlobalConfig and a // ModuleConfig. The produced files and their install locations will be available through rule.Installs(). func GenerateDexpreoptRule(ctx android.PathContext, globalSoong *GlobalSoongConfig, @@ -589,7 +591,14 @@ func NonUpdatableSystemServerJars(ctx android.PathContext, global *GlobalConfig) // at that time (Soong processes the jars in dependency order, which may be different from the // the system server classpath order). func SystemServerDexJarHostPath(ctx android.PathContext, jar string) android.OutputPath { - return android.PathForOutput(ctx, "system_server_dexjars", jar+".jar") + if DexpreoptRunningInSoong { + // Soong module, just use the default output directory $OUT/soong. + return android.PathForOutput(ctx, "system_server_dexjars", jar+".jar") + } else { + // Make module, default output directory is $OUT (passed via the "null config" created + // by dexpreopt_gen). Append Soong subdirectory to match Soong module paths. + return android.PathForOutput(ctx, "soong", "system_server_dexjars", jar+".jar") + } } func contains(l []string, s string) bool { diff --git a/java/dexpreopt.go b/java/dexpreopt.go index fba0b97fb..4725b0781 100644 --- a/java/dexpreopt.go +++ b/java/dexpreopt.go @@ -62,6 +62,10 @@ type DexpreoptProperties struct { } } +func init() { + dexpreopt.DexpreoptRunningInSoong = true +} + func (d *dexpreopter) dexpreoptDisabled(ctx android.BaseModuleContext) bool { global := dexpreopt.GetGlobalConfig(ctx)