From 3f07ab2d63e2a0892b45d9200a15b2fbba6c33e9 Mon Sep 17 00:00:00 2001 From: Anton Hansson Date: Thu, 9 Apr 2020 13:29:59 +0100 Subject: [PATCH] Create a framework.aidl for non-updatable platform framework.aidl includes the parcelables from the non-updatable part of the framework as well as the modules. This causes a dependency cycle when building module stubs: module_stub -> module_sdk -> framework.aidl -> public_sdk -> module_stub The module_sdk only includes the the stubs for the non-updatable part of the framework, so it should also only contain the non-updatable parcelables. This change creates a framework_non_updatable.aidl with those parcelables, and updates module_current to use that. Bug: 144149403 Test: m Test: m && diff out/soong/framework{,_non_updatable}.aidl (the diff contains just TestApi + module parcelables) Change-Id: I224117a0ff695c22d4a4317a51a9b775ed73066b Merged-In: I224117a0ff695c22d4a4317a51a9b775ed73066b (cherry picked from commit 85c151c3f3aa64c140524de23493c39ea5822292) --- java/sdk.go | 49 +++++++++++++++++++++++++++++++++++++----------- java/sdk_test.go | 2 +- 2 files changed, 39 insertions(+), 12 deletions(-) diff --git a/java/sdk.go b/java/sdk.go index 9310f7846..2a08f329e 100644 --- a/java/sdk.go +++ b/java/sdk.go @@ -35,6 +35,7 @@ func init() { var sdkVersionsKey = android.NewOnceKey("sdkVersionsKey") var sdkFrameworkAidlPathKey = android.NewOnceKey("sdkFrameworkAidlPathKey") +var nonUpdatableFrameworkAidlPathKey = android.NewOnceKey("nonUpdatableFrameworkAidlPathKey") var apiFingerprintPathKey = android.NewOnceKey("apiFingerprintPathKey") type sdkContext interface { @@ -447,7 +448,7 @@ func decodeSdkDep(ctx android.EarlyModuleContext, sdkContext sdkContext) sdkDep return toModule([]string{"core.current.stubs"}, "", nil) case sdkModule: // TODO(146757305): provide .apk and .aidl that have more APIs for modules - return toModule([]string{"android_module_lib_stubs_current"}, "framework-res", sdkFrameworkAidlPath(ctx)) + return toModule([]string{"android_module_lib_stubs_current"}, "framework-res", nonUpdatableFrameworkAidlPath(ctx)) case sdkSystemServer: // TODO(146757305): provide .apk and .aidl that have more APIs for modules return toModule([]string{"android_system_server_stubs_current"}, "framework-res", sdkFrameworkAidlPath(ctx)) @@ -506,6 +507,7 @@ func (sdkSingleton) GenerateBuildActions(ctx android.SingletonContext) { } createSdkFrameworkAidl(ctx) + createNonUpdatableFrameworkAidl(ctx) createAPIFingerprint(ctx) } @@ -517,6 +519,31 @@ func createSdkFrameworkAidl(ctx android.SingletonContext) { "android_system_stubs_current", } + combinedAidl := sdkFrameworkAidlPath(ctx) + tempPath := combinedAidl.ReplaceExtension(ctx, "aidl.tmp") + + rule := createFrameworkAidl(stubsModules, tempPath, ctx) + + commitChangeForRestat(rule, tempPath, combinedAidl) + + rule.Build(pctx, ctx, "framework_aidl", "generate framework.aidl") +} + +// Creates a version of framework.aidl for the non-updatable part of the platform. +func createNonUpdatableFrameworkAidl(ctx android.SingletonContext) { + stubsModules := []string{"android_module_lib_stubs_current"} + + combinedAidl := nonUpdatableFrameworkAidlPath(ctx) + tempPath := combinedAidl.ReplaceExtension(ctx, "aidl.tmp") + + rule := createFrameworkAidl(stubsModules, tempPath, ctx) + + commitChangeForRestat(rule, tempPath, combinedAidl) + + rule.Build(pctx, ctx, "framework_non_updatable_aidl", "generate framework_non_updatable.aidl") +} + +func createFrameworkAidl(stubsModules []string, path android.OutputPath, ctx android.SingletonContext) *android.RuleBuilder { stubsJars := make([]android.Paths, len(stubsModules)) ctx.VisitAllModules(func(module android.Module) { @@ -536,8 +563,7 @@ func createSdkFrameworkAidl(ctx android.SingletonContext) { if ctx.Config().AllowMissingDependencies() { missingDeps = append(missingDeps, stubsModules[i]) } else { - ctx.Errorf("failed to find dex jar path for module %q", - stubsModules[i]) + ctx.Errorf("failed to find dex jar path for module %q", stubsModules[i]) } } } @@ -561,20 +587,15 @@ func createSdkFrameworkAidl(ctx android.SingletonContext) { } } - combinedAidl := sdkFrameworkAidlPath(ctx) - tempPath := combinedAidl.ReplaceExtension(ctx, "aidl.tmp") - rule.Command(). - Text("rm -f").Output(tempPath) + Text("rm -f").Output(path) rule.Command(). Text("cat"). Inputs(aidls). Text("| sort -u >"). - Output(tempPath) + Output(path) - commitChangeForRestat(rule, tempPath, combinedAidl) - - rule.Build(pctx, ctx, "framework_aidl", "generate framework.aidl") + return rule } func sdkFrameworkAidlPath(ctx android.PathContext) android.OutputPath { @@ -583,6 +604,12 @@ func sdkFrameworkAidlPath(ctx android.PathContext) android.OutputPath { }).(android.OutputPath) } +func nonUpdatableFrameworkAidlPath(ctx android.PathContext) android.OutputPath { + return ctx.Config().Once(nonUpdatableFrameworkAidlPathKey, func() interface{} { + return android.PathForOutput(ctx, "framework_non_updatable.aidl") + }).(android.OutputPath) +} + // Create api_fingerprint.txt func createAPIFingerprint(ctx android.SingletonContext) { out := ApiFingerprintPath(ctx) diff --git a/java/sdk_test.go b/java/sdk_test.go index fb8646313..52d2df552 100644 --- a/java/sdk_test.go +++ b/java/sdk_test.go @@ -252,7 +252,7 @@ func TestClasspath(t *testing.T) { bootclasspath: []string{"android_module_lib_stubs_current", "core-lambda-stubs"}, system: "core-current-stubs-system-modules", java9classpath: []string{"android_module_lib_stubs_current"}, - aidl: "-p" + buildDir + "/framework.aidl", + aidl: "-p" + buildDir + "/framework_non_updatable.aidl", }, { name: "system_server_current",