Merge changes Ibc673303,I70317eb8
* changes: Don't fail if the target module is disabled in dex2oat tool dependencies. Use oatdump rather than oatdumpd for boot jar boot.*.oatdump.txt files.
This commit is contained in:
@@ -803,8 +803,7 @@ func dumpOatRules(ctx android.ModuleContext, image *bootImageConfig) {
|
||||
rule := android.NewRuleBuilder(pctx, ctx)
|
||||
imageLocationsOnHost, _ := image.imageLocations()
|
||||
rule.Command().
|
||||
// TODO: for now, use the debug version for better error reporting
|
||||
BuiltTool("oatdumpd").
|
||||
BuiltTool("oatdump").
|
||||
FlagWithInputList("--runtime-arg -Xbootclasspath:", image.dexPathsDeps.Paths(), ":").
|
||||
FlagWithList("--runtime-arg -Xbootclasspath-locations:", image.dexLocationsDeps, ":").
|
||||
FlagWithArg("--image=", strings.Join(imageLocationsOnHost, ":")).Implicits(image.imagesDeps.Paths()).
|
||||
|
@@ -15,7 +15,12 @@
|
||||
package java
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"android/soong/android"
|
||||
"android/soong/cc"
|
||||
"android/soong/dexpreopt"
|
||||
)
|
||||
|
||||
func TestDexpreoptEnabled(t *testing.T) {
|
||||
@@ -166,3 +171,46 @@ func enabledString(enabled bool) string {
|
||||
return "disabled"
|
||||
}
|
||||
}
|
||||
|
||||
func TestDex2oatToolDeps(t *testing.T) {
|
||||
preparers := android.GroupFixturePreparers(
|
||||
cc.PrepareForTestWithCcDefaultModules,
|
||||
PrepareForTestWithJavaDefaultModulesWithoutFakeDex2oatd,
|
||||
dexpreopt.PrepareForTestByEnablingDexpreopt)
|
||||
|
||||
testDex2oatToolDep := func(sourceEnabled, prebuiltEnabled, prebuiltPreferred bool,
|
||||
expectedDex2oatPath string) {
|
||||
name := fmt.Sprintf("sourceEnabled:%t,prebuiltEnabled:%t,prebuiltPreferred:%t",
|
||||
sourceEnabled, prebuiltEnabled, prebuiltPreferred)
|
||||
t.Run(name, func(t *testing.T) {
|
||||
result := preparers.RunTestWithBp(t, fmt.Sprintf(`
|
||||
cc_binary {
|
||||
name: "dex2oatd",
|
||||
enabled: %t,
|
||||
host_supported: true,
|
||||
}
|
||||
cc_prebuilt_binary {
|
||||
name: "dex2oatd",
|
||||
enabled: %t,
|
||||
prefer: %t,
|
||||
host_supported: true,
|
||||
srcs: ["x86_64/bin/dex2oatd"],
|
||||
}
|
||||
java_library {
|
||||
name: "myjavalib",
|
||||
}
|
||||
`, sourceEnabled, prebuiltEnabled, prebuiltPreferred))
|
||||
pathContext := android.PathContextForTesting(result.Config)
|
||||
dex2oatPath := dexpreopt.GetCachedGlobalSoongConfig(pathContext).Dex2oat
|
||||
android.AssertStringEquals(t, "Testing "+name, expectedDex2oatPath, android.NormalizePathForTesting(dex2oatPath))
|
||||
})
|
||||
}
|
||||
|
||||
sourceDex2oatPath := "host/linux-x86/bin/dex2oatd"
|
||||
prebuiltDex2oatPath := ".intermediates/prebuilt_dex2oatd/linux_glibc_x86_64/dex2oatd"
|
||||
|
||||
testDex2oatToolDep(true, false, false, sourceDex2oatPath)
|
||||
testDex2oatToolDep(true, true, false, sourceDex2oatPath)
|
||||
testDex2oatToolDep(true, true, true, prebuiltDex2oatPath)
|
||||
testDex2oatToolDep(false, true, false, prebuiltDex2oatPath)
|
||||
}
|
||||
|
@@ -57,6 +57,10 @@ func registerJavaBuildComponents(ctx android.RegistrationContext) {
|
||||
ctx.RegisterModuleType("java_host_for_device", HostForDeviceFactory)
|
||||
ctx.RegisterModuleType("dex_import", DexImportFactory)
|
||||
|
||||
// This mutator registers dependencies on dex2oat for modules that should be
|
||||
// dexpreopted. This is done late when the final variants have been
|
||||
// established, to not get the dependencies split into the wrong variants and
|
||||
// to support the checks in dexpreoptDisabled().
|
||||
ctx.FinalDepsMutators(func(ctx android.RegisterMutatorsContext) {
|
||||
ctx.BottomUp("dexpreopt_tool_deps", dexpreoptToolDepsMutator).Parallel()
|
||||
})
|
||||
|
@@ -24,6 +24,7 @@ import (
|
||||
"android/soong/android"
|
||||
"android/soong/cc"
|
||||
"android/soong/dexpreopt"
|
||||
|
||||
"github.com/google/blueprint"
|
||||
)
|
||||
|
||||
@@ -55,8 +56,9 @@ var PrepareForTestWithJavaBuildComponents = android.GroupFixturePreparers(
|
||||
}.AddToFixture(),
|
||||
)
|
||||
|
||||
// Test fixture preparer that will define default java modules, e.g. standard prebuilt modules.
|
||||
var PrepareForTestWithJavaDefaultModules = android.GroupFixturePreparers(
|
||||
// Test fixture preparer that will define all default java modules except the
|
||||
// fake_tool_binary for dex2oatd.
|
||||
var PrepareForTestWithJavaDefaultModulesWithoutFakeDex2oatd = android.GroupFixturePreparers(
|
||||
// Make sure that all the module types used in the defaults are registered.
|
||||
PrepareForTestWithJavaBuildComponents,
|
||||
// Additional files needed when test disallows non-existent source.
|
||||
@@ -72,6 +74,11 @@ var PrepareForTestWithJavaDefaultModules = android.GroupFixturePreparers(
|
||||
android.FixtureAddTextFile(defaultJavaDir+"/Android.bp", gatherRequiredDepsForTest()),
|
||||
// Add dexpreopt compat libs (android.test.base, etc.) and a fake dex2oatd module.
|
||||
dexpreopt.PrepareForTestWithDexpreoptCompatLibs,
|
||||
)
|
||||
|
||||
// Test fixture preparer that will define default java modules, e.g. standard prebuilt modules.
|
||||
var PrepareForTestWithJavaDefaultModules = android.GroupFixturePreparers(
|
||||
PrepareForTestWithJavaDefaultModulesWithoutFakeDex2oatd,
|
||||
dexpreopt.PrepareForTestWithFakeDex2oatd,
|
||||
)
|
||||
|
||||
|
Reference in New Issue
Block a user