From 7d1d083ec14de2966518654eb348a4fa23d63cf6 Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Fri, 23 Apr 2021 11:39:41 +0100 Subject: [PATCH] Check consistency of the BootJars/UpdatableBootJars config Both out/soong/dexpreopt.config and out/soong/soong.variables contain configuration for the BootJars and UpdatableBootJars that MUST be identical. If they are not then it can lead to broken builds. This change adds a consistency check for them that will make the issue more obvious. Bug: 186195980 Test: DIST_DIR=out/bionic-dist ./art/tools/dist_linux_bionic.sh -j80 com.android.art.host com.android.support.apexer --skip-soong-tests Ran the previous command with and without the fix in https://r.android.com/1684877. Without the fix the build reported an inconsistency in the configuration, with that fix the build passed. Change-Id: I10fbe328ba4f1fbd9db4708409979e9824c196ef --- dexpreopt/config.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/dexpreopt/config.go b/dexpreopt/config.go index 151f032fb..a94e7af5a 100644 --- a/dexpreopt/config.go +++ b/dexpreopt/config.go @@ -17,6 +17,7 @@ package dexpreopt import ( "encoding/json" "fmt" + "reflect" "strings" "github.com/google/blueprint" @@ -522,7 +523,27 @@ func ParseGlobalSoongConfig(ctx android.PathContext, data []byte) (*GlobalSoongC return config, nil } +// checkBootJarsConfigConsistency checks the consistency of BootJars and UpdatableBootJars fields in +// DexpreoptGlobalConfig and Config.productVariables. +func checkBootJarsConfigConsistency(ctx android.SingletonContext, dexpreoptConfig *GlobalConfig, config android.Config) { + compareBootJars := func(property string, dexpreoptJars, variableJars android.ConfiguredJarList) { + dexpreoptPairs := dexpreoptJars.CopyOfApexJarPairs() + variablePairs := variableJars.CopyOfApexJarPairs() + if !reflect.DeepEqual(dexpreoptPairs, variablePairs) { + ctx.Errorf("Inconsistent configuration of %[1]s\n"+ + " dexpreopt.GlobalConfig.%[1]s = %[2]s\n"+ + " productVariables.%[1]s = %[3]s", + property, dexpreoptPairs, variablePairs) + } + } + + compareBootJars("BootJars", dexpreoptConfig.BootJars, config.NonUpdatableBootJars()) + compareBootJars("UpdatableBootJars", dexpreoptConfig.UpdatableBootJars, config.UpdatableBootJars()) +} + func (s *globalSoongConfigSingleton) GenerateBuildActions(ctx android.SingletonContext) { + checkBootJarsConfigConsistency(ctx, GetGlobalConfig(ctx), ctx.Config()) + if GetGlobalConfig(ctx).DisablePreopt { return }