From 6d9108f0473aa7e5726cb232ede83c1a2016e5d6 Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Tue, 9 Mar 2021 22:59:28 +0000 Subject: [PATCH] Extract sdk registration code into function for reuse Test: m nothing Change-Id: I0d0e36324808831deb9a32f07ca3696125703873 --- sdk/exports.go | 8 ++++++-- sdk/sdk.go | 12 ++++++++---- sdk/testing.go | 8 ++------ 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/sdk/exports.go b/sdk/exports.go index d3130574e..9a0ba4e32 100644 --- a/sdk/exports.go +++ b/sdk/exports.go @@ -17,8 +17,12 @@ package sdk import "android/soong/android" func init() { - android.RegisterModuleType("module_exports", ModuleExportsFactory) - android.RegisterModuleType("module_exports_snapshot", ModuleExportsSnapshotsFactory) + registerModuleExportsBuildComponents(android.InitRegistrationContext) +} + +func registerModuleExportsBuildComponents(ctx android.RegistrationContext) { + ctx.RegisterModuleType("module_exports", ModuleExportsFactory) + ctx.RegisterModuleType("module_exports_snapshot", ModuleExportsSnapshotsFactory) } // module_exports defines the exports of a mainline module. The exports are Soong modules diff --git a/sdk/sdk.go b/sdk/sdk.go index f3d075022..2c84a2e88 100644 --- a/sdk/sdk.go +++ b/sdk/sdk.go @@ -33,10 +33,14 @@ func init() { pctx.Import("android/soong/android") pctx.Import("android/soong/java/config") - android.RegisterModuleType("sdk", SdkModuleFactory) - android.RegisterModuleType("sdk_snapshot", SnapshotModuleFactory) - android.PreDepsMutators(RegisterPreDepsMutators) - android.PostDepsMutators(RegisterPostDepsMutators) + registerSdkBuildComponents(android.InitRegistrationContext) +} + +func registerSdkBuildComponents(ctx android.RegistrationContext) { + ctx.RegisterModuleType("sdk", SdkModuleFactory) + ctx.RegisterModuleType("sdk_snapshot", SnapshotModuleFactory) + ctx.PreDepsMutators(RegisterPreDepsMutators) + ctx.PostDepsMutators(RegisterPostDepsMutators) } type sdk struct { diff --git a/sdk/testing.go b/sdk/testing.go index 7a2540a27..4e31b0463 100644 --- a/sdk/testing.go +++ b/sdk/testing.go @@ -122,12 +122,8 @@ func testSdkContext(bp string, fs map[string][]byte, extraOsTypes []android.OsTy ctx.PostDepsMutators(apex.RegisterPostDepsMutators) // from this package - ctx.RegisterModuleType("sdk", SdkModuleFactory) - ctx.RegisterModuleType("sdk_snapshot", SnapshotModuleFactory) - ctx.RegisterModuleType("module_exports", ModuleExportsFactory) - ctx.RegisterModuleType("module_exports_snapshot", ModuleExportsSnapshotsFactory) - ctx.PreDepsMutators(RegisterPreDepsMutators) - ctx.PostDepsMutators(RegisterPostDepsMutators) + registerModuleExportsBuildComponents(ctx) + registerSdkBuildComponents(ctx) ctx.Register()