diff options
Diffstat (limited to 'java')
| -rwxr-xr-x | java/app.go | 13 | ||||
| -rw-r--r-- | java/sdk_library.go | 17 |
2 files changed, 22 insertions, 8 deletions
diff --git a/java/app.go b/java/app.go index d25575c99..43bdc91de 100755 --- a/java/app.go +++ b/java/app.go @@ -80,10 +80,14 @@ type appProperties struct { // list of native libraries that will be provided in or alongside the resulting jar Jni_libs []string `android:"arch_variant"` - // if true, allow JNI libraries that link against platform APIs even if this module sets + // if true, use JNI libraries that link against platform APIs even if this module sets // sdk_version. Jni_uses_platform_apis *bool + // if true, use JNI libraries that link against SDK APIs even if this module does not set + // sdk_version. + Jni_uses_sdk_apis *bool + // STL library to use for JNI libraries. Stl *string `android:"arch_variant"` @@ -234,7 +238,8 @@ func (a *AndroidApp) DepsMutator(ctx android.BottomUpMutatorContext) { // If the app builds against an Android SDK use the SDK variant of JNI dependencies // unless jni_uses_platform_apis is set. if a.sdkVersion().specified() && a.sdkVersion().kind != sdkCorePlatform && - !Bool(a.appProperties.Jni_uses_platform_apis) { + !Bool(a.appProperties.Jni_uses_platform_apis) || + Bool(a.appProperties.Jni_uses_sdk_apis) { variation = append(variation, blueprint.Variation{Mutator: "sdk", Variation: "sdk"}) } ctx.AddFarVariationDependencies(variation, tag, a.appProperties.Jni_libs...) @@ -714,6 +719,8 @@ func (a *AndroidApp) MarkAsCoverageVariant(coverage bool) { a.appProperties.IsCoverageVariant = coverage } +func (a *AndroidApp) EnableCoverageIfNeeded() {} + var _ cc.Coverage = (*AndroidApp)(nil) // android_app compiles sources and Android resources into an Android application package `.apk` file. @@ -1391,6 +1398,8 @@ func AndroidTestImportFactory() android.Module { module.processVariants(ctx) }) + module.dexpreopter.isTest = true + android.InitApexModule(module) android.InitAndroidMultiTargetsArchModule(module, android.DeviceSupported, android.MultilibCommon) android.InitDefaultableModule(module) diff --git a/java/sdk_library.go b/java/sdk_library.go index 4d480ee1b..39c118d34 100644 --- a/java/sdk_library.go +++ b/java/sdk_library.go @@ -387,7 +387,7 @@ func (module *SdkLibrary) apiDistPath(apiScope *apiScope) string { } // Get the sdk version for use when compiling the stubs library. -func (module *SdkLibrary) sdkVersionForStubsLibrary(mctx android.LoadHookContext, apiScope *apiScope) string { +func (module *SdkLibrary) sdkVersionForStubsLibrary(mctx android.DefaultableHookContext, apiScope *apiScope) string { sdkDep := decodeSdkDep(mctx, sdkContext(&module.Library)) if sdkDep.hasStandardLibs() { // If building against a standard sdk then use the sdk version appropriate for the scope. @@ -407,7 +407,7 @@ func (module *SdkLibrary) latestRemovedApiFilegroupName(apiScope *apiScope) stri } // Creates a static java library that has API stubs -func (module *SdkLibrary) createStubsLibrary(mctx android.LoadHookContext, apiScope *apiScope) { +func (module *SdkLibrary) createStubsLibrary(mctx android.DefaultableHookContext, apiScope *apiScope) { props := struct { Name *string Srcs []string @@ -478,7 +478,7 @@ func (module *SdkLibrary) createStubsLibrary(mctx android.LoadHookContext, apiSc // Creates a droidstubs module that creates stubs source files from the given full source // files -func (module *SdkLibrary) createStubsSources(mctx android.LoadHookContext, apiScope *apiScope) { +func (module *SdkLibrary) createStubsSources(mctx android.DefaultableHookContext, apiScope *apiScope) { props := struct { Name *string Srcs []string @@ -597,7 +597,7 @@ func (module *SdkLibrary) DepIsInSameApex(mctx android.BaseModuleContext, dep an } // Creates the xml file that publicizes the runtime library -func (module *SdkLibrary) createXmlFile(mctx android.LoadHookContext) { +func (module *SdkLibrary) createXmlFile(mctx android.DefaultableHookContext) { props := struct { Name *string Lib_name *string @@ -718,7 +718,12 @@ func (module *SdkLibrary) getApiDir() string { // For a java_sdk_library module, create internal modules for stubs, docs, // runtime libs and xml file. If requested, the stubs and docs are created twice // once for public API level and once for system API level -func (module *SdkLibrary) CreateInternalModules(mctx android.LoadHookContext) { +func (module *SdkLibrary) CreateInternalModules(mctx android.DefaultableHookContext) { + // If the module has been disabled then don't create any child modules. + if !module.Enabled() { + return + } + if len(module.Library.Module.properties.Srcs) == 0 { mctx.PropertyErrorf("srcs", "java_sdk_library must specify srcs") return @@ -804,7 +809,7 @@ func SdkLibraryFactory() android.Module { module.InitSdkLibraryProperties() android.InitApexModule(module) InitJavaModule(module, android.HostAndDeviceSupported) - android.AddLoadHook(module, func(ctx android.LoadHookContext) { module.CreateInternalModules(ctx) }) + module.SetDefaultableHook(func(ctx android.DefaultableHookContext) { module.CreateInternalModules(ctx) }) return module } |