Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 1 | // Copyright 2018 Google Inc. All rights reserved. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | package java |
| 16 | |
| 17 | import ( |
| 18 | "android/soong/android" |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 19 | "fmt" |
Jiyong Park | 82484c0 | 2018-04-23 21:41:26 +0900 | [diff] [blame] | 20 | "io" |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 21 | "path" |
Sundong Ahn | 054b19a | 2018-10-19 13:46:09 +0900 | [diff] [blame] | 22 | "path/filepath" |
Jiyong Park | 82484c0 | 2018-04-23 21:41:26 +0900 | [diff] [blame] | 23 | "sort" |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 24 | "strings" |
Jiyong Park | 82484c0 | 2018-04-23 21:41:26 +0900 | [diff] [blame] | 25 | "sync" |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 26 | |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 27 | "github.com/google/blueprint/proptools" |
| 28 | ) |
| 29 | |
Jooyung Han | 58f26ab | 2019-12-18 15:34:32 +0900 | [diff] [blame] | 30 | const ( |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 31 | sdkStubsLibrarySuffix = ".stubs" |
| 32 | sdkSystemApiSuffix = ".system" |
Jiyong Park | df13054 | 2018-04-27 16:29:21 +0900 | [diff] [blame] | 33 | sdkTestApiSuffix = ".test" |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 34 | sdkDocsSuffix = ".docs" |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 35 | sdkXmlFileSuffix = ".xml" |
Jooyung Han | 624058e | 2019-12-24 18:38:06 +0900 | [diff] [blame] | 36 | permissionsTemplate = `<?xml version="1.0" encoding="utf-8"?>\n` + |
| 37 | `<!-- Copyright (C) 2018 The Android Open Source Project\n` + |
| 38 | `\n` + |
| 39 | ` Licensed under the Apache License, Version 2.0 (the "License");\n` + |
| 40 | ` you may not use this file except in compliance with the License.\n` + |
| 41 | ` You may obtain a copy of the License at\n` + |
| 42 | `\n` + |
| 43 | ` http://www.apache.org/licenses/LICENSE-2.0\n` + |
| 44 | `\n` + |
| 45 | ` Unless required by applicable law or agreed to in writing, software\n` + |
| 46 | ` distributed under the License is distributed on an "AS IS" BASIS,\n` + |
| 47 | ` WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n` + |
| 48 | ` See the License for the specific language governing permissions and\n` + |
| 49 | ` limitations under the License.\n` + |
| 50 | `-->\n` + |
| 51 | `<permissions>\n` + |
| 52 | ` <library name="%s" file="%s"/>\n` + |
| 53 | `</permissions>\n` |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 54 | ) |
| 55 | |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 56 | var ( |
| 57 | publicApiStubsTag = dependencyTag{name: "public"} |
| 58 | systemApiStubsTag = dependencyTag{name: "system"} |
Jiyong Park | df13054 | 2018-04-27 16:29:21 +0900 | [diff] [blame] | 59 | testApiStubsTag = dependencyTag{name: "test"} |
Sundong Ahn | 20e998b | 2018-07-24 11:19:26 +0900 | [diff] [blame] | 60 | publicApiFileTag = dependencyTag{name: "publicApi"} |
| 61 | systemApiFileTag = dependencyTag{name: "systemApi"} |
| 62 | testApiFileTag = dependencyTag{name: "testApi"} |
Jiyong Park | df13054 | 2018-04-27 16:29:21 +0900 | [diff] [blame] | 63 | ) |
| 64 | |
| 65 | type apiScope int |
| 66 | |
| 67 | const ( |
| 68 | apiScopePublic apiScope = iota |
| 69 | apiScopeSystem |
| 70 | apiScopeTest |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 71 | ) |
| 72 | |
Jiyong Park | 82484c0 | 2018-04-23 21:41:26 +0900 | [diff] [blame] | 73 | var ( |
| 74 | javaSdkLibrariesLock sync.Mutex |
| 75 | ) |
| 76 | |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 77 | // TODO: these are big features that are currently missing |
Jiyong Park | 1be9691 | 2018-05-28 18:02:19 +0900 | [diff] [blame] | 78 | // 1) disallowing linking to the runtime shared lib |
| 79 | // 2) HTML generation |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 80 | |
| 81 | func init() { |
Paul Duffin | 43dc1cc | 2019-12-19 11:18:54 +0000 | [diff] [blame] | 82 | RegisterSdkLibraryBuildComponents(android.InitRegistrationContext) |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 83 | |
Jiyong Park | 82484c0 | 2018-04-23 21:41:26 +0900 | [diff] [blame] | 84 | android.RegisterMakeVarsProvider(pctx, func(ctx android.MakeVarsContext) { |
| 85 | javaSdkLibraries := javaSdkLibraries(ctx.Config()) |
| 86 | sort.Strings(*javaSdkLibraries) |
| 87 | ctx.Strict("JAVA_SDK_LIBRARIES", strings.Join(*javaSdkLibraries, " ")) |
| 88 | }) |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 89 | } |
| 90 | |
Paul Duffin | 43dc1cc | 2019-12-19 11:18:54 +0000 | [diff] [blame] | 91 | func RegisterSdkLibraryBuildComponents(ctx android.RegistrationContext) { |
| 92 | ctx.RegisterModuleType("java_sdk_library", SdkLibraryFactory) |
| 93 | ctx.RegisterModuleType("java_sdk_library_import", sdkLibraryImportFactory) |
| 94 | } |
| 95 | |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 96 | type sdkLibraryProperties struct { |
Sundong Ahn | f043cf6 | 2018-06-25 16:04:37 +0900 | [diff] [blame] | 97 | // List of Java libraries that will be in the classpath when building stubs |
| 98 | Stub_only_libs []string `android:"arch_variant"` |
| 99 | |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 100 | // list of package names that will be documented and publicized as API |
| 101 | Api_packages []string |
| 102 | |
Jiyong Park | 5a2c9d7 | 2018-05-01 22:25:41 +0900 | [diff] [blame] | 103 | // list of package names that must be hidden from the API |
| 104 | Hidden_api_packages []string |
| 105 | |
Paul Duffin | 1151247 | 2019-02-11 15:55:17 +0000 | [diff] [blame] | 106 | // local files that are used within user customized droiddoc options. |
| 107 | Droiddoc_option_files []string |
| 108 | |
| 109 | // additional droiddoc options |
| 110 | // Available variables for substitution: |
| 111 | // |
| 112 | // $(location <label>): the path to the droiddoc_option_files with name <label> |
Sundong Ahn | dd567f9 | 2018-07-31 17:19:11 +0900 | [diff] [blame] | 113 | Droiddoc_options []string |
| 114 | |
Sundong Ahn | 054b19a | 2018-10-19 13:46:09 +0900 | [diff] [blame] | 115 | // a list of top-level directories containing files to merge qualifier annotations |
| 116 | // (i.e. those intended to be included in the stubs written) from. |
| 117 | Merge_annotations_dirs []string |
| 118 | |
| 119 | // a list of top-level directories containing Java stub files to merge show/hide annotations from. |
| 120 | Merge_inclusion_annotations_dirs []string |
| 121 | |
| 122 | // If set to true, the path of dist files is apistubs/core. Defaults to false. |
| 123 | Core_lib *bool |
| 124 | |
Sundong Ahn | 80a87b3 | 2019-05-13 15:02:50 +0900 | [diff] [blame] | 125 | // don't create dist rules. |
| 126 | No_dist *bool `blueprint:"mutated"` |
| 127 | |
Paul Duffin | 37e0b77 | 2019-12-30 17:20:10 +0000 | [diff] [blame^] | 128 | // indicates whether system and test apis should be managed. |
| 129 | Has_system_and_test_apis bool `blueprint:"mutated"` |
| 130 | |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 131 | // TODO: determines whether to create HTML doc or not |
| 132 | //Html_doc *bool |
| 133 | } |
| 134 | |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 135 | type SdkLibrary struct { |
Sundong Ahn | 054b19a | 2018-10-19 13:46:09 +0900 | [diff] [blame] | 136 | Library |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 137 | |
Sundong Ahn | 054b19a | 2018-10-19 13:46:09 +0900 | [diff] [blame] | 138 | sdkLibraryProperties sdkLibraryProperties |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 139 | |
| 140 | publicApiStubsPath android.Paths |
| 141 | systemApiStubsPath android.Paths |
Jiyong Park | df13054 | 2018-04-27 16:29:21 +0900 | [diff] [blame] | 142 | testApiStubsPath android.Paths |
Sundong Ahn | 241cd37 | 2018-07-13 16:16:44 +0900 | [diff] [blame] | 143 | |
| 144 | publicApiStubsImplPath android.Paths |
| 145 | systemApiStubsImplPath android.Paths |
| 146 | testApiStubsImplPath android.Paths |
Sundong Ahn | 20e998b | 2018-07-24 11:19:26 +0900 | [diff] [blame] | 147 | |
| 148 | publicApiFilePath android.Path |
| 149 | systemApiFilePath android.Path |
| 150 | testApiFilePath android.Path |
Jooyung Han | 58f26ab | 2019-12-18 15:34:32 +0900 | [diff] [blame] | 151 | |
Jooyung Han | 624058e | 2019-12-24 18:38:06 +0900 | [diff] [blame] | 152 | permissionsFile android.Path |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 153 | } |
| 154 | |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 155 | var _ Dependency = (*SdkLibrary)(nil) |
| 156 | var _ SdkLibraryDependency = (*SdkLibrary)(nil) |
Colin Cross | 897d2ed | 2019-02-11 14:03:51 -0800 | [diff] [blame] | 157 | |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 158 | func (module *SdkLibrary) DepsMutator(ctx android.BottomUpMutatorContext) { |
Jiyong Park | e3ef3c8 | 2019-07-15 15:31:16 +0900 | [diff] [blame] | 159 | useBuiltStubs := !ctx.Config().UnbundledBuildUsePrebuiltSdks() |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 160 | // Add dependencies to the stubs library |
Jiyong Park | e3ef3c8 | 2019-07-15 15:31:16 +0900 | [diff] [blame] | 161 | if useBuiltStubs { |
| 162 | ctx.AddVariationDependencies(nil, publicApiStubsTag, module.stubsName(apiScopePublic)) |
| 163 | } |
Colin Cross | 42d48b7 | 2018-08-29 14:10:52 -0700 | [diff] [blame] | 164 | ctx.AddVariationDependencies(nil, publicApiFileTag, module.docsName(apiScopePublic)) |
Sundong Ahn | 054b19a | 2018-10-19 13:46:09 +0900 | [diff] [blame] | 165 | |
Paul Duffin | 37e0b77 | 2019-12-30 17:20:10 +0000 | [diff] [blame^] | 166 | if module.sdkLibraryProperties.Has_system_and_test_apis { |
Jiyong Park | e3ef3c8 | 2019-07-15 15:31:16 +0900 | [diff] [blame] | 167 | if useBuiltStubs { |
| 168 | ctx.AddVariationDependencies(nil, systemApiStubsTag, module.stubsName(apiScopeSystem)) |
| 169 | ctx.AddVariationDependencies(nil, testApiStubsTag, module.stubsName(apiScopeTest)) |
| 170 | } |
Sundong Ahn | 054b19a | 2018-10-19 13:46:09 +0900 | [diff] [blame] | 171 | ctx.AddVariationDependencies(nil, systemApiFileTag, module.docsName(apiScopeSystem)) |
| 172 | ctx.AddVariationDependencies(nil, testApiFileTag, module.docsName(apiScopeTest)) |
Sundong Ahn | 054b19a | 2018-10-19 13:46:09 +0900 | [diff] [blame] | 173 | } |
| 174 | |
| 175 | module.Library.deps(ctx) |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 176 | } |
| 177 | |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 178 | func (module *SdkLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
Sundong Ahn | 054b19a | 2018-10-19 13:46:09 +0900 | [diff] [blame] | 179 | module.Library.GenerateAndroidBuildActions(ctx) |
| 180 | |
Jooyung Han | 624058e | 2019-12-24 18:38:06 +0900 | [diff] [blame] | 181 | module.buildPermissionsFile(ctx) |
Jooyung Han | 58f26ab | 2019-12-18 15:34:32 +0900 | [diff] [blame] | 182 | |
Sundong Ahn | 57368eb | 2018-07-06 11:20:23 +0900 | [diff] [blame] | 183 | // Record the paths to the header jars of the library (stubs and impl). |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 184 | // When this java_sdk_library is dependened from others via "libs" property, |
| 185 | // the recorded paths will be returned depending on the link type of the caller. |
| 186 | ctx.VisitDirectDeps(func(to android.Module) { |
| 187 | otherName := ctx.OtherModuleName(to) |
| 188 | tag := ctx.OtherModuleDependencyTag(to) |
| 189 | |
Sundong Ahn | 57368eb | 2018-07-06 11:20:23 +0900 | [diff] [blame] | 190 | if lib, ok := to.(Dependency); ok { |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 191 | switch tag { |
| 192 | case publicApiStubsTag: |
Sundong Ahn | 57368eb | 2018-07-06 11:20:23 +0900 | [diff] [blame] | 193 | module.publicApiStubsPath = lib.HeaderJars() |
Sundong Ahn | 241cd37 | 2018-07-13 16:16:44 +0900 | [diff] [blame] | 194 | module.publicApiStubsImplPath = lib.ImplementationJars() |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 195 | case systemApiStubsTag: |
Sundong Ahn | 57368eb | 2018-07-06 11:20:23 +0900 | [diff] [blame] | 196 | module.systemApiStubsPath = lib.HeaderJars() |
Sundong Ahn | 241cd37 | 2018-07-13 16:16:44 +0900 | [diff] [blame] | 197 | module.systemApiStubsImplPath = lib.ImplementationJars() |
Jiyong Park | df13054 | 2018-04-27 16:29:21 +0900 | [diff] [blame] | 198 | case testApiStubsTag: |
Sundong Ahn | 57368eb | 2018-07-06 11:20:23 +0900 | [diff] [blame] | 199 | module.testApiStubsPath = lib.HeaderJars() |
Sundong Ahn | 241cd37 | 2018-07-13 16:16:44 +0900 | [diff] [blame] | 200 | module.testApiStubsImplPath = lib.ImplementationJars() |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 201 | } |
| 202 | } |
Sundong Ahn | 20e998b | 2018-07-24 11:19:26 +0900 | [diff] [blame] | 203 | if doc, ok := to.(ApiFilePath); ok { |
| 204 | switch tag { |
| 205 | case publicApiFileTag: |
| 206 | module.publicApiFilePath = doc.ApiFilePath() |
| 207 | case systemApiFileTag: |
| 208 | module.systemApiFilePath = doc.ApiFilePath() |
| 209 | case testApiFileTag: |
| 210 | module.testApiFilePath = doc.ApiFilePath() |
| 211 | default: |
| 212 | ctx.ModuleErrorf("depends on module %q of unknown tag %q", otherName, tag) |
| 213 | } |
| 214 | } |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 215 | }) |
| 216 | } |
| 217 | |
Jooyung Han | 624058e | 2019-12-24 18:38:06 +0900 | [diff] [blame] | 218 | func (module *SdkLibrary) buildPermissionsFile(ctx android.ModuleContext) { |
| 219 | xmlContent := fmt.Sprintf(permissionsTemplate, module.BaseModuleName(), module.implPath()) |
| 220 | permissionsFile := android.PathForModuleOut(ctx, module.xmlFileName()) |
Jooyung Han | 58f26ab | 2019-12-18 15:34:32 +0900 | [diff] [blame] | 221 | |
Jooyung Han | 624058e | 2019-12-24 18:38:06 +0900 | [diff] [blame] | 222 | ctx.Build(pctx, android.BuildParams{ |
| 223 | Rule: android.WriteFile, |
| 224 | Output: permissionsFile, |
| 225 | Description: "Generating " + module.BaseModuleName() + " permissions", |
| 226 | Args: map[string]string{ |
| 227 | "content": xmlContent, |
| 228 | }, |
| 229 | }) |
Jooyung Han | 58f26ab | 2019-12-18 15:34:32 +0900 | [diff] [blame] | 230 | |
Jooyung Han | 624058e | 2019-12-24 18:38:06 +0900 | [diff] [blame] | 231 | module.permissionsFile = permissionsFile |
Jooyung Han | 58f26ab | 2019-12-18 15:34:32 +0900 | [diff] [blame] | 232 | } |
| 233 | |
Jooyung Han | 624058e | 2019-12-24 18:38:06 +0900 | [diff] [blame] | 234 | func (module *SdkLibrary) OutputFiles(tag string) (android.Paths, error) { |
| 235 | switch tag { |
| 236 | case ".xml": |
| 237 | return android.Paths{module.permissionsFile}, nil |
| 238 | } |
| 239 | return module.Library.OutputFiles(tag) |
Jooyung Han | 58f26ab | 2019-12-18 15:34:32 +0900 | [diff] [blame] | 240 | } |
| 241 | |
Jiyong Park | 0b0e1b9 | 2019-12-03 13:24:29 +0900 | [diff] [blame] | 242 | func (module *SdkLibrary) AndroidMkEntries() []android.AndroidMkEntries { |
| 243 | entriesList := module.Library.AndroidMkEntries() |
| 244 | entries := &entriesList[0] |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame] | 245 | entries.Required = append(entries.Required, module.xmlFileName()) |
Sundong Ahn | 054b19a | 2018-10-19 13:46:09 +0900 | [diff] [blame] | 246 | |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame] | 247 | entries.ExtraFooters = []android.AndroidMkExtraFootersFunc{ |
| 248 | func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) { |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame] | 249 | if !Bool(module.sdkLibraryProperties.No_dist) { |
| 250 | // Create a phony module that installs the impl library, for the case when this lib is |
| 251 | // in PRODUCT_PACKAGES. |
| 252 | owner := module.ModuleBase.Owner() |
| 253 | if owner == "" { |
| 254 | if Bool(module.sdkLibraryProperties.Core_lib) { |
| 255 | owner = "core" |
| 256 | } else { |
| 257 | owner = "android" |
| 258 | } |
| 259 | } |
| 260 | // Create dist rules to install the stubs libs to the dist dir |
| 261 | if len(module.publicApiStubsPath) == 1 { |
| 262 | fmt.Fprintln(w, "$(call dist-for-goals,sdk win_sdk,"+ |
| 263 | module.publicApiStubsImplPath.Strings()[0]+ |
| 264 | ":"+path.Join("apistubs", owner, "public", |
| 265 | module.BaseModuleName()+".jar")+")") |
| 266 | } |
| 267 | if len(module.systemApiStubsPath) == 1 { |
| 268 | fmt.Fprintln(w, "$(call dist-for-goals,sdk win_sdk,"+ |
| 269 | module.systemApiStubsImplPath.Strings()[0]+ |
| 270 | ":"+path.Join("apistubs", owner, "system", |
| 271 | module.BaseModuleName()+".jar")+")") |
| 272 | } |
| 273 | if len(module.testApiStubsPath) == 1 { |
| 274 | fmt.Fprintln(w, "$(call dist-for-goals,sdk win_sdk,"+ |
| 275 | module.testApiStubsImplPath.Strings()[0]+ |
| 276 | ":"+path.Join("apistubs", owner, "test", |
| 277 | module.BaseModuleName()+".jar")+")") |
| 278 | } |
| 279 | if module.publicApiFilePath != nil { |
| 280 | fmt.Fprintln(w, "$(call dist-for-goals,sdk win_sdk,"+ |
| 281 | module.publicApiFilePath.String()+ |
| 282 | ":"+path.Join("apistubs", owner, "public", "api", |
| 283 | module.BaseModuleName()+".txt")+")") |
| 284 | } |
| 285 | if module.systemApiFilePath != nil { |
| 286 | fmt.Fprintln(w, "$(call dist-for-goals,sdk win_sdk,"+ |
| 287 | module.systemApiFilePath.String()+ |
| 288 | ":"+path.Join("apistubs", owner, "system", "api", |
| 289 | module.BaseModuleName()+".txt")+")") |
| 290 | } |
| 291 | if module.testApiFilePath != nil { |
| 292 | fmt.Fprintln(w, "$(call dist-for-goals,sdk win_sdk,"+ |
| 293 | module.testApiFilePath.String()+ |
| 294 | ":"+path.Join("apistubs", owner, "test", "api", |
| 295 | module.BaseModuleName()+".txt")+")") |
Sundong Ahn | 80a87b3 | 2019-05-13 15:02:50 +0900 | [diff] [blame] | 296 | } |
Sundong Ahn | 4fd04bb | 2018-08-31 18:01:37 +0900 | [diff] [blame] | 297 | } |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame] | 298 | }, |
Jiyong Park | 82484c0 | 2018-04-23 21:41:26 +0900 | [diff] [blame] | 299 | } |
Jiyong Park | 0b0e1b9 | 2019-12-03 13:24:29 +0900 | [diff] [blame] | 300 | return entriesList |
Jiyong Park | 82484c0 | 2018-04-23 21:41:26 +0900 | [diff] [blame] | 301 | } |
| 302 | |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 303 | // Module name of the stubs library |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 304 | func (module *SdkLibrary) stubsName(apiScope apiScope) string { |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 305 | stubsName := module.BaseModuleName() + sdkStubsLibrarySuffix |
Jiyong Park | df13054 | 2018-04-27 16:29:21 +0900 | [diff] [blame] | 306 | switch apiScope { |
| 307 | case apiScopeSystem: |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 308 | stubsName = stubsName + sdkSystemApiSuffix |
Jiyong Park | df13054 | 2018-04-27 16:29:21 +0900 | [diff] [blame] | 309 | case apiScopeTest: |
| 310 | stubsName = stubsName + sdkTestApiSuffix |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 311 | } |
| 312 | return stubsName |
| 313 | } |
| 314 | |
| 315 | // Module name of the docs |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 316 | func (module *SdkLibrary) docsName(apiScope apiScope) string { |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 317 | docsName := module.BaseModuleName() + sdkDocsSuffix |
Jiyong Park | df13054 | 2018-04-27 16:29:21 +0900 | [diff] [blame] | 318 | switch apiScope { |
| 319 | case apiScopeSystem: |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 320 | docsName = docsName + sdkSystemApiSuffix |
Jiyong Park | df13054 | 2018-04-27 16:29:21 +0900 | [diff] [blame] | 321 | case apiScopeTest: |
| 322 | docsName = docsName + sdkTestApiSuffix |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 323 | } |
| 324 | return docsName |
| 325 | } |
| 326 | |
| 327 | // Module name of the runtime implementation library |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 328 | func (module *SdkLibrary) implName() string { |
Sundong Ahn | 054b19a | 2018-10-19 13:46:09 +0900 | [diff] [blame] | 329 | return module.BaseModuleName() |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 330 | } |
| 331 | |
| 332 | // File path to the runtime implementation library |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 333 | func (module *SdkLibrary) implPath() string { |
Jooyung Han | 58f26ab | 2019-12-18 15:34:32 +0900 | [diff] [blame] | 334 | if apexName := module.ApexName(); apexName != "" { |
| 335 | // TODO(b/146468504): ApexName() is only a soong module name, not apex name. |
| 336 | // In most cases, this works fine. But when apex_name is set or override_apex is used |
| 337 | // this can be wrong. |
| 338 | return fmt.Sprintf("/apex/%s/javalib/%s.jar", apexName, module.implName()) |
| 339 | } |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 340 | partition := "system" |
| 341 | if module.SocSpecific() { |
| 342 | partition = "vendor" |
| 343 | } else if module.DeviceSpecific() { |
| 344 | partition = "odm" |
| 345 | } else if module.ProductSpecific() { |
| 346 | partition = "product" |
Sundong Ahn | 0d7dff4 | 2019-12-04 12:53:44 +0900 | [diff] [blame] | 347 | } else if module.SystemExtSpecific() { |
| 348 | partition = "system_ext" |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 349 | } |
| 350 | return "/" + partition + "/framework/" + module.implName() + ".jar" |
| 351 | } |
| 352 | |
| 353 | // Module name of the XML file for the lib |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 354 | func (module *SdkLibrary) xmlFileName() string { |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 355 | return module.BaseModuleName() + sdkXmlFileSuffix |
| 356 | } |
| 357 | |
| 358 | // SDK version that the stubs library is built against. Note that this is always |
| 359 | // *current. Older stubs library built with a numberd SDK version is created from |
| 360 | // the prebuilt jar. |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 361 | func (module *SdkLibrary) sdkVersion(apiScope apiScope) string { |
Jiyong Park | df13054 | 2018-04-27 16:29:21 +0900 | [diff] [blame] | 362 | switch apiScope { |
| 363 | case apiScopePublic: |
| 364 | return "current" |
| 365 | case apiScopeSystem: |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 366 | return "system_current" |
Jiyong Park | df13054 | 2018-04-27 16:29:21 +0900 | [diff] [blame] | 367 | case apiScopeTest: |
| 368 | return "test_current" |
| 369 | default: |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 370 | return "current" |
| 371 | } |
| 372 | } |
| 373 | |
| 374 | // $(INTERNAL_PLATFORM_<apiTagName>_API_FILE) points to the generated |
| 375 | // api file for the current source |
| 376 | // TODO: remove this when apicheck is done in soong |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 377 | func (module *SdkLibrary) apiTagName(apiScope apiScope) string { |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 378 | apiTagName := strings.Replace(strings.ToUpper(module.BaseModuleName()), ".", "_", -1) |
Jiyong Park | df13054 | 2018-04-27 16:29:21 +0900 | [diff] [blame] | 379 | switch apiScope { |
| 380 | case apiScopeSystem: |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 381 | apiTagName = apiTagName + "_SYSTEM" |
Jiyong Park | df13054 | 2018-04-27 16:29:21 +0900 | [diff] [blame] | 382 | case apiScopeTest: |
| 383 | apiTagName = apiTagName + "_TEST" |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 384 | } |
| 385 | return apiTagName |
| 386 | } |
| 387 | |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 388 | func (module *SdkLibrary) latestApiFilegroupName(apiScope apiScope) string { |
Jiyong Park | 58c518b | 2018-05-12 22:29:12 +0900 | [diff] [blame] | 389 | name := ":" + module.BaseModuleName() + ".api." |
Jiyong Park | df13054 | 2018-04-27 16:29:21 +0900 | [diff] [blame] | 390 | switch apiScope { |
Jiyong Park | 58c518b | 2018-05-12 22:29:12 +0900 | [diff] [blame] | 391 | case apiScopePublic: |
| 392 | name = name + "public" |
Jiyong Park | df13054 | 2018-04-27 16:29:21 +0900 | [diff] [blame] | 393 | case apiScopeSystem: |
Jiyong Park | 58c518b | 2018-05-12 22:29:12 +0900 | [diff] [blame] | 394 | name = name + "system" |
Jiyong Park | df13054 | 2018-04-27 16:29:21 +0900 | [diff] [blame] | 395 | case apiScopeTest: |
Jiyong Park | 58c518b | 2018-05-12 22:29:12 +0900 | [diff] [blame] | 396 | name = name + "test" |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 397 | } |
Jiyong Park | 58c518b | 2018-05-12 22:29:12 +0900 | [diff] [blame] | 398 | name = name + ".latest" |
| 399 | return name |
| 400 | } |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 401 | |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 402 | func (module *SdkLibrary) latestRemovedApiFilegroupName(apiScope apiScope) string { |
Jiyong Park | 58c518b | 2018-05-12 22:29:12 +0900 | [diff] [blame] | 403 | name := ":" + module.BaseModuleName() + "-removed.api." |
| 404 | switch apiScope { |
| 405 | case apiScopePublic: |
| 406 | name = name + "public" |
| 407 | case apiScopeSystem: |
| 408 | name = name + "system" |
| 409 | case apiScopeTest: |
| 410 | name = name + "test" |
| 411 | } |
| 412 | name = name + ".latest" |
| 413 | return name |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 414 | } |
| 415 | |
| 416 | // Creates a static java library that has API stubs |
Colin Cross | f8b860a | 2019-04-16 14:43:28 -0700 | [diff] [blame] | 417 | func (module *SdkLibrary) createStubsLibrary(mctx android.LoadHookContext, apiScope apiScope) { |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 418 | props := struct { |
Sundong Ahn | 0d7dff4 | 2019-12-04 12:53:44 +0900 | [diff] [blame] | 419 | Name *string |
| 420 | Srcs []string |
| 421 | Sdk_version *string |
| 422 | Libs []string |
| 423 | Soc_specific *bool |
| 424 | Device_specific *bool |
| 425 | Product_specific *bool |
| 426 | System_ext_specific *bool |
| 427 | Compile_dex *bool |
| 428 | System_modules *string |
| 429 | Java_version *string |
| 430 | Product_variables struct { |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 431 | Unbundled_build struct { |
| 432 | Enabled *bool |
| 433 | } |
Jiyong Park | 82484c0 | 2018-04-23 21:41:26 +0900 | [diff] [blame] | 434 | Pdk struct { |
| 435 | Enabled *bool |
| 436 | } |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 437 | } |
Sundong Ahn | 054b19a | 2018-10-19 13:46:09 +0900 | [diff] [blame] | 438 | Openjdk9 struct { |
| 439 | Srcs []string |
| 440 | Javacflags []string |
| 441 | } |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 442 | }{} |
| 443 | |
Paul Duffin | 52d398a | 2019-06-11 12:31:14 +0100 | [diff] [blame] | 444 | sdkVersion := module.sdkVersion(apiScope) |
Paul Duffin | 250e619 | 2019-06-07 10:44:37 +0100 | [diff] [blame] | 445 | sdkDep := decodeSdkDep(mctx, sdkContext(&module.Library)) |
Paul Duffin | 52d398a | 2019-06-11 12:31:14 +0100 | [diff] [blame] | 446 | if !sdkDep.hasStandardLibs() { |
| 447 | sdkVersion = "none" |
| 448 | } |
Paul Duffin | 250e619 | 2019-06-07 10:44:37 +0100 | [diff] [blame] | 449 | |
Jiyong Park | df13054 | 2018-04-27 16:29:21 +0900 | [diff] [blame] | 450 | props.Name = proptools.StringPtr(module.stubsName(apiScope)) |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 451 | // sources are generated from the droiddoc |
Jiyong Park | df13054 | 2018-04-27 16:29:21 +0900 | [diff] [blame] | 452 | props.Srcs = []string{":" + module.docsName(apiScope)} |
Paul Duffin | 52d398a | 2019-06-11 12:31:14 +0100 | [diff] [blame] | 453 | props.Sdk_version = proptools.StringPtr(sdkVersion) |
Sundong Ahn | 054b19a | 2018-10-19 13:46:09 +0900 | [diff] [blame] | 454 | props.Libs = module.sdkLibraryProperties.Stub_only_libs |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 455 | // Unbundled apps will use the prebult one from /prebuilts/sdk |
Colin Cross | 1093287 | 2019-04-18 14:27:12 -0700 | [diff] [blame] | 456 | if mctx.Config().UnbundledBuildUsePrebuiltSdks() { |
Colin Cross | 2c77ceb | 2019-01-21 11:56:21 -0800 | [diff] [blame] | 457 | props.Product_variables.Unbundled_build.Enabled = proptools.BoolPtr(false) |
| 458 | } |
Jiyong Park | 82484c0 | 2018-04-23 21:41:26 +0900 | [diff] [blame] | 459 | props.Product_variables.Pdk.Enabled = proptools.BoolPtr(false) |
Sundong Ahn | 054b19a | 2018-10-19 13:46:09 +0900 | [diff] [blame] | 460 | props.System_modules = module.Library.Module.deviceProperties.System_modules |
| 461 | props.Openjdk9.Srcs = module.Library.Module.properties.Openjdk9.Srcs |
| 462 | props.Openjdk9.Javacflags = module.Library.Module.properties.Openjdk9.Javacflags |
| 463 | props.Java_version = module.Library.Module.properties.Java_version |
| 464 | if module.Library.Module.deviceProperties.Compile_dex != nil { |
| 465 | props.Compile_dex = module.Library.Module.deviceProperties.Compile_dex |
Sundong Ahn | dd567f9 | 2018-07-31 17:19:11 +0900 | [diff] [blame] | 466 | } |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 467 | |
| 468 | if module.SocSpecific() { |
| 469 | props.Soc_specific = proptools.BoolPtr(true) |
| 470 | } else if module.DeviceSpecific() { |
| 471 | props.Device_specific = proptools.BoolPtr(true) |
| 472 | } else if module.ProductSpecific() { |
| 473 | props.Product_specific = proptools.BoolPtr(true) |
Sundong Ahn | 0d7dff4 | 2019-12-04 12:53:44 +0900 | [diff] [blame] | 474 | } else if module.SystemExtSpecific() { |
| 475 | props.System_ext_specific = proptools.BoolPtr(true) |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 476 | } |
| 477 | |
Colin Cross | 84dfc3d | 2019-09-25 11:33:01 -0700 | [diff] [blame] | 478 | mctx.CreateModule(LibraryFactory, &props) |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 479 | } |
| 480 | |
| 481 | // Creates a droiddoc module that creates stubs source files from the given full source |
| 482 | // files |
Paul Duffin | c4cea76 | 2019-12-30 17:32:47 +0000 | [diff] [blame] | 483 | func (module *SdkLibrary) createStubsSources(mctx android.LoadHookContext, apiScope apiScope) { |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 484 | props := struct { |
Sundong Ahn | 054b19a | 2018-10-19 13:46:09 +0900 | [diff] [blame] | 485 | Name *string |
| 486 | Srcs []string |
| 487 | Installable *bool |
Paul Duffin | 52d398a | 2019-06-11 12:31:14 +0100 | [diff] [blame] | 488 | Sdk_version *string |
Sundong Ahn | 054b19a | 2018-10-19 13:46:09 +0900 | [diff] [blame] | 489 | Libs []string |
Paul Duffin | 1151247 | 2019-02-11 15:55:17 +0000 | [diff] [blame] | 490 | Arg_files []string |
Sundong Ahn | 054b19a | 2018-10-19 13:46:09 +0900 | [diff] [blame] | 491 | Args *string |
| 492 | Api_tag_name *string |
| 493 | Api_filename *string |
| 494 | Removed_api_filename *string |
Sundong Ahn | 054b19a | 2018-10-19 13:46:09 +0900 | [diff] [blame] | 495 | Java_version *string |
| 496 | Merge_annotations_dirs []string |
| 497 | Merge_inclusion_annotations_dirs []string |
| 498 | Check_api struct { |
Inseob Kim | 38449af | 2019-02-28 14:24:05 +0900 | [diff] [blame] | 499 | Current ApiToCheck |
| 500 | Last_released ApiToCheck |
| 501 | Ignore_missing_latest_api *bool |
Jiyong Park | 58c518b | 2018-05-12 22:29:12 +0900 | [diff] [blame] | 502 | } |
Sundong Ahn | 1b92c82 | 2018-05-29 11:35:17 +0900 | [diff] [blame] | 503 | Aidl struct { |
| 504 | Include_dirs []string |
| 505 | Local_include_dirs []string |
| 506 | } |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 507 | }{} |
| 508 | |
Paul Duffin | 250e619 | 2019-06-07 10:44:37 +0100 | [diff] [blame] | 509 | sdkDep := decodeSdkDep(mctx, sdkContext(&module.Library)) |
Paul Duffin | 52d398a | 2019-06-11 12:31:14 +0100 | [diff] [blame] | 510 | sdkVersion := "" |
| 511 | if !sdkDep.hasStandardLibs() { |
| 512 | sdkVersion = "none" |
| 513 | } |
Paul Duffin | 250e619 | 2019-06-07 10:44:37 +0100 | [diff] [blame] | 514 | |
Jiyong Park | df13054 | 2018-04-27 16:29:21 +0900 | [diff] [blame] | 515 | props.Name = proptools.StringPtr(module.docsName(apiScope)) |
Sundong Ahn | 054b19a | 2018-10-19 13:46:09 +0900 | [diff] [blame] | 516 | props.Srcs = append(props.Srcs, module.Library.Module.properties.Srcs...) |
Paul Duffin | 52d398a | 2019-06-11 12:31:14 +0100 | [diff] [blame] | 517 | props.Sdk_version = proptools.StringPtr(sdkVersion) |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 518 | props.Installable = proptools.BoolPtr(false) |
Sundong Ahn | e6f0b05 | 2018-06-05 16:46:14 +0900 | [diff] [blame] | 519 | // A droiddoc module has only one Libs property and doesn't distinguish between |
| 520 | // shared libs and static libs. So we need to add both of these libs to Libs property. |
Sundong Ahn | 054b19a | 2018-10-19 13:46:09 +0900 | [diff] [blame] | 521 | props.Libs = module.Library.Module.properties.Libs |
| 522 | props.Libs = append(props.Libs, module.Library.Module.properties.Static_libs...) |
| 523 | props.Aidl.Include_dirs = module.Library.Module.deviceProperties.Aidl.Include_dirs |
| 524 | props.Aidl.Local_include_dirs = module.Library.Module.deviceProperties.Aidl.Local_include_dirs |
Sundong Ahn | 054b19a | 2018-10-19 13:46:09 +0900 | [diff] [blame] | 525 | props.Java_version = module.Library.Module.properties.Java_version |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 526 | |
Sundong Ahn | 054b19a | 2018-10-19 13:46:09 +0900 | [diff] [blame] | 527 | props.Merge_annotations_dirs = module.sdkLibraryProperties.Merge_annotations_dirs |
| 528 | props.Merge_inclusion_annotations_dirs = module.sdkLibraryProperties.Merge_inclusion_annotations_dirs |
| 529 | |
Paul Duffin | 235ffff | 2019-12-24 10:41:30 +0000 | [diff] [blame] | 530 | droiddocArgs := []string{} |
| 531 | if len(module.sdkLibraryProperties.Api_packages) != 0 { |
| 532 | droiddocArgs = append(droiddocArgs, "--stub-packages "+strings.Join(module.sdkLibraryProperties.Api_packages, ":")) |
| 533 | } |
| 534 | if len(module.sdkLibraryProperties.Hidden_api_packages) != 0 { |
| 535 | droiddocArgs = append(droiddocArgs, |
| 536 | android.JoinWithPrefix(module.sdkLibraryProperties.Hidden_api_packages, " --hide-package ")) |
| 537 | } |
| 538 | droiddocArgs = append(droiddocArgs, module.sdkLibraryProperties.Droiddoc_options...) |
| 539 | disabledWarnings := []string{ |
| 540 | "MissingPermission", |
| 541 | "BroadcastBehavior", |
| 542 | "HiddenSuperclass", |
| 543 | "DeprecationMismatch", |
| 544 | "UnavailableSymbol", |
| 545 | "SdkConstant", |
| 546 | "HiddenTypeParameter", |
| 547 | "Todo", |
| 548 | "Typo", |
| 549 | } |
| 550 | droiddocArgs = append(droiddocArgs, android.JoinWithPrefix(disabledWarnings, "--hide ")) |
Sundong Ahn | fb2721f | 2018-09-17 13:23:09 +0900 | [diff] [blame] | 551 | |
Jiyong Park | df13054 | 2018-04-27 16:29:21 +0900 | [diff] [blame] | 552 | switch apiScope { |
| 553 | case apiScopeSystem: |
Paul Duffin | 235ffff | 2019-12-24 10:41:30 +0000 | [diff] [blame] | 554 | droiddocArgs = append(droiddocArgs, "-showAnnotation android.annotation.SystemApi") |
Jiyong Park | df13054 | 2018-04-27 16:29:21 +0900 | [diff] [blame] | 555 | case apiScopeTest: |
Paul Duffin | 235ffff | 2019-12-24 10:41:30 +0000 | [diff] [blame] | 556 | droiddocArgs = append(droiddocArgs, " -showAnnotation android.annotation.TestApi") |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 557 | } |
Paul Duffin | 1151247 | 2019-02-11 15:55:17 +0000 | [diff] [blame] | 558 | props.Arg_files = module.sdkLibraryProperties.Droiddoc_option_files |
Paul Duffin | 235ffff | 2019-12-24 10:41:30 +0000 | [diff] [blame] | 559 | props.Args = proptools.StringPtr(strings.Join(droiddocArgs, " ")) |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 560 | |
| 561 | // List of APIs identified from the provided source files are created. They are later |
| 562 | // compared against to the not-yet-released (a.k.a current) list of APIs and to the |
| 563 | // last-released (a.k.a numbered) list of API. |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 564 | currentApiFileName := "current.txt" |
| 565 | removedApiFileName := "removed.txt" |
Jiyong Park | df13054 | 2018-04-27 16:29:21 +0900 | [diff] [blame] | 566 | switch apiScope { |
| 567 | case apiScopeSystem: |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 568 | currentApiFileName = "system-" + currentApiFileName |
| 569 | removedApiFileName = "system-" + removedApiFileName |
Jiyong Park | df13054 | 2018-04-27 16:29:21 +0900 | [diff] [blame] | 570 | case apiScopeTest: |
| 571 | currentApiFileName = "test-" + currentApiFileName |
| 572 | removedApiFileName = "test-" + removedApiFileName |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 573 | } |
| 574 | currentApiFileName = path.Join("api", currentApiFileName) |
| 575 | removedApiFileName = path.Join("api", removedApiFileName) |
Jiyong Park | 58c518b | 2018-05-12 22:29:12 +0900 | [diff] [blame] | 576 | // TODO(jiyong): remove these three props |
Jiyong Park | df13054 | 2018-04-27 16:29:21 +0900 | [diff] [blame] | 577 | props.Api_tag_name = proptools.StringPtr(module.apiTagName(apiScope)) |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 578 | props.Api_filename = proptools.StringPtr(currentApiFileName) |
| 579 | props.Removed_api_filename = proptools.StringPtr(removedApiFileName) |
| 580 | |
Jiyong Park | 58c518b | 2018-05-12 22:29:12 +0900 | [diff] [blame] | 581 | // check against the not-yet-release API |
| 582 | props.Check_api.Current.Api_file = proptools.StringPtr(currentApiFileName) |
| 583 | props.Check_api.Current.Removed_api_file = proptools.StringPtr(removedApiFileName) |
Jiyong Park | 58c518b | 2018-05-12 22:29:12 +0900 | [diff] [blame] | 584 | |
| 585 | // check against the latest released API |
| 586 | props.Check_api.Last_released.Api_file = proptools.StringPtr( |
| 587 | module.latestApiFilegroupName(apiScope)) |
| 588 | props.Check_api.Last_released.Removed_api_file = proptools.StringPtr( |
| 589 | module.latestRemovedApiFilegroupName(apiScope)) |
Inseob Kim | 38449af | 2019-02-28 14:24:05 +0900 | [diff] [blame] | 590 | props.Check_api.Ignore_missing_latest_api = proptools.BoolPtr(true) |
Jiyong Park | 58c518b | 2018-05-12 22:29:12 +0900 | [diff] [blame] | 591 | |
Colin Cross | 84dfc3d | 2019-09-25 11:33:01 -0700 | [diff] [blame] | 592 | mctx.CreateModule(DroidstubsFactory, &props) |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 593 | } |
| 594 | |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 595 | // Creates the xml file that publicizes the runtime library |
Colin Cross | f8b860a | 2019-04-16 14:43:28 -0700 | [diff] [blame] | 596 | func (module *SdkLibrary) createXmlFile(mctx android.LoadHookContext) { |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 597 | // creates a prebuilt_etc module to actually place the xml file under |
| 598 | // <partition>/etc/permissions |
| 599 | etcProps := struct { |
Sundong Ahn | 0d7dff4 | 2019-12-04 12:53:44 +0900 | [diff] [blame] | 600 | Name *string |
| 601 | Src *string |
| 602 | Sub_dir *string |
| 603 | Soc_specific *bool |
| 604 | Device_specific *bool |
| 605 | Product_specific *bool |
| 606 | System_ext_specific *bool |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 607 | }{} |
| 608 | etcProps.Name = proptools.StringPtr(module.xmlFileName()) |
Jooyung Han | 624058e | 2019-12-24 18:38:06 +0900 | [diff] [blame] | 609 | etcProps.Src = proptools.StringPtr(":" + module.BaseModuleName() + "{.xml}") |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 610 | etcProps.Sub_dir = proptools.StringPtr("permissions") |
| 611 | if module.SocSpecific() { |
| 612 | etcProps.Soc_specific = proptools.BoolPtr(true) |
| 613 | } else if module.DeviceSpecific() { |
| 614 | etcProps.Device_specific = proptools.BoolPtr(true) |
| 615 | } else if module.ProductSpecific() { |
| 616 | etcProps.Product_specific = proptools.BoolPtr(true) |
Sundong Ahn | 0d7dff4 | 2019-12-04 12:53:44 +0900 | [diff] [blame] | 617 | } else if module.SystemExtSpecific() { |
| 618 | etcProps.System_ext_specific = proptools.BoolPtr(true) |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 619 | } |
Colin Cross | 84dfc3d | 2019-09-25 11:33:01 -0700 | [diff] [blame] | 620 | mctx.CreateModule(android.PrebuiltEtcFactory, &etcProps) |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 621 | } |
| 622 | |
Colin Cross | 0ea8ba8 | 2019-06-06 14:33:29 -0700 | [diff] [blame] | 623 | func (module *SdkLibrary) PrebuiltJars(ctx android.BaseModuleContext, sdkVersion string) android.Paths { |
Sundong Ahn | 054b19a | 2018-10-19 13:46:09 +0900 | [diff] [blame] | 624 | var api, v string |
Paul Duffin | 52d398a | 2019-06-11 12:31:14 +0100 | [diff] [blame] | 625 | if sdkVersion == "" || sdkVersion == "none" { |
Sundong Ahn | 054b19a | 2018-10-19 13:46:09 +0900 | [diff] [blame] | 626 | api = "system" |
| 627 | v = "current" |
| 628 | } else if strings.Contains(sdkVersion, "_") { |
| 629 | t := strings.Split(sdkVersion, "_") |
| 630 | api = t[0] |
| 631 | v = t[1] |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 632 | } else { |
Sundong Ahn | 054b19a | 2018-10-19 13:46:09 +0900 | [diff] [blame] | 633 | api = "public" |
| 634 | v = sdkVersion |
| 635 | } |
| 636 | dir := filepath.Join("prebuilts", "sdk", v, api) |
| 637 | jar := filepath.Join(dir, module.BaseModuleName()+".jar") |
| 638 | jarPath := android.ExistentPathForSource(ctx, jar) |
Sundong Ahn | ae418ac | 2019-02-28 15:01:28 +0900 | [diff] [blame] | 639 | if !jarPath.Valid() { |
| 640 | ctx.PropertyErrorf("sdk_library", "invalid sdk version %q, %q does not exist", v, jar) |
| 641 | return nil |
| 642 | } |
Sundong Ahn | 054b19a | 2018-10-19 13:46:09 +0900 | [diff] [blame] | 643 | return android.Paths{jarPath.Path()} |
| 644 | } |
| 645 | |
| 646 | // to satisfy SdkLibraryDependency interface |
Colin Cross | 0ea8ba8 | 2019-06-06 14:33:29 -0700 | [diff] [blame] | 647 | func (module *SdkLibrary) SdkHeaderJars(ctx android.BaseModuleContext, sdkVersion string) android.Paths { |
Sundong Ahn | 054b19a | 2018-10-19 13:46:09 +0900 | [diff] [blame] | 648 | // This module is just a wrapper for the stubs. |
Colin Cross | 1093287 | 2019-04-18 14:27:12 -0700 | [diff] [blame] | 649 | if ctx.Config().UnbundledBuildUsePrebuiltSdks() { |
Sundong Ahn | 054b19a | 2018-10-19 13:46:09 +0900 | [diff] [blame] | 650 | return module.PrebuiltJars(ctx, sdkVersion) |
| 651 | } else { |
| 652 | if strings.HasPrefix(sdkVersion, "system_") { |
| 653 | return module.systemApiStubsPath |
| 654 | } else if sdkVersion == "" { |
| 655 | return module.Library.HeaderJars() |
| 656 | } else { |
| 657 | return module.publicApiStubsPath |
| 658 | } |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 659 | } |
| 660 | } |
| 661 | |
Sundong Ahn | 241cd37 | 2018-07-13 16:16:44 +0900 | [diff] [blame] | 662 | // to satisfy SdkLibraryDependency interface |
Colin Cross | 0ea8ba8 | 2019-06-06 14:33:29 -0700 | [diff] [blame] | 663 | func (module *SdkLibrary) SdkImplementationJars(ctx android.BaseModuleContext, sdkVersion string) android.Paths { |
Sundong Ahn | 241cd37 | 2018-07-13 16:16:44 +0900 | [diff] [blame] | 664 | // This module is just a wrapper for the stubs. |
Colin Cross | 1093287 | 2019-04-18 14:27:12 -0700 | [diff] [blame] | 665 | if ctx.Config().UnbundledBuildUsePrebuiltSdks() { |
Sundong Ahn | 054b19a | 2018-10-19 13:46:09 +0900 | [diff] [blame] | 666 | return module.PrebuiltJars(ctx, sdkVersion) |
Sundong Ahn | 241cd37 | 2018-07-13 16:16:44 +0900 | [diff] [blame] | 667 | } else { |
Sundong Ahn | 054b19a | 2018-10-19 13:46:09 +0900 | [diff] [blame] | 668 | if strings.HasPrefix(sdkVersion, "system_") { |
| 669 | return module.systemApiStubsImplPath |
| 670 | } else if sdkVersion == "" { |
| 671 | return module.Library.ImplementationJars() |
| 672 | } else { |
| 673 | return module.publicApiStubsImplPath |
| 674 | } |
Sundong Ahn | 241cd37 | 2018-07-13 16:16:44 +0900 | [diff] [blame] | 675 | } |
| 676 | } |
| 677 | |
Sundong Ahn | 80a87b3 | 2019-05-13 15:02:50 +0900 | [diff] [blame] | 678 | func (module *SdkLibrary) SetNoDist() { |
| 679 | module.sdkLibraryProperties.No_dist = proptools.BoolPtr(true) |
| 680 | } |
| 681 | |
Colin Cross | 571cccf | 2019-02-04 11:22:08 -0800 | [diff] [blame] | 682 | var javaSdkLibrariesKey = android.NewOnceKey("javaSdkLibraries") |
| 683 | |
Jiyong Park | 82484c0 | 2018-04-23 21:41:26 +0900 | [diff] [blame] | 684 | func javaSdkLibraries(config android.Config) *[]string { |
Colin Cross | 571cccf | 2019-02-04 11:22:08 -0800 | [diff] [blame] | 685 | return config.Once(javaSdkLibrariesKey, func() interface{} { |
Jiyong Park | 82484c0 | 2018-04-23 21:41:26 +0900 | [diff] [blame] | 686 | return &[]string{} |
| 687 | }).(*[]string) |
| 688 | } |
| 689 | |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 690 | // For a java_sdk_library module, create internal modules for stubs, docs, |
| 691 | // runtime libs and xml file. If requested, the stubs and docs are created twice |
| 692 | // once for public API level and once for system API level |
Colin Cross | f8b860a | 2019-04-16 14:43:28 -0700 | [diff] [blame] | 693 | func (module *SdkLibrary) CreateInternalModules(mctx android.LoadHookContext) { |
Inseob Kim | 6e93ac9 | 2019-03-21 17:43:49 +0900 | [diff] [blame] | 694 | if len(module.Library.Module.properties.Srcs) == 0 { |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 695 | mctx.PropertyErrorf("srcs", "java_sdk_library must specify srcs") |
Jooyung Han | 58f26ab | 2019-12-18 15:34:32 +0900 | [diff] [blame] | 696 | return |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 697 | } |
| 698 | |
Inseob Kim | 6e93ac9 | 2019-03-21 17:43:49 +0900 | [diff] [blame] | 699 | if len(module.sdkLibraryProperties.Api_packages) == 0 { |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 700 | mctx.PropertyErrorf("api_packages", "java_sdk_library must specify api_packages") |
Jooyung Han | 58f26ab | 2019-12-18 15:34:32 +0900 | [diff] [blame] | 701 | return |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 702 | } |
Inseob Kim | 8098faa | 2019-03-18 10:19:51 +0900 | [diff] [blame] | 703 | |
Paul Duffin | 37e0b77 | 2019-12-30 17:20:10 +0000 | [diff] [blame^] | 704 | // If this builds against standard libraries (i.e. is not part of the core libraries) |
| 705 | // then assume it provides both system and test apis. Otherwise, assume it does not and |
| 706 | // also assume it does not contribute to the dist build. |
| 707 | sdkDep := decodeSdkDep(mctx, sdkContext(&module.Library)) |
| 708 | hasSystemAndTestApis := sdkDep.hasStandardLibs() |
| 709 | module.sdkLibraryProperties.Has_system_and_test_apis = hasSystemAndTestApis |
| 710 | module.sdkLibraryProperties.No_dist = proptools.BoolPtr(!hasSystemAndTestApis) |
| 711 | |
| 712 | scopes := []string{""} |
| 713 | if hasSystemAndTestApis { |
| 714 | scopes = append(scopes, "system-", "test-") |
| 715 | } |
| 716 | |
Inseob Kim | 8098faa | 2019-03-18 10:19:51 +0900 | [diff] [blame] | 717 | missing_current_api := false |
| 718 | |
Paul Duffin | 37e0b77 | 2019-12-30 17:20:10 +0000 | [diff] [blame^] | 719 | for _, scope := range scopes { |
Inseob Kim | 8098faa | 2019-03-18 10:19:51 +0900 | [diff] [blame] | 720 | for _, api := range []string{"current.txt", "removed.txt"} { |
| 721 | path := path.Join(mctx.ModuleDir(), "api", scope+api) |
| 722 | p := android.ExistentPathForSource(mctx, path) |
| 723 | if !p.Valid() { |
| 724 | mctx.ModuleErrorf("Current api file %#v doesn't exist", path) |
| 725 | missing_current_api = true |
| 726 | } |
| 727 | } |
| 728 | } |
| 729 | |
| 730 | if missing_current_api { |
| 731 | script := "build/soong/scripts/gen-java-current-api-files.sh" |
| 732 | p := android.ExistentPathForSource(mctx, script) |
| 733 | |
| 734 | if !p.Valid() { |
| 735 | panic(fmt.Sprintf("script file %s doesn't exist", script)) |
| 736 | } |
| 737 | |
| 738 | mctx.ModuleErrorf("One or more current api files are missing. "+ |
| 739 | "You can update them by:\n"+ |
Paul Duffin | 37e0b77 | 2019-12-30 17:20:10 +0000 | [diff] [blame^] | 740 | "%s %q %s && m update-api", |
| 741 | script, mctx.ModuleDir(), strings.Join(scopes, " ")) |
Inseob Kim | 8098faa | 2019-03-18 10:19:51 +0900 | [diff] [blame] | 742 | return |
| 743 | } |
| 744 | |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 745 | // for public API stubs |
| 746 | module.createStubsLibrary(mctx, apiScopePublic) |
Paul Duffin | c4cea76 | 2019-12-30 17:32:47 +0000 | [diff] [blame] | 747 | module.createStubsSources(mctx, apiScopePublic) |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 748 | |
Paul Duffin | 37e0b77 | 2019-12-30 17:20:10 +0000 | [diff] [blame^] | 749 | if hasSystemAndTestApis { |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 750 | // for system API stubs |
| 751 | module.createStubsLibrary(mctx, apiScopeSystem) |
Paul Duffin | c4cea76 | 2019-12-30 17:32:47 +0000 | [diff] [blame] | 752 | module.createStubsSources(mctx, apiScopeSystem) |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 753 | |
| 754 | // for test API stubs |
| 755 | module.createStubsLibrary(mctx, apiScopeTest) |
Paul Duffin | c4cea76 | 2019-12-30 17:32:47 +0000 | [diff] [blame] | 756 | module.createStubsSources(mctx, apiScopeTest) |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 757 | |
| 758 | // for runtime |
| 759 | module.createXmlFile(mctx) |
| 760 | } |
| 761 | |
| 762 | // record java_sdk_library modules so that they are exported to make |
| 763 | javaSdkLibraries := javaSdkLibraries(mctx.Config()) |
| 764 | javaSdkLibrariesLock.Lock() |
| 765 | defer javaSdkLibrariesLock.Unlock() |
| 766 | *javaSdkLibraries = append(*javaSdkLibraries, module.BaseModuleName()) |
| 767 | } |
| 768 | |
| 769 | func (module *SdkLibrary) InitSdkLibraryProperties() { |
Sundong Ahn | 054b19a | 2018-10-19 13:46:09 +0900 | [diff] [blame] | 770 | module.AddProperties( |
| 771 | &module.sdkLibraryProperties, |
| 772 | &module.Library.Module.properties, |
| 773 | &module.Library.Module.dexpreoptProperties, |
| 774 | &module.Library.Module.deviceProperties, |
| 775 | &module.Library.Module.protoProperties, |
| 776 | ) |
| 777 | |
| 778 | module.Library.Module.properties.Installable = proptools.BoolPtr(true) |
| 779 | module.Library.Module.deviceProperties.IsSDKLibrary = true |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 780 | } |
Sundong Ahn | 054b19a | 2018-10-19 13:46:09 +0900 | [diff] [blame] | 781 | |
Jaewoong Jung | 4f158ee | 2019-07-11 10:05:35 -0700 | [diff] [blame] | 782 | // java_sdk_library is a special Java library that provides optional platform APIs to apps. |
| 783 | // In practice, it can be viewed as a combination of several modules: 1) stubs library that clients |
| 784 | // are linked against to, 2) droiddoc module that internally generates API stubs source files, |
| 785 | // 3) the real runtime shared library that implements the APIs, and 4) XML file for adding |
| 786 | // the runtime lib to the classpath at runtime if requested via <uses-library>. |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 787 | func SdkLibraryFactory() android.Module { |
| 788 | module := &SdkLibrary{} |
| 789 | module.InitSdkLibraryProperties() |
Jooyung Han | 58f26ab | 2019-12-18 15:34:32 +0900 | [diff] [blame] | 790 | android.InitApexModule(module) |
Sundong Ahn | 054b19a | 2018-10-19 13:46:09 +0900 | [diff] [blame] | 791 | InitJavaModule(module, android.HostAndDeviceSupported) |
Colin Cross | f8b860a | 2019-04-16 14:43:28 -0700 | [diff] [blame] | 792 | android.AddLoadHook(module, func(ctx android.LoadHookContext) { module.CreateInternalModules(ctx) }) |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 793 | return module |
| 794 | } |
Colin Cross | 79c7c26 | 2019-04-17 11:11:46 -0700 | [diff] [blame] | 795 | |
| 796 | // |
| 797 | // SDK library prebuilts |
| 798 | // |
| 799 | |
| 800 | type sdkLibraryImportProperties struct { |
| 801 | Jars []string `android:"path"` |
| 802 | |
| 803 | Sdk_version *string |
| 804 | |
| 805 | Installable *bool |
| 806 | |
| 807 | // List of shared java libs that this module has dependencies to |
| 808 | Libs []string |
| 809 | |
| 810 | // List of files to remove from the jar file(s) |
| 811 | Exclude_files []string |
| 812 | |
| 813 | // List of directories to remove from the jar file(s) |
| 814 | Exclude_dirs []string |
| 815 | } |
| 816 | |
| 817 | type sdkLibraryImport struct { |
| 818 | android.ModuleBase |
| 819 | android.DefaultableModuleBase |
| 820 | prebuilt android.Prebuilt |
| 821 | |
| 822 | properties sdkLibraryImportProperties |
| 823 | |
| 824 | stubsPath android.Paths |
| 825 | } |
| 826 | |
| 827 | var _ SdkLibraryDependency = (*sdkLibraryImport)(nil) |
| 828 | |
Jaewoong Jung | 4f158ee | 2019-07-11 10:05:35 -0700 | [diff] [blame] | 829 | // java_sdk_library_import imports a prebuilt java_sdk_library. |
Colin Cross | 79c7c26 | 2019-04-17 11:11:46 -0700 | [diff] [blame] | 830 | func sdkLibraryImportFactory() android.Module { |
| 831 | module := &sdkLibraryImport{} |
| 832 | |
| 833 | module.AddProperties(&module.properties) |
| 834 | |
| 835 | android.InitPrebuiltModule(module, &module.properties.Jars) |
| 836 | InitJavaModule(module, android.HostAndDeviceSupported) |
| 837 | |
| 838 | android.AddLoadHook(module, func(mctx android.LoadHookContext) { module.createInternalModules(mctx) }) |
| 839 | return module |
| 840 | } |
| 841 | |
| 842 | func (module *sdkLibraryImport) Prebuilt() *android.Prebuilt { |
| 843 | return &module.prebuilt |
| 844 | } |
| 845 | |
| 846 | func (module *sdkLibraryImport) Name() string { |
| 847 | return module.prebuilt.Name(module.ModuleBase.Name()) |
| 848 | } |
| 849 | |
| 850 | func (module *sdkLibraryImport) createInternalModules(mctx android.LoadHookContext) { |
| 851 | // Creates a java import for the jar with ".stubs" suffix |
| 852 | props := struct { |
Sundong Ahn | 0d7dff4 | 2019-12-04 12:53:44 +0900 | [diff] [blame] | 853 | Name *string |
| 854 | Soc_specific *bool |
| 855 | Device_specific *bool |
| 856 | Product_specific *bool |
| 857 | System_ext_specific *bool |
Colin Cross | 79c7c26 | 2019-04-17 11:11:46 -0700 | [diff] [blame] | 858 | }{} |
| 859 | |
| 860 | props.Name = proptools.StringPtr(module.BaseModuleName() + sdkStubsLibrarySuffix) |
| 861 | |
| 862 | if module.SocSpecific() { |
| 863 | props.Soc_specific = proptools.BoolPtr(true) |
| 864 | } else if module.DeviceSpecific() { |
| 865 | props.Device_specific = proptools.BoolPtr(true) |
| 866 | } else if module.ProductSpecific() { |
| 867 | props.Product_specific = proptools.BoolPtr(true) |
Sundong Ahn | 0d7dff4 | 2019-12-04 12:53:44 +0900 | [diff] [blame] | 868 | } else if module.SystemExtSpecific() { |
| 869 | props.System_ext_specific = proptools.BoolPtr(true) |
Colin Cross | 79c7c26 | 2019-04-17 11:11:46 -0700 | [diff] [blame] | 870 | } |
| 871 | |
Colin Cross | 84dfc3d | 2019-09-25 11:33:01 -0700 | [diff] [blame] | 872 | mctx.CreateModule(ImportFactory, &props, &module.properties) |
Colin Cross | 79c7c26 | 2019-04-17 11:11:46 -0700 | [diff] [blame] | 873 | |
| 874 | javaSdkLibraries := javaSdkLibraries(mctx.Config()) |
| 875 | javaSdkLibrariesLock.Lock() |
| 876 | defer javaSdkLibrariesLock.Unlock() |
| 877 | *javaSdkLibraries = append(*javaSdkLibraries, module.BaseModuleName()) |
| 878 | } |
| 879 | |
| 880 | func (module *sdkLibraryImport) DepsMutator(ctx android.BottomUpMutatorContext) { |
| 881 | // Add dependencies to the prebuilt stubs library |
| 882 | ctx.AddVariationDependencies(nil, publicApiStubsTag, module.BaseModuleName()+sdkStubsLibrarySuffix) |
| 883 | } |
| 884 | |
| 885 | func (module *sdkLibraryImport) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
| 886 | // Record the paths to the prebuilt stubs library. |
| 887 | ctx.VisitDirectDeps(func(to android.Module) { |
| 888 | tag := ctx.OtherModuleDependencyTag(to) |
| 889 | |
| 890 | switch tag { |
| 891 | case publicApiStubsTag: |
| 892 | module.stubsPath = to.(Dependency).HeaderJars() |
| 893 | } |
| 894 | }) |
| 895 | } |
| 896 | |
| 897 | // to satisfy SdkLibraryDependency interface |
Colin Cross | 0ea8ba8 | 2019-06-06 14:33:29 -0700 | [diff] [blame] | 898 | func (module *sdkLibraryImport) SdkHeaderJars(ctx android.BaseModuleContext, sdkVersion string) android.Paths { |
Colin Cross | 79c7c26 | 2019-04-17 11:11:46 -0700 | [diff] [blame] | 899 | // This module is just a wrapper for the prebuilt stubs. |
| 900 | return module.stubsPath |
| 901 | } |
| 902 | |
| 903 | // to satisfy SdkLibraryDependency interface |
Colin Cross | 0ea8ba8 | 2019-06-06 14:33:29 -0700 | [diff] [blame] | 904 | func (module *sdkLibraryImport) SdkImplementationJars(ctx android.BaseModuleContext, sdkVersion string) android.Paths { |
Colin Cross | 79c7c26 | 2019-04-17 11:11:46 -0700 | [diff] [blame] | 905 | // This module is just a wrapper for the stubs. |
| 906 | return module.stubsPath |
| 907 | } |