2018-04-10 06:07:10 +02:00
|
|
|
// Copyright 2018 Google Inc. All rights reserved.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
package java
|
|
|
|
|
|
|
|
import (
|
|
|
|
"android/soong/android"
|
2020-02-06 14:51:46 +01:00
|
|
|
"android/soong/genrule"
|
2020-01-22 12:57:20 +01:00
|
|
|
|
2018-04-10 06:07:10 +02:00
|
|
|
"fmt"
|
2018-04-23 14:41:26 +02:00
|
|
|
"io"
|
2018-04-10 06:07:10 +02:00
|
|
|
"path"
|
2018-10-19 06:46:09 +02:00
|
|
|
"path/filepath"
|
2018-04-23 14:41:26 +02:00
|
|
|
"sort"
|
2018-04-10 06:07:10 +02:00
|
|
|
"strings"
|
2018-04-23 14:41:26 +02:00
|
|
|
"sync"
|
2018-04-10 06:07:10 +02:00
|
|
|
|
2020-01-22 12:57:20 +01:00
|
|
|
"github.com/google/blueprint"
|
2018-04-10 06:07:10 +02:00
|
|
|
"github.com/google/blueprint/proptools"
|
|
|
|
)
|
|
|
|
|
2019-12-18 07:34:32 +01:00
|
|
|
const (
|
2018-04-10 06:07:10 +02:00
|
|
|
sdkStubsLibrarySuffix = ".stubs"
|
|
|
|
sdkSystemApiSuffix = ".system"
|
2018-04-27 09:29:21 +02:00
|
|
|
sdkTestApiSuffix = ".test"
|
2018-04-10 06:07:10 +02:00
|
|
|
sdkDocsSuffix = ".docs"
|
|
|
|
sdkXmlFileSuffix = ".xml"
|
2019-12-24 10:38:06 +01:00
|
|
|
permissionsTemplate = `<?xml version="1.0" encoding="utf-8"?>\n` +
|
|
|
|
`<!-- Copyright (C) 2018 The Android Open Source Project\n` +
|
|
|
|
`\n` +
|
|
|
|
` Licensed under the Apache License, Version 2.0 (the "License");\n` +
|
|
|
|
` you may not use this file except in compliance with the License.\n` +
|
|
|
|
` You may obtain a copy of the License at\n` +
|
|
|
|
`\n` +
|
|
|
|
` http://www.apache.org/licenses/LICENSE-2.0\n` +
|
|
|
|
`\n` +
|
|
|
|
` Unless required by applicable law or agreed to in writing, software\n` +
|
|
|
|
` distributed under the License is distributed on an "AS IS" BASIS,\n` +
|
|
|
|
` WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n` +
|
|
|
|
` See the License for the specific language governing permissions and\n` +
|
|
|
|
` limitations under the License.\n` +
|
|
|
|
`-->\n` +
|
|
|
|
`<permissions>\n` +
|
|
|
|
` <library name="%s" file="%s"/>\n` +
|
|
|
|
`</permissions>\n`
|
2018-04-10 06:07:10 +02:00
|
|
|
)
|
|
|
|
|
2020-01-22 12:57:20 +01:00
|
|
|
// A tag to associated a dependency with a specific api scope.
|
|
|
|
type scopeDependencyTag struct {
|
|
|
|
blueprint.BaseDependencyTag
|
|
|
|
name string
|
|
|
|
apiScope *apiScope
|
|
|
|
}
|
2018-04-27 09:29:21 +02:00
|
|
|
|
2020-01-22 12:57:20 +01:00
|
|
|
// Provides information about an api scope, e.g. public, system, test.
|
|
|
|
type apiScope struct {
|
|
|
|
// The name of the api scope, e.g. public, system, test
|
|
|
|
name string
|
2018-04-27 09:29:21 +02:00
|
|
|
|
2020-01-22 12:57:20 +01:00
|
|
|
// The tag to use to depend on the stubs library module.
|
|
|
|
stubsTag scopeDependencyTag
|
|
|
|
|
|
|
|
// The tag to use to depend on the stubs
|
|
|
|
apiFileTag scopeDependencyTag
|
|
|
|
|
|
|
|
// The scope specific prefix to add to the api file base of "current.txt" or "removed.txt".
|
|
|
|
apiFilePrefix string
|
|
|
|
|
|
|
|
// The scope specific prefix to add to the sdk library module name to construct a scope specific
|
|
|
|
// module name.
|
|
|
|
moduleSuffix string
|
|
|
|
|
|
|
|
// The suffix to add to the make variable that references the location of the api file.
|
|
|
|
apiFileMakeVariableSuffix string
|
|
|
|
|
|
|
|
// SDK version that the stubs library is built against. Note that this is always
|
|
|
|
// *current. Older stubs library built with a numbered SDK version is created from
|
|
|
|
// the prebuilt jar.
|
|
|
|
sdkVersion string
|
|
|
|
}
|
|
|
|
|
|
|
|
// Initialize a scope, creating and adding appropriate dependency tags
|
|
|
|
func initApiScope(scope *apiScope) *apiScope {
|
|
|
|
//apiScope := &scope
|
|
|
|
scope.stubsTag = scopeDependencyTag{
|
|
|
|
name: scope.name + "-stubs",
|
|
|
|
apiScope: scope,
|
|
|
|
}
|
|
|
|
scope.apiFileTag = scopeDependencyTag{
|
|
|
|
name: scope.name + "-api",
|
|
|
|
apiScope: scope,
|
|
|
|
}
|
|
|
|
return scope
|
|
|
|
}
|
|
|
|
|
|
|
|
func (scope *apiScope) stubsModuleName(baseName string) string {
|
|
|
|
return baseName + sdkStubsLibrarySuffix + scope.moduleSuffix
|
|
|
|
}
|
|
|
|
|
|
|
|
func (scope *apiScope) docsModuleName(baseName string) string {
|
|
|
|
return baseName + sdkDocsSuffix + scope.moduleSuffix
|
|
|
|
}
|
|
|
|
|
|
|
|
type apiScopes []*apiScope
|
|
|
|
|
|
|
|
func (scopes apiScopes) Strings(accessor func(*apiScope) string) []string {
|
|
|
|
var list []string
|
|
|
|
for _, scope := range scopes {
|
|
|
|
list = append(list, accessor(scope))
|
|
|
|
}
|
|
|
|
return list
|
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
|
|
|
apiScopePublic = initApiScope(&apiScope{
|
|
|
|
name: "public",
|
|
|
|
sdkVersion: "current",
|
|
|
|
})
|
|
|
|
apiScopeSystem = initApiScope(&apiScope{
|
|
|
|
name: "system",
|
|
|
|
apiFilePrefix: "system-",
|
|
|
|
moduleSuffix: sdkSystemApiSuffix,
|
|
|
|
apiFileMakeVariableSuffix: "_SYSTEM",
|
|
|
|
sdkVersion: "system_current",
|
|
|
|
})
|
|
|
|
apiScopeTest = initApiScope(&apiScope{
|
|
|
|
name: "test",
|
|
|
|
apiFilePrefix: "test-",
|
|
|
|
moduleSuffix: sdkTestApiSuffix,
|
|
|
|
apiFileMakeVariableSuffix: "_TEST",
|
|
|
|
sdkVersion: "test_current",
|
|
|
|
})
|
|
|
|
allApiScopes = apiScopes{
|
|
|
|
apiScopePublic,
|
|
|
|
apiScopeSystem,
|
|
|
|
apiScopeTest,
|
|
|
|
}
|
2018-04-10 06:07:10 +02:00
|
|
|
)
|
|
|
|
|
2018-04-23 14:41:26 +02:00
|
|
|
var (
|
|
|
|
javaSdkLibrariesLock sync.Mutex
|
|
|
|
)
|
|
|
|
|
2018-04-10 06:07:10 +02:00
|
|
|
// TODO: these are big features that are currently missing
|
2018-05-28 11:02:19 +02:00
|
|
|
// 1) disallowing linking to the runtime shared lib
|
|
|
|
// 2) HTML generation
|
2018-04-10 06:07:10 +02:00
|
|
|
|
|
|
|
func init() {
|
2019-12-19 12:18:54 +01:00
|
|
|
RegisterSdkLibraryBuildComponents(android.InitRegistrationContext)
|
2018-04-10 06:07:10 +02:00
|
|
|
|
2018-04-23 14:41:26 +02:00
|
|
|
android.RegisterMakeVarsProvider(pctx, func(ctx android.MakeVarsContext) {
|
|
|
|
javaSdkLibraries := javaSdkLibraries(ctx.Config())
|
|
|
|
sort.Strings(*javaSdkLibraries)
|
|
|
|
ctx.Strict("JAVA_SDK_LIBRARIES", strings.Join(*javaSdkLibraries, " "))
|
|
|
|
})
|
2018-04-10 06:07:10 +02:00
|
|
|
}
|
|
|
|
|
2019-12-19 12:18:54 +01:00
|
|
|
func RegisterSdkLibraryBuildComponents(ctx android.RegistrationContext) {
|
|
|
|
ctx.RegisterModuleType("java_sdk_library", SdkLibraryFactory)
|
|
|
|
ctx.RegisterModuleType("java_sdk_library_import", sdkLibraryImportFactory)
|
|
|
|
}
|
|
|
|
|
2018-04-10 06:07:10 +02:00
|
|
|
type sdkLibraryProperties struct {
|
2018-06-25 09:04:37 +02:00
|
|
|
// List of Java libraries that will be in the classpath when building stubs
|
|
|
|
Stub_only_libs []string `android:"arch_variant"`
|
|
|
|
|
2019-12-30 18:09:34 +01:00
|
|
|
// list of package names that will be documented and publicized as API.
|
|
|
|
// This allows the API to be restricted to a subset of the source files provided.
|
|
|
|
// If this is unspecified then all the source files will be treated as being part
|
|
|
|
// of the API.
|
2018-04-10 06:07:10 +02:00
|
|
|
Api_packages []string
|
|
|
|
|
2018-05-01 15:25:41 +02:00
|
|
|
// list of package names that must be hidden from the API
|
|
|
|
Hidden_api_packages []string
|
|
|
|
|
2019-12-30 18:23:46 +01:00
|
|
|
// the relative path to the directory containing the api specification files.
|
|
|
|
// Defaults to "api".
|
|
|
|
Api_dir *string
|
|
|
|
|
2019-12-30 18:35:49 +01:00
|
|
|
// If set to true there is no runtime library.
|
|
|
|
Api_only *bool
|
|
|
|
|
2019-02-11 16:55:17 +01:00
|
|
|
// local files that are used within user customized droiddoc options.
|
|
|
|
Droiddoc_option_files []string
|
|
|
|
|
|
|
|
// additional droiddoc options
|
|
|
|
// Available variables for substitution:
|
|
|
|
//
|
|
|
|
// $(location <label>): the path to the droiddoc_option_files with name <label>
|
2018-07-31 10:19:11 +02:00
|
|
|
Droiddoc_options []string
|
|
|
|
|
2018-10-19 06:46:09 +02:00
|
|
|
// a list of top-level directories containing files to merge qualifier annotations
|
|
|
|
// (i.e. those intended to be included in the stubs written) from.
|
|
|
|
Merge_annotations_dirs []string
|
|
|
|
|
|
|
|
// a list of top-level directories containing Java stub files to merge show/hide annotations from.
|
|
|
|
Merge_inclusion_annotations_dirs []string
|
|
|
|
|
|
|
|
// If set to true, the path of dist files is apistubs/core. Defaults to false.
|
|
|
|
Core_lib *bool
|
|
|
|
|
2019-05-13 08:02:50 +02:00
|
|
|
// don't create dist rules.
|
|
|
|
No_dist *bool `blueprint:"mutated"`
|
|
|
|
|
2019-12-30 18:20:10 +01:00
|
|
|
// indicates whether system and test apis should be managed.
|
|
|
|
Has_system_and_test_apis bool `blueprint:"mutated"`
|
|
|
|
|
2018-04-10 06:07:10 +02:00
|
|
|
// TODO: determines whether to create HTML doc or not
|
|
|
|
//Html_doc *bool
|
|
|
|
}
|
|
|
|
|
2020-01-22 12:57:20 +01:00
|
|
|
type scopePaths struct {
|
|
|
|
stubsHeaderPath android.Paths
|
|
|
|
stubsImplPath android.Paths
|
|
|
|
apiFilePath android.Path
|
|
|
|
}
|
|
|
|
|
2020-01-31 14:36:25 +01:00
|
|
|
// Common code between sdk library and sdk library import
|
|
|
|
type commonToSdkLibraryAndImport struct {
|
|
|
|
scopePaths map[*apiScope]*scopePaths
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *commonToSdkLibraryAndImport) getScopePaths(scope *apiScope) *scopePaths {
|
|
|
|
if c.scopePaths == nil {
|
|
|
|
c.scopePaths = make(map[*apiScope]*scopePaths)
|
|
|
|
}
|
|
|
|
paths := c.scopePaths[scope]
|
|
|
|
if paths == nil {
|
|
|
|
paths = &scopePaths{}
|
|
|
|
c.scopePaths[scope] = paths
|
|
|
|
}
|
|
|
|
|
|
|
|
return paths
|
|
|
|
}
|
|
|
|
|
2019-02-08 13:00:45 +01:00
|
|
|
type SdkLibrary struct {
|
2018-10-19 06:46:09 +02:00
|
|
|
Library
|
2018-04-10 06:07:10 +02:00
|
|
|
|
2018-10-19 06:46:09 +02:00
|
|
|
sdkLibraryProperties sdkLibraryProperties
|
2018-04-10 06:07:10 +02:00
|
|
|
|
2020-01-31 14:36:25 +01:00
|
|
|
commonToSdkLibraryAndImport
|
2019-12-18 07:34:32 +01:00
|
|
|
|
2019-12-24 10:38:06 +01:00
|
|
|
permissionsFile android.Path
|
2018-04-10 06:07:10 +02:00
|
|
|
}
|
|
|
|
|
2019-02-08 13:00:45 +01:00
|
|
|
var _ Dependency = (*SdkLibrary)(nil)
|
|
|
|
var _ SdkLibraryDependency = (*SdkLibrary)(nil)
|
2019-02-11 23:03:51 +01:00
|
|
|
|
2020-01-22 12:57:20 +01:00
|
|
|
func (module *SdkLibrary) getActiveApiScopes() apiScopes {
|
|
|
|
if module.sdkLibraryProperties.Has_system_and_test_apis {
|
|
|
|
return allApiScopes
|
|
|
|
} else {
|
|
|
|
return apiScopes{apiScopePublic}
|
2019-07-15 08:31:16 +02:00
|
|
|
}
|
2020-01-22 12:57:20 +01:00
|
|
|
}
|
2018-10-19 06:46:09 +02:00
|
|
|
|
2020-02-06 14:51:46 +01:00
|
|
|
var xmlPermissionsFileTag = dependencyTag{name: "xml-permissions-file"}
|
|
|
|
|
2020-01-22 12:57:20 +01:00
|
|
|
func (module *SdkLibrary) DepsMutator(ctx android.BottomUpMutatorContext) {
|
|
|
|
for _, apiScope := range module.getActiveApiScopes() {
|
|
|
|
// Add dependencies to the stubs library
|
2020-01-21 17:31:05 +01:00
|
|
|
ctx.AddVariationDependencies(nil, apiScope.stubsTag, module.stubsName(apiScope))
|
2020-01-22 12:57:20 +01:00
|
|
|
|
2020-01-21 17:31:05 +01:00
|
|
|
// And the api file
|
2020-01-22 12:57:20 +01:00
|
|
|
ctx.AddVariationDependencies(nil, apiScope.apiFileTag, module.docsName(apiScope))
|
2018-10-19 06:46:09 +02:00
|
|
|
}
|
|
|
|
|
2020-02-06 14:51:46 +01:00
|
|
|
if !proptools.Bool(module.sdkLibraryProperties.Api_only) {
|
|
|
|
// Add dependency to the rule for generating the xml permissions file
|
|
|
|
ctx.AddDependency(module, xmlPermissionsFileTag, module.genXmlPermissionsFileName())
|
|
|
|
}
|
|
|
|
|
2018-10-19 06:46:09 +02:00
|
|
|
module.Library.deps(ctx)
|
2018-04-10 06:07:10 +02:00
|
|
|
}
|
|
|
|
|
2019-02-08 13:00:45 +01:00
|
|
|
func (module *SdkLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
2019-12-30 18:35:49 +01:00
|
|
|
// Don't build an implementation library if this is api only.
|
|
|
|
if !proptools.Bool(module.sdkLibraryProperties.Api_only) {
|
|
|
|
module.Library.GenerateAndroidBuildActions(ctx)
|
|
|
|
}
|
2018-10-19 06:46:09 +02:00
|
|
|
|
2018-07-06 04:20:23 +02:00
|
|
|
// Record the paths to the header jars of the library (stubs and impl).
|
2020-01-22 12:57:20 +01:00
|
|
|
// When this java_sdk_library is depended upon from others via "libs" property,
|
2018-04-10 06:07:10 +02:00
|
|
|
// the recorded paths will be returned depending on the link type of the caller.
|
|
|
|
ctx.VisitDirectDeps(func(to android.Module) {
|
|
|
|
otherName := ctx.OtherModuleName(to)
|
|
|
|
tag := ctx.OtherModuleDependencyTag(to)
|
|
|
|
|
2018-07-06 04:20:23 +02:00
|
|
|
if lib, ok := to.(Dependency); ok {
|
2020-01-22 12:57:20 +01:00
|
|
|
if scopeTag, ok := tag.(scopeDependencyTag); ok {
|
|
|
|
apiScope := scopeTag.apiScope
|
|
|
|
scopePaths := module.getScopePaths(apiScope)
|
|
|
|
scopePaths.stubsHeaderPath = lib.HeaderJars()
|
|
|
|
scopePaths.stubsImplPath = lib.ImplementationJars()
|
2018-04-10 06:07:10 +02:00
|
|
|
}
|
|
|
|
}
|
2018-07-24 04:19:26 +02:00
|
|
|
if doc, ok := to.(ApiFilePath); ok {
|
2020-01-22 12:57:20 +01:00
|
|
|
if scopeTag, ok := tag.(scopeDependencyTag); ok {
|
|
|
|
apiScope := scopeTag.apiScope
|
|
|
|
scopePaths := module.getScopePaths(apiScope)
|
|
|
|
scopePaths.apiFilePath = doc.ApiFilePath()
|
|
|
|
} else {
|
2018-07-24 04:19:26 +02:00
|
|
|
ctx.ModuleErrorf("depends on module %q of unknown tag %q", otherName, tag)
|
|
|
|
}
|
|
|
|
}
|
2020-02-06 14:51:46 +01:00
|
|
|
if tag == xmlPermissionsFileTag {
|
|
|
|
if genRule, ok := to.(genrule.SourceFileGenerator); ok {
|
|
|
|
pf := genRule.GeneratedSourceFiles()
|
|
|
|
if len(pf) != 1 {
|
|
|
|
ctx.ModuleErrorf("%q failed to generate permission XML", otherName)
|
|
|
|
} else {
|
|
|
|
module.permissionsFile = pf[0]
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ctx.ModuleErrorf("depends on module %q to generate xml permissions file but it does not provide any outputs", otherName)
|
|
|
|
}
|
|
|
|
}
|
2018-04-10 06:07:10 +02:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2019-12-03 05:24:29 +01:00
|
|
|
func (module *SdkLibrary) AndroidMkEntries() []android.AndroidMkEntries {
|
2019-12-30 18:35:49 +01:00
|
|
|
if proptools.Bool(module.sdkLibraryProperties.Api_only) {
|
|
|
|
return nil
|
|
|
|
}
|
2019-12-03 05:24:29 +01:00
|
|
|
entriesList := module.Library.AndroidMkEntries()
|
|
|
|
entries := &entriesList[0]
|
2019-08-29 23:56:03 +02:00
|
|
|
entries.Required = append(entries.Required, module.xmlFileName())
|
|
|
|
|
|
|
|
entries.ExtraFooters = []android.AndroidMkExtraFootersFunc{
|
|
|
|
func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
|
|
|
|
if !Bool(module.sdkLibraryProperties.No_dist) {
|
|
|
|
// Create a phony module that installs the impl library, for the case when this lib is
|
|
|
|
// in PRODUCT_PACKAGES.
|
|
|
|
owner := module.ModuleBase.Owner()
|
|
|
|
if owner == "" {
|
|
|
|
if Bool(module.sdkLibraryProperties.Core_lib) {
|
|
|
|
owner = "core"
|
|
|
|
} else {
|
|
|
|
owner = "android"
|
|
|
|
}
|
|
|
|
}
|
2020-01-22 12:57:20 +01:00
|
|
|
|
|
|
|
// Create dist rules to install the stubs libs and api files to the dist dir
|
|
|
|
for _, apiScope := range module.getActiveApiScopes() {
|
|
|
|
if scopePaths, ok := module.scopePaths[apiScope]; ok {
|
|
|
|
if len(scopePaths.stubsHeaderPath) == 1 {
|
|
|
|
fmt.Fprintln(w, "$(call dist-for-goals,sdk win_sdk,"+
|
|
|
|
scopePaths.stubsImplPath.Strings()[0]+
|
|
|
|
":"+path.Join("apistubs", owner, apiScope.name,
|
|
|
|
module.BaseModuleName()+".jar")+")")
|
|
|
|
}
|
|
|
|
if scopePaths.apiFilePath != nil {
|
|
|
|
fmt.Fprintln(w, "$(call dist-for-goals,sdk win_sdk,"+
|
|
|
|
scopePaths.apiFilePath.String()+
|
|
|
|
":"+path.Join("apistubs", owner, apiScope.name, "api",
|
|
|
|
module.BaseModuleName()+".txt")+")")
|
|
|
|
}
|
|
|
|
}
|
2019-05-13 08:02:50 +02:00
|
|
|
}
|
|
|
|
}
|
2019-08-29 23:56:03 +02:00
|
|
|
},
|
2018-04-23 14:41:26 +02:00
|
|
|
}
|
2019-12-03 05:24:29 +01:00
|
|
|
return entriesList
|
2018-04-23 14:41:26 +02:00
|
|
|
}
|
|
|
|
|
2018-04-10 06:07:10 +02:00
|
|
|
// Module name of the stubs library
|
2020-01-22 12:57:20 +01:00
|
|
|
func (module *SdkLibrary) stubsName(apiScope *apiScope) string {
|
|
|
|
return apiScope.stubsModuleName(module.BaseModuleName())
|
2018-04-10 06:07:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Module name of the docs
|
2020-01-22 12:57:20 +01:00
|
|
|
func (module *SdkLibrary) docsName(apiScope *apiScope) string {
|
|
|
|
return apiScope.docsModuleName(module.BaseModuleName())
|
2018-04-10 06:07:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Module name of the runtime implementation library
|
2019-02-08 13:00:45 +01:00
|
|
|
func (module *SdkLibrary) implName() string {
|
2018-10-19 06:46:09 +02:00
|
|
|
return module.BaseModuleName()
|
2018-04-10 06:07:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// File path to the runtime implementation library
|
2019-02-08 13:00:45 +01:00
|
|
|
func (module *SdkLibrary) implPath() string {
|
2019-12-18 07:34:32 +01:00
|
|
|
if apexName := module.ApexName(); apexName != "" {
|
|
|
|
// TODO(b/146468504): ApexName() is only a soong module name, not apex name.
|
|
|
|
// In most cases, this works fine. But when apex_name is set or override_apex is used
|
|
|
|
// this can be wrong.
|
|
|
|
return fmt.Sprintf("/apex/%s/javalib/%s.jar", apexName, module.implName())
|
|
|
|
}
|
2018-04-10 06:07:10 +02:00
|
|
|
partition := "system"
|
|
|
|
if module.SocSpecific() {
|
|
|
|
partition = "vendor"
|
|
|
|
} else if module.DeviceSpecific() {
|
|
|
|
partition = "odm"
|
|
|
|
} else if module.ProductSpecific() {
|
|
|
|
partition = "product"
|
2019-12-04 04:53:44 +01:00
|
|
|
} else if module.SystemExtSpecific() {
|
|
|
|
partition = "system_ext"
|
2018-04-10 06:07:10 +02:00
|
|
|
}
|
|
|
|
return "/" + partition + "/framework/" + module.implName() + ".jar"
|
|
|
|
}
|
|
|
|
|
|
|
|
// Module name of the XML file for the lib
|
2019-02-08 13:00:45 +01:00
|
|
|
func (module *SdkLibrary) xmlFileName() string {
|
2018-04-10 06:07:10 +02:00
|
|
|
return module.BaseModuleName() + sdkXmlFileSuffix
|
|
|
|
}
|
|
|
|
|
2020-02-06 14:51:46 +01:00
|
|
|
// Module name of the rule for generating the XML permissions file
|
|
|
|
func (module *SdkLibrary) genXmlPermissionsFileName() string {
|
|
|
|
return "gen-" + module.BaseModuleName() + sdkXmlFileSuffix
|
|
|
|
}
|
|
|
|
|
2019-12-24 21:31:31 +01:00
|
|
|
// Get the sdk version for use when compiling the stubs library.
|
2020-01-22 12:57:20 +01:00
|
|
|
func (module *SdkLibrary) sdkVersionForStubsLibrary(mctx android.LoadHookContext, apiScope *apiScope) string {
|
2019-12-24 21:31:31 +01:00
|
|
|
sdkDep := decodeSdkDep(mctx, sdkContext(&module.Library))
|
|
|
|
if sdkDep.hasStandardLibs() {
|
|
|
|
// If building against a standard sdk then use the sdk version appropriate for the scope.
|
2020-01-22 12:57:20 +01:00
|
|
|
return apiScope.sdkVersion
|
2019-12-24 21:31:31 +01:00
|
|
|
} else {
|
|
|
|
// Otherwise, use no system module.
|
|
|
|
return "none"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-10 06:07:10 +02:00
|
|
|
// $(INTERNAL_PLATFORM_<apiTagName>_API_FILE) points to the generated
|
|
|
|
// api file for the current source
|
|
|
|
// TODO: remove this when apicheck is done in soong
|
2020-01-22 12:57:20 +01:00
|
|
|
func (module *SdkLibrary) apiTagName(apiScope *apiScope) string {
|
|
|
|
return strings.Replace(strings.ToUpper(module.BaseModuleName()), ".", "_", -1) + apiScope.apiFileMakeVariableSuffix
|
2018-04-10 06:07:10 +02:00
|
|
|
}
|
|
|
|
|
2020-01-22 12:57:20 +01:00
|
|
|
func (module *SdkLibrary) latestApiFilegroupName(apiScope *apiScope) string {
|
|
|
|
return ":" + module.BaseModuleName() + ".api." + apiScope.name + ".latest"
|
2018-05-12 15:29:12 +02:00
|
|
|
}
|
2018-04-10 06:07:10 +02:00
|
|
|
|
2020-01-22 12:57:20 +01:00
|
|
|
func (module *SdkLibrary) latestRemovedApiFilegroupName(apiScope *apiScope) string {
|
|
|
|
return ":" + module.BaseModuleName() + "-removed.api." + apiScope.name + ".latest"
|
2018-04-10 06:07:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Creates a static java library that has API stubs
|
2020-01-22 12:57:20 +01:00
|
|
|
func (module *SdkLibrary) createStubsLibrary(mctx android.LoadHookContext, apiScope *apiScope) {
|
2018-04-10 06:07:10 +02:00
|
|
|
props := struct {
|
2019-12-04 04:53:44 +01:00
|
|
|
Name *string
|
|
|
|
Srcs []string
|
2019-12-23 20:40:36 +01:00
|
|
|
Installable *bool
|
2019-12-04 04:53:44 +01:00
|
|
|
Sdk_version *string
|
2019-12-24 21:31:31 +01:00
|
|
|
System_modules *string
|
2020-02-07 17:12:04 +01:00
|
|
|
Patch_module *string
|
2019-12-04 04:53:44 +01:00
|
|
|
Libs []string
|
|
|
|
Soc_specific *bool
|
|
|
|
Device_specific *bool
|
|
|
|
Product_specific *bool
|
|
|
|
System_ext_specific *bool
|
|
|
|
Compile_dex *bool
|
|
|
|
Java_version *string
|
|
|
|
Product_variables struct {
|
2018-04-23 14:41:26 +02:00
|
|
|
Pdk struct {
|
|
|
|
Enabled *bool
|
|
|
|
}
|
2018-04-10 06:07:10 +02:00
|
|
|
}
|
2018-10-19 06:46:09 +02:00
|
|
|
Openjdk9 struct {
|
|
|
|
Srcs []string
|
|
|
|
Javacflags []string
|
|
|
|
}
|
2018-04-10 06:07:10 +02:00
|
|
|
}{}
|
|
|
|
|
2018-04-27 09:29:21 +02:00
|
|
|
props.Name = proptools.StringPtr(module.stubsName(apiScope))
|
2018-04-10 06:07:10 +02:00
|
|
|
// sources are generated from the droiddoc
|
2018-04-27 09:29:21 +02:00
|
|
|
props.Srcs = []string{":" + module.docsName(apiScope)}
|
2019-12-24 21:31:31 +01:00
|
|
|
sdkVersion := module.sdkVersionForStubsLibrary(mctx, apiScope)
|
2019-06-11 13:31:14 +02:00
|
|
|
props.Sdk_version = proptools.StringPtr(sdkVersion)
|
2019-12-24 21:31:31 +01:00
|
|
|
props.System_modules = module.Library.Module.deviceProperties.System_modules
|
2020-02-07 17:12:04 +01:00
|
|
|
props.Patch_module = module.Library.Module.properties.Patch_module
|
2019-12-23 20:40:36 +01:00
|
|
|
props.Installable = proptools.BoolPtr(false)
|
2018-10-19 06:46:09 +02:00
|
|
|
props.Libs = module.sdkLibraryProperties.Stub_only_libs
|
2018-04-23 14:41:26 +02:00
|
|
|
props.Product_variables.Pdk.Enabled = proptools.BoolPtr(false)
|
2018-10-19 06:46:09 +02:00
|
|
|
props.Openjdk9.Srcs = module.Library.Module.properties.Openjdk9.Srcs
|
|
|
|
props.Openjdk9.Javacflags = module.Library.Module.properties.Openjdk9.Javacflags
|
|
|
|
props.Java_version = module.Library.Module.properties.Java_version
|
|
|
|
if module.Library.Module.deviceProperties.Compile_dex != nil {
|
|
|
|
props.Compile_dex = module.Library.Module.deviceProperties.Compile_dex
|
2018-07-31 10:19:11 +02:00
|
|
|
}
|
2018-04-10 06:07:10 +02:00
|
|
|
|
|
|
|
if module.SocSpecific() {
|
|
|
|
props.Soc_specific = proptools.BoolPtr(true)
|
|
|
|
} else if module.DeviceSpecific() {
|
|
|
|
props.Device_specific = proptools.BoolPtr(true)
|
|
|
|
} else if module.ProductSpecific() {
|
|
|
|
props.Product_specific = proptools.BoolPtr(true)
|
2019-12-04 04:53:44 +01:00
|
|
|
} else if module.SystemExtSpecific() {
|
|
|
|
props.System_ext_specific = proptools.BoolPtr(true)
|
2018-04-10 06:07:10 +02:00
|
|
|
}
|
|
|
|
|
2019-09-25 20:33:01 +02:00
|
|
|
mctx.CreateModule(LibraryFactory, &props)
|
2018-04-10 06:07:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Creates a droiddoc module that creates stubs source files from the given full source
|
|
|
|
// files
|
2020-01-22 12:57:20 +01:00
|
|
|
func (module *SdkLibrary) createStubsSources(mctx android.LoadHookContext, apiScope *apiScope) {
|
2018-04-10 06:07:10 +02:00
|
|
|
props := struct {
|
2018-10-19 06:46:09 +02:00
|
|
|
Name *string
|
|
|
|
Srcs []string
|
|
|
|
Installable *bool
|
2019-06-11 13:31:14 +02:00
|
|
|
Sdk_version *string
|
2019-12-24 21:31:31 +01:00
|
|
|
System_modules *string
|
2018-10-19 06:46:09 +02:00
|
|
|
Libs []string
|
2019-02-11 16:55:17 +01:00
|
|
|
Arg_files []string
|
2018-10-19 06:46:09 +02:00
|
|
|
Args *string
|
|
|
|
Api_tag_name *string
|
|
|
|
Api_filename *string
|
|
|
|
Removed_api_filename *string
|
|
|
|
Java_version *string
|
|
|
|
Merge_annotations_dirs []string
|
|
|
|
Merge_inclusion_annotations_dirs []string
|
|
|
|
Check_api struct {
|
2019-02-28 06:24:05 +01:00
|
|
|
Current ApiToCheck
|
|
|
|
Last_released ApiToCheck
|
|
|
|
Ignore_missing_latest_api *bool
|
2018-05-12 15:29:12 +02:00
|
|
|
}
|
2018-05-29 04:35:17 +02:00
|
|
|
Aidl struct {
|
|
|
|
Include_dirs []string
|
|
|
|
Local_include_dirs []string
|
|
|
|
}
|
2018-04-10 06:07:10 +02:00
|
|
|
}{}
|
|
|
|
|
2019-06-07 11:44:37 +02:00
|
|
|
sdkDep := decodeSdkDep(mctx, sdkContext(&module.Library))
|
2019-12-24 21:31:31 +01:00
|
|
|
// Use the platform API if standard libraries were requested, otherwise use
|
|
|
|
// no default libraries.
|
2019-06-11 13:31:14 +02:00
|
|
|
sdkVersion := ""
|
|
|
|
if !sdkDep.hasStandardLibs() {
|
|
|
|
sdkVersion = "none"
|
|
|
|
}
|
2019-06-07 11:44:37 +02:00
|
|
|
|
2018-04-27 09:29:21 +02:00
|
|
|
props.Name = proptools.StringPtr(module.docsName(apiScope))
|
2018-10-19 06:46:09 +02:00
|
|
|
props.Srcs = append(props.Srcs, module.Library.Module.properties.Srcs...)
|
2019-06-11 13:31:14 +02:00
|
|
|
props.Sdk_version = proptools.StringPtr(sdkVersion)
|
2019-12-24 21:31:31 +01:00
|
|
|
props.System_modules = module.Library.Module.deviceProperties.System_modules
|
2018-04-10 06:07:10 +02:00
|
|
|
props.Installable = proptools.BoolPtr(false)
|
2018-06-05 09:46:14 +02:00
|
|
|
// A droiddoc module has only one Libs property and doesn't distinguish between
|
|
|
|
// shared libs and static libs. So we need to add both of these libs to Libs property.
|
2018-10-19 06:46:09 +02:00
|
|
|
props.Libs = module.Library.Module.properties.Libs
|
|
|
|
props.Libs = append(props.Libs, module.Library.Module.properties.Static_libs...)
|
|
|
|
props.Aidl.Include_dirs = module.Library.Module.deviceProperties.Aidl.Include_dirs
|
|
|
|
props.Aidl.Local_include_dirs = module.Library.Module.deviceProperties.Aidl.Local_include_dirs
|
|
|
|
props.Java_version = module.Library.Module.properties.Java_version
|
|
|
|
|
|
|
|
props.Merge_annotations_dirs = module.sdkLibraryProperties.Merge_annotations_dirs
|
|
|
|
props.Merge_inclusion_annotations_dirs = module.sdkLibraryProperties.Merge_inclusion_annotations_dirs
|
|
|
|
|
2019-12-24 11:41:30 +01:00
|
|
|
droiddocArgs := []string{}
|
|
|
|
if len(module.sdkLibraryProperties.Api_packages) != 0 {
|
|
|
|
droiddocArgs = append(droiddocArgs, "--stub-packages "+strings.Join(module.sdkLibraryProperties.Api_packages, ":"))
|
|
|
|
}
|
|
|
|
if len(module.sdkLibraryProperties.Hidden_api_packages) != 0 {
|
|
|
|
droiddocArgs = append(droiddocArgs,
|
|
|
|
android.JoinWithPrefix(module.sdkLibraryProperties.Hidden_api_packages, " --hide-package "))
|
|
|
|
}
|
|
|
|
droiddocArgs = append(droiddocArgs, module.sdkLibraryProperties.Droiddoc_options...)
|
|
|
|
disabledWarnings := []string{
|
|
|
|
"MissingPermission",
|
|
|
|
"BroadcastBehavior",
|
|
|
|
"HiddenSuperclass",
|
|
|
|
"DeprecationMismatch",
|
|
|
|
"UnavailableSymbol",
|
|
|
|
"SdkConstant",
|
|
|
|
"HiddenTypeParameter",
|
|
|
|
"Todo",
|
|
|
|
"Typo",
|
|
|
|
}
|
|
|
|
droiddocArgs = append(droiddocArgs, android.JoinWithPrefix(disabledWarnings, "--hide "))
|
2018-09-17 06:23:09 +02:00
|
|
|
|
2018-04-27 09:29:21 +02:00
|
|
|
switch apiScope {
|
|
|
|
case apiScopeSystem:
|
2019-12-24 11:41:30 +01:00
|
|
|
droiddocArgs = append(droiddocArgs, "-showAnnotation android.annotation.SystemApi")
|
2018-04-27 09:29:21 +02:00
|
|
|
case apiScopeTest:
|
2019-12-24 11:41:30 +01:00
|
|
|
droiddocArgs = append(droiddocArgs, " -showAnnotation android.annotation.TestApi")
|
2018-04-10 06:07:10 +02:00
|
|
|
}
|
2019-02-11 16:55:17 +01:00
|
|
|
props.Arg_files = module.sdkLibraryProperties.Droiddoc_option_files
|
2019-12-24 11:41:30 +01:00
|
|
|
props.Args = proptools.StringPtr(strings.Join(droiddocArgs, " "))
|
2018-04-10 06:07:10 +02:00
|
|
|
|
|
|
|
// List of APIs identified from the provided source files are created. They are later
|
|
|
|
// compared against to the not-yet-released (a.k.a current) list of APIs and to the
|
|
|
|
// last-released (a.k.a numbered) list of API.
|
2020-01-22 12:57:20 +01:00
|
|
|
currentApiFileName := apiScope.apiFilePrefix + "current.txt"
|
|
|
|
removedApiFileName := apiScope.apiFilePrefix + "removed.txt"
|
2019-12-30 18:23:46 +01:00
|
|
|
apiDir := module.getApiDir()
|
|
|
|
currentApiFileName = path.Join(apiDir, currentApiFileName)
|
|
|
|
removedApiFileName = path.Join(apiDir, removedApiFileName)
|
2018-05-12 15:29:12 +02:00
|
|
|
// TODO(jiyong): remove these three props
|
2018-04-27 09:29:21 +02:00
|
|
|
props.Api_tag_name = proptools.StringPtr(module.apiTagName(apiScope))
|
2018-04-10 06:07:10 +02:00
|
|
|
props.Api_filename = proptools.StringPtr(currentApiFileName)
|
|
|
|
props.Removed_api_filename = proptools.StringPtr(removedApiFileName)
|
|
|
|
|
2018-05-12 15:29:12 +02:00
|
|
|
// check against the not-yet-release API
|
|
|
|
props.Check_api.Current.Api_file = proptools.StringPtr(currentApiFileName)
|
|
|
|
props.Check_api.Current.Removed_api_file = proptools.StringPtr(removedApiFileName)
|
|
|
|
|
|
|
|
// check against the latest released API
|
|
|
|
props.Check_api.Last_released.Api_file = proptools.StringPtr(
|
|
|
|
module.latestApiFilegroupName(apiScope))
|
|
|
|
props.Check_api.Last_released.Removed_api_file = proptools.StringPtr(
|
|
|
|
module.latestRemovedApiFilegroupName(apiScope))
|
2019-02-28 06:24:05 +01:00
|
|
|
props.Check_api.Ignore_missing_latest_api = proptools.BoolPtr(true)
|
2018-04-10 06:07:10 +02:00
|
|
|
|
2019-09-25 20:33:01 +02:00
|
|
|
mctx.CreateModule(DroidstubsFactory, &props)
|
2018-04-10 06:07:10 +02:00
|
|
|
}
|
|
|
|
|
2020-02-06 14:51:46 +01:00
|
|
|
func (module *SdkLibrary) XmlPermissionsFile() android.Path {
|
|
|
|
return module.permissionsFile
|
|
|
|
}
|
|
|
|
|
|
|
|
func (module *SdkLibrary) XmlPermissionsFileContent() string {
|
|
|
|
return fmt.Sprintf(permissionsTemplate, module.BaseModuleName(), module.implPath())
|
|
|
|
}
|
|
|
|
|
2018-04-10 06:07:10 +02:00
|
|
|
// Creates the xml file that publicizes the runtime library
|
2019-04-16 23:43:28 +02:00
|
|
|
func (module *SdkLibrary) createXmlFile(mctx android.LoadHookContext) {
|
2020-02-06 14:51:46 +01:00
|
|
|
|
|
|
|
xmlContent := module.XmlPermissionsFileContent()
|
|
|
|
|
|
|
|
genRuleName := module.genXmlPermissionsFileName()
|
|
|
|
|
|
|
|
// Create a genrule module to create the XML permissions file.
|
|
|
|
genRuleProps := struct {
|
|
|
|
Name *string
|
|
|
|
Cmd *string
|
|
|
|
Out []string
|
|
|
|
}{
|
|
|
|
Name: proptools.StringPtr(genRuleName),
|
|
|
|
Cmd: proptools.StringPtr("echo -e '" + xmlContent + "' > '$(out)'"),
|
|
|
|
Out: []string{module.xmlFileName()},
|
|
|
|
}
|
|
|
|
|
|
|
|
mctx.CreateModule(genrule.GenRuleFactory, &genRuleProps)
|
|
|
|
|
2018-04-10 06:07:10 +02:00
|
|
|
// creates a prebuilt_etc module to actually place the xml file under
|
|
|
|
// <partition>/etc/permissions
|
|
|
|
etcProps := struct {
|
2019-12-04 04:53:44 +01:00
|
|
|
Name *string
|
|
|
|
Src *string
|
|
|
|
Sub_dir *string
|
|
|
|
Soc_specific *bool
|
|
|
|
Device_specific *bool
|
|
|
|
Product_specific *bool
|
|
|
|
System_ext_specific *bool
|
2018-04-10 06:07:10 +02:00
|
|
|
}{}
|
|
|
|
etcProps.Name = proptools.StringPtr(module.xmlFileName())
|
2020-02-06 14:51:46 +01:00
|
|
|
etcProps.Src = proptools.StringPtr(":" + genRuleName)
|
2018-04-10 06:07:10 +02:00
|
|
|
etcProps.Sub_dir = proptools.StringPtr("permissions")
|
|
|
|
if module.SocSpecific() {
|
|
|
|
etcProps.Soc_specific = proptools.BoolPtr(true)
|
|
|
|
} else if module.DeviceSpecific() {
|
|
|
|
etcProps.Device_specific = proptools.BoolPtr(true)
|
|
|
|
} else if module.ProductSpecific() {
|
|
|
|
etcProps.Product_specific = proptools.BoolPtr(true)
|
2019-12-04 04:53:44 +01:00
|
|
|
} else if module.SystemExtSpecific() {
|
|
|
|
etcProps.System_ext_specific = proptools.BoolPtr(true)
|
2018-04-10 06:07:10 +02:00
|
|
|
}
|
2019-09-25 20:33:01 +02:00
|
|
|
mctx.CreateModule(android.PrebuiltEtcFactory, &etcProps)
|
2018-04-10 06:07:10 +02:00
|
|
|
}
|
|
|
|
|
2020-01-21 17:31:05 +01:00
|
|
|
func PrebuiltJars(ctx android.BaseModuleContext, baseName string, s sdkSpec) android.Paths {
|
Abstract sdk_version string using sdkSpec type
The value format that sdk_version (and min_sdk_version, etc.) can have
has consistently evolved and is quite complicated. Furthermore, with the
Mainline module effort, we are expected to have more sdk_versions like
'module-app-current', 'module-lib-current', etc.
The goal of this change is to abstract the various sdk versions, which
are currently represented in string and is parsed in various places,
into a type called sdkSpec, so that adding new sdk veresions becomes
easier than before.
The sdk_version string is now parsed in only one place 'SdkSpecFrom', in
which it is converted into the sdkSpec struct. The struct type provides
several methods that again converts sdkSpec into context-specific
information such as the effective version number, etc.
Bug: 146757305
Bug: 147879031
Test: m
Change-Id: I252f3706544f00ea71c61c23460f07561dd28ab0
2020-01-20 18:03:43 +01:00
|
|
|
var ver sdkVersion
|
|
|
|
var kind sdkKind
|
|
|
|
if s.usePrebuilt(ctx) {
|
|
|
|
ver = s.version
|
|
|
|
kind = s.kind
|
2018-10-19 06:46:09 +02:00
|
|
|
} else {
|
Abstract sdk_version string using sdkSpec type
The value format that sdk_version (and min_sdk_version, etc.) can have
has consistently evolved and is quite complicated. Furthermore, with the
Mainline module effort, we are expected to have more sdk_versions like
'module-app-current', 'module-lib-current', etc.
The goal of this change is to abstract the various sdk versions, which
are currently represented in string and is parsed in various places,
into a type called sdkSpec, so that adding new sdk veresions becomes
easier than before.
The sdk_version string is now parsed in only one place 'SdkSpecFrom', in
which it is converted into the sdkSpec struct. The struct type provides
several methods that again converts sdkSpec into context-specific
information such as the effective version number, etc.
Bug: 146757305
Bug: 147879031
Test: m
Change-Id: I252f3706544f00ea71c61c23460f07561dd28ab0
2020-01-20 18:03:43 +01:00
|
|
|
// We don't have prebuilt SDK for the specific sdkVersion.
|
|
|
|
// Instead of breaking the build, fallback to use "system_current"
|
|
|
|
ver = sdkVersionCurrent
|
|
|
|
kind = sdkSystem
|
2018-10-19 06:46:09 +02:00
|
|
|
}
|
Abstract sdk_version string using sdkSpec type
The value format that sdk_version (and min_sdk_version, etc.) can have
has consistently evolved and is quite complicated. Furthermore, with the
Mainline module effort, we are expected to have more sdk_versions like
'module-app-current', 'module-lib-current', etc.
The goal of this change is to abstract the various sdk versions, which
are currently represented in string and is parsed in various places,
into a type called sdkSpec, so that adding new sdk veresions becomes
easier than before.
The sdk_version string is now parsed in only one place 'SdkSpecFrom', in
which it is converted into the sdkSpec struct. The struct type provides
several methods that again converts sdkSpec into context-specific
information such as the effective version number, etc.
Bug: 146757305
Bug: 147879031
Test: m
Change-Id: I252f3706544f00ea71c61c23460f07561dd28ab0
2020-01-20 18:03:43 +01:00
|
|
|
|
|
|
|
dir := filepath.Join("prebuilts", "sdk", ver.String(), kind.String())
|
2020-01-21 17:31:05 +01:00
|
|
|
jar := filepath.Join(dir, baseName+".jar")
|
2018-10-19 06:46:09 +02:00
|
|
|
jarPath := android.ExistentPathForSource(ctx, jar)
|
2019-02-28 07:01:28 +01:00
|
|
|
if !jarPath.Valid() {
|
2020-01-07 18:34:44 +01:00
|
|
|
if ctx.Config().AllowMissingDependencies() {
|
|
|
|
return android.Paths{android.PathForSource(ctx, jar)}
|
|
|
|
} else {
|
Abstract sdk_version string using sdkSpec type
The value format that sdk_version (and min_sdk_version, etc.) can have
has consistently evolved and is quite complicated. Furthermore, with the
Mainline module effort, we are expected to have more sdk_versions like
'module-app-current', 'module-lib-current', etc.
The goal of this change is to abstract the various sdk versions, which
are currently represented in string and is parsed in various places,
into a type called sdkSpec, so that adding new sdk veresions becomes
easier than before.
The sdk_version string is now parsed in only one place 'SdkSpecFrom', in
which it is converted into the sdkSpec struct. The struct type provides
several methods that again converts sdkSpec into context-specific
information such as the effective version number, etc.
Bug: 146757305
Bug: 147879031
Test: m
Change-Id: I252f3706544f00ea71c61c23460f07561dd28ab0
2020-01-20 18:03:43 +01:00
|
|
|
ctx.PropertyErrorf("sdk_library", "invalid sdk version %q, %q does not exist", s.raw, jar)
|
2020-01-07 18:34:44 +01:00
|
|
|
}
|
2019-02-28 07:01:28 +01:00
|
|
|
return nil
|
|
|
|
}
|
2018-10-19 06:46:09 +02:00
|
|
|
return android.Paths{jarPath.Path()}
|
|
|
|
}
|
|
|
|
|
2020-01-22 12:57:20 +01:00
|
|
|
func (module *SdkLibrary) sdkJars(
|
|
|
|
ctx android.BaseModuleContext,
|
|
|
|
sdkVersion sdkSpec,
|
|
|
|
headerJars bool) android.Paths {
|
|
|
|
|
2020-01-21 17:31:05 +01:00
|
|
|
// If a specific numeric version has been requested then use prebuilt versions of the sdk.
|
|
|
|
if sdkVersion.version.isNumbered() {
|
|
|
|
return PrebuiltJars(ctx, module.BaseModuleName(), sdkVersion)
|
2018-04-10 06:07:10 +02:00
|
|
|
} else {
|
2020-01-22 12:57:20 +01:00
|
|
|
if !sdkVersion.specified() {
|
|
|
|
if headerJars {
|
|
|
|
return module.Library.HeaderJars()
|
|
|
|
} else {
|
|
|
|
return module.Library.ImplementationJars()
|
|
|
|
}
|
|
|
|
}
|
2020-01-22 17:30:37 +01:00
|
|
|
var apiScope *apiScope
|
Abstract sdk_version string using sdkSpec type
The value format that sdk_version (and min_sdk_version, etc.) can have
has consistently evolved and is quite complicated. Furthermore, with the
Mainline module effort, we are expected to have more sdk_versions like
'module-app-current', 'module-lib-current', etc.
The goal of this change is to abstract the various sdk versions, which
are currently represented in string and is parsed in various places,
into a type called sdkSpec, so that adding new sdk veresions becomes
easier than before.
The sdk_version string is now parsed in only one place 'SdkSpecFrom', in
which it is converted into the sdkSpec struct. The struct type provides
several methods that again converts sdkSpec into context-specific
information such as the effective version number, etc.
Bug: 146757305
Bug: 147879031
Test: m
Change-Id: I252f3706544f00ea71c61c23460f07561dd28ab0
2020-01-20 18:03:43 +01:00
|
|
|
switch sdkVersion.kind {
|
|
|
|
case sdkSystem:
|
2020-01-22 17:30:37 +01:00
|
|
|
apiScope = apiScopeSystem
|
|
|
|
case sdkTest:
|
|
|
|
apiScope = apiScopeTest
|
Abstract sdk_version string using sdkSpec type
The value format that sdk_version (and min_sdk_version, etc.) can have
has consistently evolved and is quite complicated. Furthermore, with the
Mainline module effort, we are expected to have more sdk_versions like
'module-app-current', 'module-lib-current', etc.
The goal of this change is to abstract the various sdk versions, which
are currently represented in string and is parsed in various places,
into a type called sdkSpec, so that adding new sdk veresions becomes
easier than before.
The sdk_version string is now parsed in only one place 'SdkSpecFrom', in
which it is converted into the sdkSpec struct. The struct type provides
several methods that again converts sdkSpec into context-specific
information such as the effective version number, etc.
Bug: 146757305
Bug: 147879031
Test: m
Change-Id: I252f3706544f00ea71c61c23460f07561dd28ab0
2020-01-20 18:03:43 +01:00
|
|
|
case sdkPrivate:
|
2018-10-19 06:46:09 +02:00
|
|
|
return module.Library.HeaderJars()
|
Abstract sdk_version string using sdkSpec type
The value format that sdk_version (and min_sdk_version, etc.) can have
has consistently evolved and is quite complicated. Furthermore, with the
Mainline module effort, we are expected to have more sdk_versions like
'module-app-current', 'module-lib-current', etc.
The goal of this change is to abstract the various sdk versions, which
are currently represented in string and is parsed in various places,
into a type called sdkSpec, so that adding new sdk veresions becomes
easier than before.
The sdk_version string is now parsed in only one place 'SdkSpecFrom', in
which it is converted into the sdkSpec struct. The struct type provides
several methods that again converts sdkSpec into context-specific
information such as the effective version number, etc.
Bug: 146757305
Bug: 147879031
Test: m
Change-Id: I252f3706544f00ea71c61c23460f07561dd28ab0
2020-01-20 18:03:43 +01:00
|
|
|
default:
|
2020-01-22 17:30:37 +01:00
|
|
|
apiScope = apiScopePublic
|
2020-01-22 12:57:20 +01:00
|
|
|
}
|
|
|
|
|
2020-01-22 17:30:37 +01:00
|
|
|
paths := module.getScopePaths(apiScope)
|
2020-01-22 12:57:20 +01:00
|
|
|
if headerJars {
|
|
|
|
return paths.stubsHeaderPath
|
|
|
|
} else {
|
|
|
|
return paths.stubsImplPath
|
2018-10-19 06:46:09 +02:00
|
|
|
}
|
2018-04-10 06:07:10 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-22 12:57:20 +01:00
|
|
|
// to satisfy SdkLibraryDependency interface
|
|
|
|
func (module *SdkLibrary) SdkHeaderJars(ctx android.BaseModuleContext, sdkVersion sdkSpec) android.Paths {
|
|
|
|
return module.sdkJars(ctx, sdkVersion, true /*headerJars*/)
|
|
|
|
}
|
|
|
|
|
2018-07-13 09:16:44 +02:00
|
|
|
// to satisfy SdkLibraryDependency interface
|
Abstract sdk_version string using sdkSpec type
The value format that sdk_version (and min_sdk_version, etc.) can have
has consistently evolved and is quite complicated. Furthermore, with the
Mainline module effort, we are expected to have more sdk_versions like
'module-app-current', 'module-lib-current', etc.
The goal of this change is to abstract the various sdk versions, which
are currently represented in string and is parsed in various places,
into a type called sdkSpec, so that adding new sdk veresions becomes
easier than before.
The sdk_version string is now parsed in only one place 'SdkSpecFrom', in
which it is converted into the sdkSpec struct. The struct type provides
several methods that again converts sdkSpec into context-specific
information such as the effective version number, etc.
Bug: 146757305
Bug: 147879031
Test: m
Change-Id: I252f3706544f00ea71c61c23460f07561dd28ab0
2020-01-20 18:03:43 +01:00
|
|
|
func (module *SdkLibrary) SdkImplementationJars(ctx android.BaseModuleContext, sdkVersion sdkSpec) android.Paths {
|
2020-01-22 12:57:20 +01:00
|
|
|
return module.sdkJars(ctx, sdkVersion, false /*headerJars*/)
|
2018-07-13 09:16:44 +02:00
|
|
|
}
|
|
|
|
|
2019-05-13 08:02:50 +02:00
|
|
|
func (module *SdkLibrary) SetNoDist() {
|
|
|
|
module.sdkLibraryProperties.No_dist = proptools.BoolPtr(true)
|
|
|
|
}
|
|
|
|
|
2019-02-04 20:22:08 +01:00
|
|
|
var javaSdkLibrariesKey = android.NewOnceKey("javaSdkLibraries")
|
|
|
|
|
2018-04-23 14:41:26 +02:00
|
|
|
func javaSdkLibraries(config android.Config) *[]string {
|
2019-02-04 20:22:08 +01:00
|
|
|
return config.Once(javaSdkLibrariesKey, func() interface{} {
|
2018-04-23 14:41:26 +02:00
|
|
|
return &[]string{}
|
|
|
|
}).(*[]string)
|
|
|
|
}
|
|
|
|
|
2019-12-30 18:23:46 +01:00
|
|
|
func (module *SdkLibrary) getApiDir() string {
|
|
|
|
return proptools.StringDefault(module.sdkLibraryProperties.Api_dir, "api")
|
|
|
|
}
|
|
|
|
|
2018-04-10 06:07:10 +02:00
|
|
|
// 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
|
2019-04-16 23:43:28 +02:00
|
|
|
func (module *SdkLibrary) CreateInternalModules(mctx android.LoadHookContext) {
|
2019-03-21 09:43:49 +01:00
|
|
|
if len(module.Library.Module.properties.Srcs) == 0 {
|
2019-02-08 13:00:45 +01:00
|
|
|
mctx.PropertyErrorf("srcs", "java_sdk_library must specify srcs")
|
2019-12-18 07:34:32 +01:00
|
|
|
return
|
2019-02-08 13:00:45 +01:00
|
|
|
}
|
2018-04-10 06:07:10 +02:00
|
|
|
|
2019-12-30 18:20:10 +01:00
|
|
|
// If this builds against standard libraries (i.e. is not part of the core libraries)
|
|
|
|
// then assume it provides both system and test apis. Otherwise, assume it does not and
|
|
|
|
// also assume it does not contribute to the dist build.
|
|
|
|
sdkDep := decodeSdkDep(mctx, sdkContext(&module.Library))
|
|
|
|
hasSystemAndTestApis := sdkDep.hasStandardLibs()
|
|
|
|
module.sdkLibraryProperties.Has_system_and_test_apis = hasSystemAndTestApis
|
|
|
|
module.sdkLibraryProperties.No_dist = proptools.BoolPtr(!hasSystemAndTestApis)
|
|
|
|
|
2019-03-18 02:19:51 +01:00
|
|
|
missing_current_api := false
|
|
|
|
|
2020-01-22 12:57:20 +01:00
|
|
|
activeScopes := module.getActiveApiScopes()
|
|
|
|
|
2019-12-30 18:23:46 +01:00
|
|
|
apiDir := module.getApiDir()
|
2020-01-22 12:57:20 +01:00
|
|
|
for _, scope := range activeScopes {
|
2019-03-18 02:19:51 +01:00
|
|
|
for _, api := range []string{"current.txt", "removed.txt"} {
|
2020-01-22 12:57:20 +01:00
|
|
|
path := path.Join(mctx.ModuleDir(), apiDir, scope.apiFilePrefix+api)
|
2019-03-18 02:19:51 +01:00
|
|
|
p := android.ExistentPathForSource(mctx, path)
|
|
|
|
if !p.Valid() {
|
|
|
|
mctx.ModuleErrorf("Current api file %#v doesn't exist", path)
|
|
|
|
missing_current_api = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if missing_current_api {
|
|
|
|
script := "build/soong/scripts/gen-java-current-api-files.sh"
|
|
|
|
p := android.ExistentPathForSource(mctx, script)
|
|
|
|
|
|
|
|
if !p.Valid() {
|
|
|
|
panic(fmt.Sprintf("script file %s doesn't exist", script))
|
|
|
|
}
|
|
|
|
|
|
|
|
mctx.ModuleErrorf("One or more current api files are missing. "+
|
|
|
|
"You can update them by:\n"+
|
2019-12-30 18:20:10 +01:00
|
|
|
"%s %q %s && m update-api",
|
2020-01-22 12:57:20 +01:00
|
|
|
script, filepath.Join(mctx.ModuleDir(), apiDir),
|
|
|
|
strings.Join(activeScopes.Strings(func(s *apiScope) string { return s.apiFilePrefix }), " "))
|
2019-03-18 02:19:51 +01:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2020-01-22 12:57:20 +01:00
|
|
|
for _, scope := range activeScopes {
|
|
|
|
module.createStubsLibrary(mctx, scope)
|
|
|
|
module.createStubsSources(mctx, scope)
|
2019-12-30 18:35:49 +01:00
|
|
|
}
|
2018-04-23 14:41:26 +02:00
|
|
|
|
2019-12-30 18:35:49 +01:00
|
|
|
if !proptools.Bool(module.sdkLibraryProperties.Api_only) {
|
2019-02-08 13:00:45 +01:00
|
|
|
// for runtime
|
|
|
|
module.createXmlFile(mctx)
|
|
|
|
|
2019-12-30 18:35:49 +01:00
|
|
|
// record java_sdk_library modules so that they are exported to make
|
|
|
|
javaSdkLibraries := javaSdkLibraries(mctx.Config())
|
|
|
|
javaSdkLibrariesLock.Lock()
|
|
|
|
defer javaSdkLibrariesLock.Unlock()
|
|
|
|
*javaSdkLibraries = append(*javaSdkLibraries, module.BaseModuleName())
|
|
|
|
}
|
2018-04-10 06:07:10 +02:00
|
|
|
}
|
|
|
|
|
2019-02-08 13:00:45 +01:00
|
|
|
func (module *SdkLibrary) InitSdkLibraryProperties() {
|
2018-10-19 06:46:09 +02:00
|
|
|
module.AddProperties(
|
|
|
|
&module.sdkLibraryProperties,
|
|
|
|
&module.Library.Module.properties,
|
|
|
|
&module.Library.Module.dexpreoptProperties,
|
|
|
|
&module.Library.Module.deviceProperties,
|
|
|
|
&module.Library.Module.protoProperties,
|
|
|
|
)
|
|
|
|
|
|
|
|
module.Library.Module.properties.Installable = proptools.BoolPtr(true)
|
|
|
|
module.Library.Module.deviceProperties.IsSDKLibrary = true
|
2019-02-08 13:00:45 +01:00
|
|
|
}
|
2018-10-19 06:46:09 +02:00
|
|
|
|
2019-07-11 19:05:35 +02:00
|
|
|
// java_sdk_library is a special Java library that provides optional platform APIs to apps.
|
|
|
|
// In practice, it can be viewed as a combination of several modules: 1) stubs library that clients
|
|
|
|
// are linked against to, 2) droiddoc module that internally generates API stubs source files,
|
|
|
|
// 3) the real runtime shared library that implements the APIs, and 4) XML file for adding
|
|
|
|
// the runtime lib to the classpath at runtime if requested via <uses-library>.
|
2019-02-08 13:00:45 +01:00
|
|
|
func SdkLibraryFactory() android.Module {
|
|
|
|
module := &SdkLibrary{}
|
|
|
|
module.InitSdkLibraryProperties()
|
2019-12-18 07:34:32 +01:00
|
|
|
android.InitApexModule(module)
|
2018-10-19 06:46:09 +02:00
|
|
|
InitJavaModule(module, android.HostAndDeviceSupported)
|
2019-04-16 23:43:28 +02:00
|
|
|
android.AddLoadHook(module, func(ctx android.LoadHookContext) { module.CreateInternalModules(ctx) })
|
2018-04-10 06:07:10 +02:00
|
|
|
return module
|
|
|
|
}
|
2019-04-17 20:11:46 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// SDK library prebuilts
|
|
|
|
//
|
|
|
|
|
2020-01-31 14:36:25 +01:00
|
|
|
// Properties associated with each api scope.
|
|
|
|
type sdkLibraryScopeProperties struct {
|
2019-04-17 20:11:46 +02:00
|
|
|
Jars []string `android:"path"`
|
|
|
|
|
|
|
|
Sdk_version *string
|
|
|
|
|
|
|
|
// List of shared java libs that this module has dependencies to
|
|
|
|
Libs []string
|
|
|
|
}
|
|
|
|
|
2020-01-31 14:36:25 +01:00
|
|
|
type sdkLibraryImportProperties struct {
|
2020-01-31 18:54:30 +01:00
|
|
|
// List of shared java libs, common to all scopes, that this module has
|
|
|
|
// dependencies to
|
|
|
|
Libs []string
|
|
|
|
|
2020-01-31 14:36:25 +01:00
|
|
|
// Properties associated with the public api scope.
|
|
|
|
Public sdkLibraryScopeProperties
|
|
|
|
|
|
|
|
// Properties associated with the system api scope.
|
|
|
|
System sdkLibraryScopeProperties
|
|
|
|
|
|
|
|
// Properties associated with the test api scope.
|
|
|
|
Test sdkLibraryScopeProperties
|
|
|
|
}
|
|
|
|
|
2019-04-17 20:11:46 +02:00
|
|
|
type sdkLibraryImport struct {
|
|
|
|
android.ModuleBase
|
|
|
|
android.DefaultableModuleBase
|
|
|
|
prebuilt android.Prebuilt
|
|
|
|
|
|
|
|
properties sdkLibraryImportProperties
|
|
|
|
|
2020-01-31 14:36:25 +01:00
|
|
|
commonToSdkLibraryAndImport
|
2019-04-17 20:11:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
var _ SdkLibraryDependency = (*sdkLibraryImport)(nil)
|
|
|
|
|
2019-07-11 19:05:35 +02:00
|
|
|
// java_sdk_library_import imports a prebuilt java_sdk_library.
|
2019-04-17 20:11:46 +02:00
|
|
|
func sdkLibraryImportFactory() android.Module {
|
|
|
|
module := &sdkLibraryImport{}
|
|
|
|
|
2020-01-31 18:54:30 +01:00
|
|
|
module.AddProperties(&module.properties)
|
2019-04-17 20:11:46 +02:00
|
|
|
|
2020-01-31 18:54:30 +01:00
|
|
|
android.InitPrebuiltModule(module, &[]string{})
|
2019-04-17 20:11:46 +02:00
|
|
|
InitJavaModule(module, android.HostAndDeviceSupported)
|
|
|
|
|
|
|
|
android.AddLoadHook(module, func(mctx android.LoadHookContext) { module.createInternalModules(mctx) })
|
|
|
|
return module
|
|
|
|
}
|
|
|
|
|
|
|
|
func (module *sdkLibraryImport) Prebuilt() *android.Prebuilt {
|
|
|
|
return &module.prebuilt
|
|
|
|
}
|
|
|
|
|
|
|
|
func (module *sdkLibraryImport) Name() string {
|
|
|
|
return module.prebuilt.Name(module.ModuleBase.Name())
|
|
|
|
}
|
|
|
|
|
|
|
|
func (module *sdkLibraryImport) createInternalModules(mctx android.LoadHookContext) {
|
|
|
|
|
2020-01-21 17:31:05 +01:00
|
|
|
// If the build is configured to use prebuilts then force this to be preferred.
|
|
|
|
if mctx.Config().UnbundledBuildUsePrebuiltSdks() {
|
|
|
|
module.prebuilt.ForcePrefer()
|
|
|
|
}
|
|
|
|
|
2020-01-31 14:36:25 +01:00
|
|
|
for apiScope, scopeProperties := range module.scopeProperties() {
|
|
|
|
if len(scopeProperties.Jars) == 0 {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
// Creates a java import for the jar with ".stubs" suffix
|
|
|
|
props := struct {
|
|
|
|
Name *string
|
|
|
|
Soc_specific *bool
|
|
|
|
Device_specific *bool
|
|
|
|
Product_specific *bool
|
|
|
|
System_ext_specific *bool
|
|
|
|
Sdk_version *string
|
|
|
|
Libs []string
|
|
|
|
Jars []string
|
2020-01-21 17:31:05 +01:00
|
|
|
Prefer *bool
|
2020-01-31 14:36:25 +01:00
|
|
|
}{}
|
|
|
|
|
|
|
|
props.Name = proptools.StringPtr(apiScope.stubsModuleName(module.BaseModuleName()))
|
|
|
|
props.Sdk_version = scopeProperties.Sdk_version
|
2020-01-31 18:54:30 +01:00
|
|
|
// Prepend any of the libs from the legacy public properties to the libs for each of the
|
|
|
|
// scopes to avoid having to duplicate them in each scope.
|
|
|
|
props.Libs = append(module.properties.Libs, scopeProperties.Libs...)
|
2020-01-31 14:36:25 +01:00
|
|
|
props.Jars = scopeProperties.Jars
|
|
|
|
|
|
|
|
if module.SocSpecific() {
|
|
|
|
props.Soc_specific = proptools.BoolPtr(true)
|
|
|
|
} else if module.DeviceSpecific() {
|
|
|
|
props.Device_specific = proptools.BoolPtr(true)
|
|
|
|
} else if module.ProductSpecific() {
|
|
|
|
props.Product_specific = proptools.BoolPtr(true)
|
|
|
|
} else if module.SystemExtSpecific() {
|
|
|
|
props.System_ext_specific = proptools.BoolPtr(true)
|
|
|
|
}
|
|
|
|
|
2020-01-21 17:31:05 +01:00
|
|
|
// If the build should use prebuilt sdks then set prefer to true on the stubs library.
|
|
|
|
// That will cause the prebuilt version of the stubs to override the source version.
|
|
|
|
if mctx.Config().UnbundledBuildUsePrebuiltSdks() {
|
|
|
|
props.Prefer = proptools.BoolPtr(true)
|
|
|
|
}
|
|
|
|
|
2020-01-31 14:36:25 +01:00
|
|
|
mctx.CreateModule(ImportFactory, &props)
|
|
|
|
}
|
2019-04-17 20:11:46 +02:00
|
|
|
|
|
|
|
javaSdkLibraries := javaSdkLibraries(mctx.Config())
|
|
|
|
javaSdkLibrariesLock.Lock()
|
|
|
|
defer javaSdkLibrariesLock.Unlock()
|
|
|
|
*javaSdkLibraries = append(*javaSdkLibraries, module.BaseModuleName())
|
|
|
|
}
|
|
|
|
|
2020-01-31 14:36:25 +01:00
|
|
|
func (module *sdkLibraryImport) scopeProperties() map[*apiScope]*sdkLibraryScopeProperties {
|
|
|
|
p := make(map[*apiScope]*sdkLibraryScopeProperties)
|
|
|
|
p[apiScopePublic] = &module.properties.Public
|
|
|
|
p[apiScopeSystem] = &module.properties.System
|
|
|
|
p[apiScopeTest] = &module.properties.Test
|
|
|
|
return p
|
|
|
|
}
|
|
|
|
|
2019-04-17 20:11:46 +02:00
|
|
|
func (module *sdkLibraryImport) DepsMutator(ctx android.BottomUpMutatorContext) {
|
2020-01-31 14:36:25 +01:00
|
|
|
for apiScope, scopeProperties := range module.scopeProperties() {
|
|
|
|
if len(scopeProperties.Jars) == 0 {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add dependencies to the prebuilt stubs library
|
|
|
|
ctx.AddVariationDependencies(nil, apiScope.stubsTag, apiScope.stubsModuleName(module.BaseModuleName()))
|
|
|
|
}
|
2019-04-17 20:11:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (module *sdkLibraryImport) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|
|
|
// Record the paths to the prebuilt stubs library.
|
|
|
|
ctx.VisitDirectDeps(func(to android.Module) {
|
|
|
|
tag := ctx.OtherModuleDependencyTag(to)
|
|
|
|
|
2020-01-31 14:36:25 +01:00
|
|
|
if lib, ok := to.(Dependency); ok {
|
|
|
|
if scopeTag, ok := tag.(scopeDependencyTag); ok {
|
|
|
|
apiScope := scopeTag.apiScope
|
|
|
|
scopePaths := module.getScopePaths(apiScope)
|
|
|
|
scopePaths.stubsHeaderPath = lib.HeaderJars()
|
|
|
|
}
|
2019-04-17 20:11:46 +02:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-01-31 14:36:25 +01:00
|
|
|
func (module *sdkLibraryImport) sdkJars(
|
|
|
|
ctx android.BaseModuleContext,
|
|
|
|
sdkVersion sdkSpec) android.Paths {
|
|
|
|
|
2020-01-21 17:31:05 +01:00
|
|
|
// If a specific numeric version has been requested then use prebuilt versions of the sdk.
|
|
|
|
if sdkVersion.version.isNumbered() {
|
|
|
|
return PrebuiltJars(ctx, module.BaseModuleName(), sdkVersion)
|
|
|
|
}
|
|
|
|
|
2020-01-31 14:36:25 +01:00
|
|
|
var apiScope *apiScope
|
|
|
|
switch sdkVersion.kind {
|
|
|
|
case sdkSystem:
|
|
|
|
apiScope = apiScopeSystem
|
|
|
|
case sdkTest:
|
|
|
|
apiScope = apiScopeTest
|
|
|
|
default:
|
|
|
|
apiScope = apiScopePublic
|
|
|
|
}
|
|
|
|
|
|
|
|
paths := module.getScopePaths(apiScope)
|
|
|
|
return paths.stubsHeaderPath
|
|
|
|
}
|
|
|
|
|
2019-04-17 20:11:46 +02:00
|
|
|
// to satisfy SdkLibraryDependency interface
|
Abstract sdk_version string using sdkSpec type
The value format that sdk_version (and min_sdk_version, etc.) can have
has consistently evolved and is quite complicated. Furthermore, with the
Mainline module effort, we are expected to have more sdk_versions like
'module-app-current', 'module-lib-current', etc.
The goal of this change is to abstract the various sdk versions, which
are currently represented in string and is parsed in various places,
into a type called sdkSpec, so that adding new sdk veresions becomes
easier than before.
The sdk_version string is now parsed in only one place 'SdkSpecFrom', in
which it is converted into the sdkSpec struct. The struct type provides
several methods that again converts sdkSpec into context-specific
information such as the effective version number, etc.
Bug: 146757305
Bug: 147879031
Test: m
Change-Id: I252f3706544f00ea71c61c23460f07561dd28ab0
2020-01-20 18:03:43 +01:00
|
|
|
func (module *sdkLibraryImport) SdkHeaderJars(ctx android.BaseModuleContext, sdkVersion sdkSpec) android.Paths {
|
2019-04-17 20:11:46 +02:00
|
|
|
// This module is just a wrapper for the prebuilt stubs.
|
2020-01-31 14:36:25 +01:00
|
|
|
return module.sdkJars(ctx, sdkVersion)
|
2019-04-17 20:11:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// to satisfy SdkLibraryDependency interface
|
Abstract sdk_version string using sdkSpec type
The value format that sdk_version (and min_sdk_version, etc.) can have
has consistently evolved and is quite complicated. Furthermore, with the
Mainline module effort, we are expected to have more sdk_versions like
'module-app-current', 'module-lib-current', etc.
The goal of this change is to abstract the various sdk versions, which
are currently represented in string and is parsed in various places,
into a type called sdkSpec, so that adding new sdk veresions becomes
easier than before.
The sdk_version string is now parsed in only one place 'SdkSpecFrom', in
which it is converted into the sdkSpec struct. The struct type provides
several methods that again converts sdkSpec into context-specific
information such as the effective version number, etc.
Bug: 146757305
Bug: 147879031
Test: m
Change-Id: I252f3706544f00ea71c61c23460f07561dd28ab0
2020-01-20 18:03:43 +01:00
|
|
|
func (module *sdkLibraryImport) SdkImplementationJars(ctx android.BaseModuleContext, sdkVersion sdkSpec) android.Paths {
|
2019-04-17 20:11:46 +02:00
|
|
|
// This module is just a wrapper for the stubs.
|
2020-01-31 14:36:25 +01:00
|
|
|
return module.sdkJars(ctx, sdkVersion)
|
2019-04-17 20:11:46 +02:00
|
|
|
}
|