From 0ea8ba82fcffad414ea95d49f7d09107606f3f69 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Thu, 6 Jun 2019 14:33:29 -0700 Subject: [PATCH] Consolidate baseContext, BaseContext, and BaseModuleContext blueprint.BaseModuleContext is the set of methods available to all module-specific calls (GenerateBuildActions or mutators). The android package split the same functionality across baseContext (nee androidBaseContext), BaseModuleContext, and BaseContext. Consolidate all of them into android.BaseModuleContext. Test: m checkbuild Change-Id: I2d7f5c56fd4424032cb93edff6dc730ff33e4f1e --- android/api_levels.go | 2 +- android/hooks.go | 4 +- android/module.go | 124 +++++++++++++++++++++--------------------- android/mutator.go | 10 ++-- android/paths.go | 4 +- android/paths_test.go | 48 ++++++++-------- apex/apex.go | 2 +- cc/cc.go | 8 +-- cc/ndk_library.go | 4 +- java/app.go | 2 +- java/java.go | 8 +-- java/sdk.go | 8 +-- java/sdk_library.go | 10 ++-- 13 files changed, 115 insertions(+), 119 deletions(-) diff --git a/android/api_levels.go b/android/api_levels.go index 51d470381..961685aa8 100644 --- a/android/api_levels.go +++ b/android/api_levels.go @@ -85,7 +85,7 @@ func getApiLevelsMap(config Config) map[string]int { // * Numeric API levels are simply converted. // * "minimum" and "current" are not currently handled since the former is // NDK specific and the latter has inconsistent meaning. -func ApiStrToNum(ctx BaseContext, apiLevel string) (int, error) { +func ApiStrToNum(ctx BaseModuleContext, apiLevel string) (int, error) { num, ok := getApiLevelsMap(ctx.Config())[apiLevel] if ok { return num, nil diff --git a/android/hooks.go b/android/hooks.go index 163220cbd..2d2f797bd 100644 --- a/android/hooks.go +++ b/android/hooks.go @@ -27,7 +27,7 @@ import ( // been applied. type LoadHookContext interface { // TODO: a new context that includes Config() but not Target(), etc.? - BaseContext + BaseModuleContext AppendProperties(...interface{}) PrependProperties(...interface{}) CreateModule(blueprint.ModuleFactory, ...interface{}) @@ -36,7 +36,7 @@ type LoadHookContext interface { // Arch hooks are run after the module has been split into architecture variants, and can be used // to add architecture-specific properties. type ArchHookContext interface { - BaseContext + BaseModuleContext AppendProperties(...interface{}) PrependProperties(...interface{}) } diff --git a/android/module.go b/android/module.go index c3d5f6ad2..9d73859b4 100644 --- a/android/module.go +++ b/android/module.go @@ -56,7 +56,30 @@ type BuildParams struct { type ModuleBuildParams BuildParams -type baseContext interface { +// BaseModuleContext is the same as blueprint.BaseModuleContext except that Config() returns +// a Config instead of an interface{}, plus some extra methods that return Android-specific information +// about the current module. +type BaseModuleContext interface { + ModuleName() string + ModuleDir() string + ModuleType() string + Config() Config + + ContainsProperty(name string) bool + Errorf(pos scanner.Position, fmt string, args ...interface{}) + ModuleErrorf(fmt string, args ...interface{}) + PropertyErrorf(property, fmt string, args ...interface{}) + Failed() bool + + // GlobWithDeps returns a list of files that match the specified pattern but do not match any + // of the patterns in excludes. It also adds efficient dependencies to rerun the primary + // builder whenever a file matching the pattern as added or removed, without rerunning if a + // file that does not match the pattern is added to a searched directory. + GlobWithDeps(pattern string, excludes []string) ([]string, error) + + Fs() pathtools.FileSystem + AddNinjaFileDeps(deps ...string) + Target() Target TargetPrimary() bool MultiTargets() []Target @@ -78,37 +101,12 @@ type baseContext interface { DeviceConfig() DeviceConfig } +// Deprecated: use BaseModuleContext instead type BaseContext interface { BaseModuleContext - baseContext -} - -// BaseModuleContext is the same as blueprint.BaseModuleContext except that Config() returns -// a Config instead of an interface{}. -type BaseModuleContext interface { - ModuleName() string - ModuleDir() string - ModuleType() string - Config() Config - - ContainsProperty(name string) bool - Errorf(pos scanner.Position, fmt string, args ...interface{}) - ModuleErrorf(fmt string, args ...interface{}) - PropertyErrorf(property, fmt string, args ...interface{}) - Failed() bool - - // GlobWithDeps returns a list of files that match the specified pattern but do not match any - // of the patterns in excludes. It also adds efficient dependencies to rerun the primary - // builder whenever a file matching the pattern as added or removed, without rerunning if a - // file that does not match the pattern is added to a searched directory. - GlobWithDeps(pattern string, excludes []string) ([]string, error) - - Fs() pathtools.FileSystem - AddNinjaFileDeps(deps ...string) } type ModuleContext interface { - baseContext BaseModuleContext // Deprecated: use ModuleContext.Build instead. @@ -826,25 +824,26 @@ func determineModuleKind(m *ModuleBase, ctx blueprint.BaseModuleContext) moduleK } } -func (m *ModuleBase) baseContextFactory(ctx blueprint.BaseModuleContext) baseContextImpl { - return baseContextImpl{ - target: m.commonProperties.CompileTarget, - targetPrimary: m.commonProperties.CompilePrimary, - multiTargets: m.commonProperties.CompileMultiTargets, - kind: determineModuleKind(m, ctx), - config: ctx.Config().(Config), +func (m *ModuleBase) baseModuleContextFactory(ctx blueprint.BaseModuleContext) baseModuleContext { + return baseModuleContext{ + BaseModuleContext: ctx, + target: m.commonProperties.CompileTarget, + targetPrimary: m.commonProperties.CompilePrimary, + multiTargets: m.commonProperties.CompileMultiTargets, + kind: determineModuleKind(m, ctx), + config: ctx.Config().(Config), } } func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext) { ctx := &moduleContext{ - module: m.module, - ModuleContext: blueprintCtx, - baseContextImpl: m.baseContextFactory(blueprintCtx), - installDeps: m.computeInstallDeps(blueprintCtx), - installFiles: m.installFiles, - missingDeps: blueprintCtx.GetMissingDependencies(), - variables: make(map[string]string), + module: m.module, + ModuleContext: blueprintCtx, + baseModuleContext: m.baseModuleContextFactory(blueprintCtx), + installDeps: m.computeInstallDeps(blueprintCtx), + installFiles: m.installFiles, + missingDeps: blueprintCtx.GetMissingDependencies(), + variables: make(map[string]string), } if ctx.config.captureBuild { @@ -917,7 +916,8 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext) m.variables = ctx.variables } -type baseContextImpl struct { +type baseModuleContext struct { + blueprint.BaseModuleContext target Target multiTargets []Target targetPrimary bool @@ -928,7 +928,7 @@ type baseContextImpl struct { type moduleContext struct { blueprint.ModuleContext - baseContextImpl + baseModuleContext installDeps Paths installFiles Paths checkbuildFiles Paths @@ -1210,82 +1210,82 @@ func (m *moduleContext) FinalModule() Module { return m.ModuleContext.FinalModule().(Module) } -func (b *baseContextImpl) Target() Target { +func (b *baseModuleContext) Target() Target { return b.target } -func (b *baseContextImpl) TargetPrimary() bool { +func (b *baseModuleContext) TargetPrimary() bool { return b.targetPrimary } -func (b *baseContextImpl) MultiTargets() []Target { +func (b *baseModuleContext) MultiTargets() []Target { return b.multiTargets } -func (b *baseContextImpl) Arch() Arch { +func (b *baseModuleContext) Arch() Arch { return b.target.Arch } -func (b *baseContextImpl) Os() OsType { +func (b *baseModuleContext) Os() OsType { return b.target.Os } -func (b *baseContextImpl) Host() bool { +func (b *baseModuleContext) Host() bool { return b.target.Os.Class == Host || b.target.Os.Class == HostCross } -func (b *baseContextImpl) Device() bool { +func (b *baseModuleContext) Device() bool { return b.target.Os.Class == Device } -func (b *baseContextImpl) Darwin() bool { +func (b *baseModuleContext) Darwin() bool { return b.target.Os == Darwin } -func (b *baseContextImpl) Fuchsia() bool { +func (b *baseModuleContext) Fuchsia() bool { return b.target.Os == Fuchsia } -func (b *baseContextImpl) Windows() bool { +func (b *baseModuleContext) Windows() bool { return b.target.Os == Windows } -func (b *baseContextImpl) Debug() bool { +func (b *baseModuleContext) Debug() bool { return b.debug } -func (b *baseContextImpl) PrimaryArch() bool { +func (b *baseModuleContext) PrimaryArch() bool { if len(b.config.Targets[b.target.Os]) <= 1 { return true } return b.target.Arch.ArchType == b.config.Targets[b.target.Os][0].Arch.ArchType } -func (b *baseContextImpl) AConfig() Config { +func (b *baseModuleContext) AConfig() Config { return b.config } -func (b *baseContextImpl) DeviceConfig() DeviceConfig { +func (b *baseModuleContext) DeviceConfig() DeviceConfig { return DeviceConfig{b.config.deviceConfig} } -func (b *baseContextImpl) Platform() bool { +func (b *baseModuleContext) Platform() bool { return b.kind == platformModule } -func (b *baseContextImpl) DeviceSpecific() bool { +func (b *baseModuleContext) DeviceSpecific() bool { return b.kind == deviceSpecificModule } -func (b *baseContextImpl) SocSpecific() bool { +func (b *baseModuleContext) SocSpecific() bool { return b.kind == socSpecificModule } -func (b *baseContextImpl) ProductSpecific() bool { +func (b *baseModuleContext) ProductSpecific() bool { return b.kind == productSpecificModule } -func (b *baseContextImpl) ProductServicesSpecific() bool { +func (b *baseModuleContext) ProductServicesSpecific() bool { return b.kind == productServicesSpecificModule } diff --git a/android/mutator.go b/android/mutator.go index 5a92f7057..cd0d152db 100644 --- a/android/mutator.go +++ b/android/mutator.go @@ -114,7 +114,6 @@ type TopDownMutator func(TopDownMutatorContext) type TopDownMutatorContext interface { BaseModuleContext - baseContext OtherModuleExists(name string) bool Rename(name string) @@ -143,7 +142,7 @@ type TopDownMutatorContext interface { type topDownMutatorContext struct { blueprint.TopDownMutatorContext - baseContextImpl + baseModuleContext walkPath []Module } @@ -151,7 +150,6 @@ type BottomUpMutator func(BottomUpMutatorContext) type BottomUpMutatorContext interface { BaseModuleContext - baseContext OtherModuleExists(name string) bool Rename(name string) @@ -170,7 +168,7 @@ type BottomUpMutatorContext interface { type bottomUpMutatorContext struct { blueprint.BottomUpMutatorContext - baseContextImpl + baseModuleContext } func (x *registerMutatorsContext) BottomUp(name string, m BottomUpMutator) MutatorHandle { @@ -178,7 +176,7 @@ func (x *registerMutatorsContext) BottomUp(name string, m BottomUpMutator) Mutat if a, ok := ctx.Module().(Module); ok { actx := &bottomUpMutatorContext{ BottomUpMutatorContext: ctx, - baseContextImpl: a.base().baseContextFactory(ctx), + baseModuleContext: a.base().baseModuleContextFactory(ctx), } m(actx) } @@ -193,7 +191,7 @@ func (x *registerMutatorsContext) TopDown(name string, m TopDownMutator) Mutator if a, ok := ctx.Module().(Module); ok { actx := &topDownMutatorContext{ TopDownMutatorContext: ctx, - baseContextImpl: a.base().baseContextFactory(ctx), + baseModuleContext: a.base().baseModuleContextFactory(ctx), } m(actx) } diff --git a/android/paths.go b/android/paths.go index d7d779297..52d22d531 100644 --- a/android/paths.go +++ b/android/paths.go @@ -41,9 +41,7 @@ var _ PathContext = SingletonContext(nil) var _ PathContext = ModuleContext(nil) type ModuleInstallPathContext interface { - PathContext - - baseContext + BaseModuleContext InstallInData() bool InstallInSanitizerDir() bool diff --git a/android/paths_test.go b/android/paths_test.go index dc42c762c..78cfbbe78 100644 --- a/android/paths_test.go +++ b/android/paths_test.go @@ -200,7 +200,7 @@ func p(in interface{}) string { } type moduleInstallPathContextImpl struct { - baseContextImpl + baseModuleContext inData bool inSanitizerDir bool @@ -212,7 +212,7 @@ func (moduleInstallPathContextImpl) Fs() pathtools.FileSystem { } func (m moduleInstallPathContextImpl) Config() Config { - return m.baseContextImpl.config + return m.baseModuleContext.config } func (moduleInstallPathContextImpl) AddNinjaFileDeps(deps ...string) {} @@ -244,7 +244,7 @@ func TestPathForModuleInstall(t *testing.T) { { name: "host binary", ctx: &moduleInstallPathContextImpl{ - baseContextImpl: baseContextImpl{ + baseModuleContext: baseModuleContext{ target: hostTarget, }, }, @@ -255,7 +255,7 @@ func TestPathForModuleInstall(t *testing.T) { { name: "system binary", ctx: &moduleInstallPathContextImpl{ - baseContextImpl: baseContextImpl{ + baseModuleContext: baseModuleContext{ target: deviceTarget, }, }, @@ -265,7 +265,7 @@ func TestPathForModuleInstall(t *testing.T) { { name: "vendor binary", ctx: &moduleInstallPathContextImpl{ - baseContextImpl: baseContextImpl{ + baseModuleContext: baseModuleContext{ target: deviceTarget, kind: socSpecificModule, }, @@ -276,7 +276,7 @@ func TestPathForModuleInstall(t *testing.T) { { name: "odm binary", ctx: &moduleInstallPathContextImpl{ - baseContextImpl: baseContextImpl{ + baseModuleContext: baseModuleContext{ target: deviceTarget, kind: deviceSpecificModule, }, @@ -287,7 +287,7 @@ func TestPathForModuleInstall(t *testing.T) { { name: "product binary", ctx: &moduleInstallPathContextImpl{ - baseContextImpl: baseContextImpl{ + baseModuleContext: baseModuleContext{ target: deviceTarget, kind: productSpecificModule, }, @@ -298,7 +298,7 @@ func TestPathForModuleInstall(t *testing.T) { { name: "product_services binary", ctx: &moduleInstallPathContextImpl{ - baseContextImpl: baseContextImpl{ + baseModuleContext: baseModuleContext{ target: deviceTarget, kind: productServicesSpecificModule, }, @@ -310,7 +310,7 @@ func TestPathForModuleInstall(t *testing.T) { { name: "system native test binary", ctx: &moduleInstallPathContextImpl{ - baseContextImpl: baseContextImpl{ + baseModuleContext: baseModuleContext{ target: deviceTarget, }, inData: true, @@ -321,7 +321,7 @@ func TestPathForModuleInstall(t *testing.T) { { name: "vendor native test binary", ctx: &moduleInstallPathContextImpl{ - baseContextImpl: baseContextImpl{ + baseModuleContext: baseModuleContext{ target: deviceTarget, kind: socSpecificModule, }, @@ -333,7 +333,7 @@ func TestPathForModuleInstall(t *testing.T) { { name: "odm native test binary", ctx: &moduleInstallPathContextImpl{ - baseContextImpl: baseContextImpl{ + baseModuleContext: baseModuleContext{ target: deviceTarget, kind: deviceSpecificModule, }, @@ -345,7 +345,7 @@ func TestPathForModuleInstall(t *testing.T) { { name: "product native test binary", ctx: &moduleInstallPathContextImpl{ - baseContextImpl: baseContextImpl{ + baseModuleContext: baseModuleContext{ target: deviceTarget, kind: productSpecificModule, }, @@ -358,7 +358,7 @@ func TestPathForModuleInstall(t *testing.T) { { name: "product_services native test binary", ctx: &moduleInstallPathContextImpl{ - baseContextImpl: baseContextImpl{ + baseModuleContext: baseModuleContext{ target: deviceTarget, kind: productServicesSpecificModule, }, @@ -371,7 +371,7 @@ func TestPathForModuleInstall(t *testing.T) { { name: "sanitized system binary", ctx: &moduleInstallPathContextImpl{ - baseContextImpl: baseContextImpl{ + baseModuleContext: baseModuleContext{ target: deviceTarget, }, inSanitizerDir: true, @@ -382,7 +382,7 @@ func TestPathForModuleInstall(t *testing.T) { { name: "sanitized vendor binary", ctx: &moduleInstallPathContextImpl{ - baseContextImpl: baseContextImpl{ + baseModuleContext: baseModuleContext{ target: deviceTarget, kind: socSpecificModule, }, @@ -394,7 +394,7 @@ func TestPathForModuleInstall(t *testing.T) { { name: "sanitized odm binary", ctx: &moduleInstallPathContextImpl{ - baseContextImpl: baseContextImpl{ + baseModuleContext: baseModuleContext{ target: deviceTarget, kind: deviceSpecificModule, }, @@ -406,7 +406,7 @@ func TestPathForModuleInstall(t *testing.T) { { name: "sanitized product binary", ctx: &moduleInstallPathContextImpl{ - baseContextImpl: baseContextImpl{ + baseModuleContext: baseModuleContext{ target: deviceTarget, kind: productSpecificModule, }, @@ -419,7 +419,7 @@ func TestPathForModuleInstall(t *testing.T) { { name: "sanitized product_services binary", ctx: &moduleInstallPathContextImpl{ - baseContextImpl: baseContextImpl{ + baseModuleContext: baseModuleContext{ target: deviceTarget, kind: productServicesSpecificModule, }, @@ -432,7 +432,7 @@ func TestPathForModuleInstall(t *testing.T) { { name: "sanitized system native test binary", ctx: &moduleInstallPathContextImpl{ - baseContextImpl: baseContextImpl{ + baseModuleContext: baseModuleContext{ target: deviceTarget, }, inData: true, @@ -444,7 +444,7 @@ func TestPathForModuleInstall(t *testing.T) { { name: "sanitized vendor native test binary", ctx: &moduleInstallPathContextImpl{ - baseContextImpl: baseContextImpl{ + baseModuleContext: baseModuleContext{ target: deviceTarget, kind: socSpecificModule, }, @@ -457,7 +457,7 @@ func TestPathForModuleInstall(t *testing.T) { { name: "sanitized odm native test binary", ctx: &moduleInstallPathContextImpl{ - baseContextImpl: baseContextImpl{ + baseModuleContext: baseModuleContext{ target: deviceTarget, kind: deviceSpecificModule, }, @@ -470,7 +470,7 @@ func TestPathForModuleInstall(t *testing.T) { { name: "sanitized product native test binary", ctx: &moduleInstallPathContextImpl{ - baseContextImpl: baseContextImpl{ + baseModuleContext: baseModuleContext{ target: deviceTarget, kind: productSpecificModule, }, @@ -483,7 +483,7 @@ func TestPathForModuleInstall(t *testing.T) { { name: "sanitized product_services native test binary", ctx: &moduleInstallPathContextImpl{ - baseContextImpl: baseContextImpl{ + baseModuleContext: baseModuleContext{ target: deviceTarget, kind: productServicesSpecificModule, }, @@ -497,7 +497,7 @@ func TestPathForModuleInstall(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - tc.ctx.baseContextImpl.config = testConfig + tc.ctx.baseModuleContext.config = testConfig output := PathForModuleInstall(tc.ctx, tc.in...) if output.basePath.path != tc.out { t.Errorf("unexpected path:\n got: %q\nwant: %q\n", diff --git a/apex/apex.go b/apex/apex.go index aed7d6fd2..41a21c92c 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -552,7 +552,7 @@ func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) { } } -func (a *apexBundle) getCertString(ctx android.BaseContext) string { +func (a *apexBundle) getCertString(ctx android.BaseModuleContext) string { certificate, overridden := ctx.DeviceConfig().OverrideCertificateFor(ctx.ModuleName()) if overridden { return ":" + certificate diff --git a/cc/cc.go b/cc/cc.go index e61857d87..559fe4b8f 100644 --- a/cc/cc.go +++ b/cc/cc.go @@ -278,7 +278,7 @@ type ModuleContext interface { } type BaseModuleContext interface { - android.BaseContext + android.BaseModuleContext ModuleContextIntf } @@ -641,7 +641,7 @@ func installToBootstrap(name string, config android.Config) bool { } type baseModuleContext struct { - android.BaseContext + android.BaseModuleContext moduleContextImpl } @@ -1040,7 +1040,7 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) { } } -func (c *Module) toolchain(ctx android.BaseContext) config.Toolchain { +func (c *Module) toolchain(ctx android.BaseModuleContext) config.Toolchain { if c.cachedToolchain == nil { c.cachedToolchain = config.FindToolchain(ctx.Os(), ctx.Arch()) } @@ -1161,7 +1161,7 @@ func (c *Module) deps(ctx DepsContext) Deps { func (c *Module) beginMutator(actx android.BottomUpMutatorContext) { ctx := &baseModuleContext{ - BaseContext: actx, + BaseModuleContext: actx, moduleContextImpl: moduleContextImpl{ mod: c, }, diff --git a/cc/ndk_library.go b/cc/ndk_library.go index ff990b5f7..44f773c52 100644 --- a/cc/ndk_library.go +++ b/cc/ndk_library.go @@ -121,7 +121,7 @@ func intMax(a int, b int) int { } } -func normalizeNdkApiLevel(ctx android.BaseContext, apiLevel string, +func normalizeNdkApiLevel(ctx android.BaseModuleContext, apiLevel string, arch android.Arch) (string, error) { if apiLevel == "current" { @@ -167,7 +167,7 @@ func getFirstGeneratedVersion(firstSupportedVersion string, platformVersion int) return strconv.Atoi(firstSupportedVersion) } -func shouldUseVersionScript(ctx android.BaseContext, stub *stubDecorator) (bool, error) { +func shouldUseVersionScript(ctx android.BaseModuleContext, stub *stubDecorator) (bool, error) { // unversioned_until is normally empty, in which case we should use the version script. if String(stub.properties.Unversioned_until) == "" { return true, nil diff --git a/java/app.go b/java/app.go index 3c8f84748..cf9354f57 100644 --- a/java/app.go +++ b/java/app.go @@ -482,7 +482,7 @@ func collectAppDeps(ctx android.ModuleContext) ([]jniLib, []Certificate) { return jniLibs, certificates } -func (a *AndroidApp) getCertString(ctx android.BaseContext) string { +func (a *AndroidApp) getCertString(ctx android.BaseModuleContext) string { certificate, overridden := ctx.DeviceConfig().OverrideCertificateFor(ctx.ModuleName()) if overridden { return ":" + certificate diff --git a/java/java.go b/java/java.go index 5544f5763..fee262d83 100644 --- a/java/java.go +++ b/java/java.go @@ -380,8 +380,8 @@ type Dependency interface { } type SdkLibraryDependency interface { - SdkHeaderJars(ctx android.BaseContext, sdkVersion string) android.Paths - SdkImplementationJars(ctx android.BaseContext, sdkVersion string) android.Paths + SdkHeaderJars(ctx android.BaseModuleContext, sdkVersion string) android.Paths + SdkImplementationJars(ctx android.BaseModuleContext, sdkVersion string) android.Paths } type SrcDependency interface { @@ -448,11 +448,11 @@ type jniLib struct { target android.Target } -func (j *Module) shouldInstrument(ctx android.BaseContext) bool { +func (j *Module) shouldInstrument(ctx android.BaseModuleContext) bool { return j.properties.Instrument && ctx.Config().IsEnvTrue("EMMA_INSTRUMENT") } -func (j *Module) shouldInstrumentStatic(ctx android.BaseContext) bool { +func (j *Module) shouldInstrumentStatic(ctx android.BaseModuleContext) bool { return j.shouldInstrument(ctx) && (ctx.Config().IsEnvTrue("EMMA_INSTRUMENT_STATIC") || ctx.Config().UnbundledBuild()) diff --git a/java/sdk.go b/java/sdk.go index 506edfb51..90b8fac28 100644 --- a/java/sdk.go +++ b/java/sdk.go @@ -46,7 +46,7 @@ type sdkContext interface { targetSdkVersion() string } -func sdkVersionOrDefault(ctx android.BaseContext, v string) string { +func sdkVersionOrDefault(ctx android.BaseModuleContext, v string) string { switch v { case "", "current", "system_current", "test_current", "core_current": return ctx.Config().DefaultAppTargetSdk() @@ -57,7 +57,7 @@ func sdkVersionOrDefault(ctx android.BaseContext, v string) string { // Returns a sdk version as a number. For modules targeting an unreleased SDK (meaning it does not yet have a number) // it returns android.FutureApiLevel (10000). -func sdkVersionToNumber(ctx android.BaseContext, v string) (int, error) { +func sdkVersionToNumber(ctx android.BaseModuleContext, v string) (int, error) { switch v { case "", "current", "test_current", "system_current", "core_current": return ctx.Config().DefaultAppTargetSdkInt(), nil @@ -71,7 +71,7 @@ func sdkVersionToNumber(ctx android.BaseContext, v string) (int, error) { } } -func sdkVersionToNumberAsString(ctx android.BaseContext, v string) (string, error) { +func sdkVersionToNumberAsString(ctx android.BaseModuleContext, v string) (string, error) { n, err := sdkVersionToNumber(ctx, v) if err != nil { return "", err @@ -79,7 +79,7 @@ func sdkVersionToNumberAsString(ctx android.BaseContext, v string) (string, erro return strconv.Itoa(n), nil } -func decodeSdkDep(ctx android.BaseContext, sdkContext sdkContext) sdkDep { +func decodeSdkDep(ctx android.BaseModuleContext, sdkContext sdkContext) sdkDep { v := sdkContext.sdkVersion() // For PDK builds, use the latest SDK version instead of "current" if ctx.Config().IsPdkBuild() && (v == "" || v == "current") { diff --git a/java/sdk_library.go b/java/sdk_library.go index 5b65c0ca0..e38353340 100644 --- a/java/sdk_library.go +++ b/java/sdk_library.go @@ -591,7 +591,7 @@ func (module *SdkLibrary) createXmlFile(mctx android.LoadHookContext) { mctx.CreateModule(android.ModuleFactoryAdaptor(android.PrebuiltEtcFactory), &etcProps) } -func (module *SdkLibrary) PrebuiltJars(ctx android.BaseContext, sdkVersion string) android.Paths { +func (module *SdkLibrary) PrebuiltJars(ctx android.BaseModuleContext, sdkVersion string) android.Paths { var api, v string if sdkVersion == "" { api = "system" @@ -615,7 +615,7 @@ func (module *SdkLibrary) PrebuiltJars(ctx android.BaseContext, sdkVersion strin } // to satisfy SdkLibraryDependency interface -func (module *SdkLibrary) SdkHeaderJars(ctx android.BaseContext, sdkVersion string) android.Paths { +func (module *SdkLibrary) SdkHeaderJars(ctx android.BaseModuleContext, sdkVersion string) android.Paths { // This module is just a wrapper for the stubs. if ctx.Config().UnbundledBuildUsePrebuiltSdks() { return module.PrebuiltJars(ctx, sdkVersion) @@ -631,7 +631,7 @@ func (module *SdkLibrary) SdkHeaderJars(ctx android.BaseContext, sdkVersion stri } // to satisfy SdkLibraryDependency interface -func (module *SdkLibrary) SdkImplementationJars(ctx android.BaseContext, sdkVersion string) android.Paths { +func (module *SdkLibrary) SdkImplementationJars(ctx android.BaseModuleContext, sdkVersion string) android.Paths { // This module is just a wrapper for the stubs. if ctx.Config().UnbundledBuildUsePrebuiltSdks() { return module.PrebuiltJars(ctx, sdkVersion) @@ -840,13 +840,13 @@ func (module *sdkLibraryImport) GenerateAndroidBuildActions(ctx android.ModuleCo } // to satisfy SdkLibraryDependency interface -func (module *sdkLibraryImport) SdkHeaderJars(ctx android.BaseContext, sdkVersion string) android.Paths { +func (module *sdkLibraryImport) SdkHeaderJars(ctx android.BaseModuleContext, sdkVersion string) android.Paths { // This module is just a wrapper for the prebuilt stubs. return module.stubsPath } // to satisfy SdkLibraryDependency interface -func (module *sdkLibraryImport) SdkImplementationJars(ctx android.BaseContext, sdkVersion string) android.Paths { +func (module *sdkLibraryImport) SdkImplementationJars(ctx android.BaseModuleContext, sdkVersion string) android.Paths { // This module is just a wrapper for the stubs. return module.stubsPath }