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. |
Paul Duffin | 12ceb46 | 2019-12-24 20:31:31 +0000 | [diff] [blame^] | 361 | func (module *SdkLibrary) sdkVersionForScope(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 | |
Paul Duffin | 12ceb46 | 2019-12-24 20:31:31 +0000 | [diff] [blame^] | 374 | // Get the sdk version for use when compiling the stubs library. |
| 375 | func (module *SdkLibrary) sdkVersionForStubsLibrary(mctx android.BaseModuleContext, apiScope apiScope) string { |
| 376 | sdkDep := decodeSdkDep(mctx, sdkContext(&module.Library)) |
| 377 | if sdkDep.hasStandardLibs() { |
| 378 | // If building against a standard sdk then use the sdk version appropriate for the scope. |
| 379 | return module.sdkVersionForScope(apiScope) |
| 380 | } else { |
| 381 | // Otherwise, use no system module. |
| 382 | return "none" |
| 383 | } |
| 384 | } |
| 385 | |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 386 | // $(INTERNAL_PLATFORM_<apiTagName>_API_FILE) points to the generated |
| 387 | // api file for the current source |
| 388 | // TODO: remove this when apicheck is done in soong |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 389 | func (module *SdkLibrary) apiTagName(apiScope apiScope) string { |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 390 | apiTagName := strings.Replace(strings.ToUpper(module.BaseModuleName()), ".", "_", -1) |
Jiyong Park | df13054 | 2018-04-27 16:29:21 +0900 | [diff] [blame] | 391 | switch apiScope { |
| 392 | case apiScopeSystem: |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 393 | apiTagName = apiTagName + "_SYSTEM" |
Jiyong Park | df13054 | 2018-04-27 16:29:21 +0900 | [diff] [blame] | 394 | case apiScopeTest: |
| 395 | apiTagName = apiTagName + "_TEST" |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 396 | } |
| 397 | return apiTagName |
| 398 | } |
| 399 | |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 400 | func (module *SdkLibrary) latestApiFilegroupName(apiScope apiScope) string { |
Jiyong Park | 58c518b | 2018-05-12 22:29:12 +0900 | [diff] [blame] | 401 | name := ":" + module.BaseModuleName() + ".api." |
Jiyong Park | df13054 | 2018-04-27 16:29:21 +0900 | [diff] [blame] | 402 | switch apiScope { |
Jiyong Park | 58c518b | 2018-05-12 22:29:12 +0900 | [diff] [blame] | 403 | case apiScopePublic: |
| 404 | name = name + "public" |
Jiyong Park | df13054 | 2018-04-27 16:29:21 +0900 | [diff] [blame] | 405 | case apiScopeSystem: |
Jiyong Park | 58c518b | 2018-05-12 22:29:12 +0900 | [diff] [blame] | 406 | name = name + "system" |
Jiyong Park | df13054 | 2018-04-27 16:29:21 +0900 | [diff] [blame] | 407 | case apiScopeTest: |
Jiyong Park | 58c518b | 2018-05-12 22:29:12 +0900 | [diff] [blame] | 408 | name = name + "test" |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 409 | } |
Jiyong Park | 58c518b | 2018-05-12 22:29:12 +0900 | [diff] [blame] | 410 | name = name + ".latest" |
| 411 | return name |
| 412 | } |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 413 | |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 414 | func (module *SdkLibrary) latestRemovedApiFilegroupName(apiScope apiScope) string { |
Jiyong Park | 58c518b | 2018-05-12 22:29:12 +0900 | [diff] [blame] | 415 | name := ":" + module.BaseModuleName() + "-removed.api." |
| 416 | switch apiScope { |
| 417 | case apiScopePublic: |
| 418 | name = name + "public" |
| 419 | case apiScopeSystem: |
| 420 | name = name + "system" |
| 421 | case apiScopeTest: |
| 422 | name = name + "test" |
| 423 | } |
| 424 | name = name + ".latest" |
| 425 | return name |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 426 | } |
| 427 | |
| 428 | // Creates a static java library that has API stubs |
Colin Cross | f8b860a | 2019-04-16 14:43:28 -0700 | [diff] [blame] | 429 | func (module *SdkLibrary) createStubsLibrary(mctx android.LoadHookContext, apiScope apiScope) { |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 430 | props := struct { |
Sundong Ahn | 0d7dff4 | 2019-12-04 12:53:44 +0900 | [diff] [blame] | 431 | Name *string |
| 432 | Srcs []string |
| 433 | Sdk_version *string |
Paul Duffin | 12ceb46 | 2019-12-24 20:31:31 +0000 | [diff] [blame^] | 434 | System_modules *string |
Sundong Ahn | 0d7dff4 | 2019-12-04 12:53:44 +0900 | [diff] [blame] | 435 | Libs []string |
| 436 | Soc_specific *bool |
| 437 | Device_specific *bool |
| 438 | Product_specific *bool |
| 439 | System_ext_specific *bool |
| 440 | Compile_dex *bool |
Sundong Ahn | 0d7dff4 | 2019-12-04 12:53:44 +0900 | [diff] [blame] | 441 | Java_version *string |
| 442 | Product_variables struct { |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 443 | Unbundled_build struct { |
| 444 | Enabled *bool |
| 445 | } |
Jiyong Park | 82484c0 | 2018-04-23 21:41:26 +0900 | [diff] [blame] | 446 | Pdk struct { |
| 447 | Enabled *bool |
| 448 | } |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 449 | } |
Sundong Ahn | 054b19a | 2018-10-19 13:46:09 +0900 | [diff] [blame] | 450 | Openjdk9 struct { |
| 451 | Srcs []string |
| 452 | Javacflags []string |
| 453 | } |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 454 | }{} |
| 455 | |
Jiyong Park | df13054 | 2018-04-27 16:29:21 +0900 | [diff] [blame] | 456 | props.Name = proptools.StringPtr(module.stubsName(apiScope)) |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 457 | // sources are generated from the droiddoc |
Jiyong Park | df13054 | 2018-04-27 16:29:21 +0900 | [diff] [blame] | 458 | props.Srcs = []string{":" + module.docsName(apiScope)} |
Paul Duffin | 12ceb46 | 2019-12-24 20:31:31 +0000 | [diff] [blame^] | 459 | sdkVersion := module.sdkVersionForStubsLibrary(mctx, apiScope) |
Paul Duffin | 52d398a | 2019-06-11 12:31:14 +0100 | [diff] [blame] | 460 | props.Sdk_version = proptools.StringPtr(sdkVersion) |
Paul Duffin | 12ceb46 | 2019-12-24 20:31:31 +0000 | [diff] [blame^] | 461 | props.System_modules = module.Library.Module.deviceProperties.System_modules |
Sundong Ahn | 054b19a | 2018-10-19 13:46:09 +0900 | [diff] [blame] | 462 | props.Libs = module.sdkLibraryProperties.Stub_only_libs |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 463 | // Unbundled apps will use the prebult one from /prebuilts/sdk |
Colin Cross | 1093287 | 2019-04-18 14:27:12 -0700 | [diff] [blame] | 464 | if mctx.Config().UnbundledBuildUsePrebuiltSdks() { |
Colin Cross | 2c77ceb | 2019-01-21 11:56:21 -0800 | [diff] [blame] | 465 | props.Product_variables.Unbundled_build.Enabled = proptools.BoolPtr(false) |
| 466 | } |
Jiyong Park | 82484c0 | 2018-04-23 21:41:26 +0900 | [diff] [blame] | 467 | props.Product_variables.Pdk.Enabled = proptools.BoolPtr(false) |
Sundong Ahn | 054b19a | 2018-10-19 13:46:09 +0900 | [diff] [blame] | 468 | props.Openjdk9.Srcs = module.Library.Module.properties.Openjdk9.Srcs |
| 469 | props.Openjdk9.Javacflags = module.Library.Module.properties.Openjdk9.Javacflags |
| 470 | props.Java_version = module.Library.Module.properties.Java_version |
| 471 | if module.Library.Module.deviceProperties.Compile_dex != nil { |
| 472 | props.Compile_dex = module.Library.Module.deviceProperties.Compile_dex |
Sundong Ahn | dd567f9 | 2018-07-31 17:19:11 +0900 | [diff] [blame] | 473 | } |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 474 | |
| 475 | if module.SocSpecific() { |
| 476 | props.Soc_specific = proptools.BoolPtr(true) |
| 477 | } else if module.DeviceSpecific() { |
| 478 | props.Device_specific = proptools.BoolPtr(true) |
| 479 | } else if module.ProductSpecific() { |
| 480 | props.Product_specific = proptools.BoolPtr(true) |
Sundong Ahn | 0d7dff4 | 2019-12-04 12:53:44 +0900 | [diff] [blame] | 481 | } else if module.SystemExtSpecific() { |
| 482 | props.System_ext_specific = proptools.BoolPtr(true) |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 483 | } |
| 484 | |
Colin Cross | 84dfc3d | 2019-09-25 11:33:01 -0700 | [diff] [blame] | 485 | mctx.CreateModule(LibraryFactory, &props) |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 486 | } |
| 487 | |
| 488 | // Creates a droiddoc module that creates stubs source files from the given full source |
| 489 | // files |
Paul Duffin | c4cea76 | 2019-12-30 17:32:47 +0000 | [diff] [blame] | 490 | func (module *SdkLibrary) createStubsSources(mctx android.LoadHookContext, apiScope apiScope) { |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 491 | props := struct { |
Sundong Ahn | 054b19a | 2018-10-19 13:46:09 +0900 | [diff] [blame] | 492 | Name *string |
| 493 | Srcs []string |
| 494 | Installable *bool |
Paul Duffin | 52d398a | 2019-06-11 12:31:14 +0100 | [diff] [blame] | 495 | Sdk_version *string |
Paul Duffin | 12ceb46 | 2019-12-24 20:31:31 +0000 | [diff] [blame^] | 496 | System_modules *string |
Sundong Ahn | 054b19a | 2018-10-19 13:46:09 +0900 | [diff] [blame] | 497 | Libs []string |
Paul Duffin | 1151247 | 2019-02-11 15:55:17 +0000 | [diff] [blame] | 498 | Arg_files []string |
Sundong Ahn | 054b19a | 2018-10-19 13:46:09 +0900 | [diff] [blame] | 499 | Args *string |
| 500 | Api_tag_name *string |
| 501 | Api_filename *string |
| 502 | Removed_api_filename *string |
Sundong Ahn | 054b19a | 2018-10-19 13:46:09 +0900 | [diff] [blame] | 503 | Java_version *string |
| 504 | Merge_annotations_dirs []string |
| 505 | Merge_inclusion_annotations_dirs []string |
| 506 | Check_api struct { |
Inseob Kim | 38449af | 2019-02-28 14:24:05 +0900 | [diff] [blame] | 507 | Current ApiToCheck |
| 508 | Last_released ApiToCheck |
| 509 | Ignore_missing_latest_api *bool |
Jiyong Park | 58c518b | 2018-05-12 22:29:12 +0900 | [diff] [blame] | 510 | } |
Sundong Ahn | 1b92c82 | 2018-05-29 11:35:17 +0900 | [diff] [blame] | 511 | Aidl struct { |
| 512 | Include_dirs []string |
| 513 | Local_include_dirs []string |
| 514 | } |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 515 | }{} |
| 516 | |
Paul Duffin | 250e619 | 2019-06-07 10:44:37 +0100 | [diff] [blame] | 517 | sdkDep := decodeSdkDep(mctx, sdkContext(&module.Library)) |
Paul Duffin | 12ceb46 | 2019-12-24 20:31:31 +0000 | [diff] [blame^] | 518 | // Use the platform API if standard libraries were requested, otherwise use |
| 519 | // no default libraries. |
Paul Duffin | 52d398a | 2019-06-11 12:31:14 +0100 | [diff] [blame] | 520 | sdkVersion := "" |
| 521 | if !sdkDep.hasStandardLibs() { |
| 522 | sdkVersion = "none" |
| 523 | } |
Paul Duffin | 250e619 | 2019-06-07 10:44:37 +0100 | [diff] [blame] | 524 | |
Jiyong Park | df13054 | 2018-04-27 16:29:21 +0900 | [diff] [blame] | 525 | props.Name = proptools.StringPtr(module.docsName(apiScope)) |
Sundong Ahn | 054b19a | 2018-10-19 13:46:09 +0900 | [diff] [blame] | 526 | props.Srcs = append(props.Srcs, module.Library.Module.properties.Srcs...) |
Paul Duffin | 52d398a | 2019-06-11 12:31:14 +0100 | [diff] [blame] | 527 | props.Sdk_version = proptools.StringPtr(sdkVersion) |
Paul Duffin | 12ceb46 | 2019-12-24 20:31:31 +0000 | [diff] [blame^] | 528 | props.System_modules = module.Library.Module.deviceProperties.System_modules |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 529 | props.Installable = proptools.BoolPtr(false) |
Sundong Ahn | e6f0b05 | 2018-06-05 16:46:14 +0900 | [diff] [blame] | 530 | // A droiddoc module has only one Libs property and doesn't distinguish between |
| 531 | // 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] | 532 | props.Libs = module.Library.Module.properties.Libs |
| 533 | props.Libs = append(props.Libs, module.Library.Module.properties.Static_libs...) |
| 534 | props.Aidl.Include_dirs = module.Library.Module.deviceProperties.Aidl.Include_dirs |
| 535 | 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] | 536 | props.Java_version = module.Library.Module.properties.Java_version |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 537 | |
Sundong Ahn | 054b19a | 2018-10-19 13:46:09 +0900 | [diff] [blame] | 538 | props.Merge_annotations_dirs = module.sdkLibraryProperties.Merge_annotations_dirs |
| 539 | props.Merge_inclusion_annotations_dirs = module.sdkLibraryProperties.Merge_inclusion_annotations_dirs |
| 540 | |
Paul Duffin | 235ffff | 2019-12-24 10:41:30 +0000 | [diff] [blame] | 541 | droiddocArgs := []string{} |
| 542 | if len(module.sdkLibraryProperties.Api_packages) != 0 { |
| 543 | droiddocArgs = append(droiddocArgs, "--stub-packages "+strings.Join(module.sdkLibraryProperties.Api_packages, ":")) |
| 544 | } |
| 545 | if len(module.sdkLibraryProperties.Hidden_api_packages) != 0 { |
| 546 | droiddocArgs = append(droiddocArgs, |
| 547 | android.JoinWithPrefix(module.sdkLibraryProperties.Hidden_api_packages, " --hide-package ")) |
| 548 | } |
| 549 | droiddocArgs = append(droiddocArgs, module.sdkLibraryProperties.Droiddoc_options...) |
| 550 | disabledWarnings := []string{ |
| 551 | "MissingPermission", |
| 552 | "BroadcastBehavior", |
| 553 | "HiddenSuperclass", |
| 554 | "DeprecationMismatch", |
| 555 | "UnavailableSymbol", |
| 556 | "SdkConstant", |
| 557 | "HiddenTypeParameter", |
| 558 | "Todo", |
| 559 | "Typo", |
| 560 | } |
| 561 | droiddocArgs = append(droiddocArgs, android.JoinWithPrefix(disabledWarnings, "--hide ")) |
Sundong Ahn | fb2721f | 2018-09-17 13:23:09 +0900 | [diff] [blame] | 562 | |
Jiyong Park | df13054 | 2018-04-27 16:29:21 +0900 | [diff] [blame] | 563 | switch apiScope { |
| 564 | case apiScopeSystem: |
Paul Duffin | 235ffff | 2019-12-24 10:41:30 +0000 | [diff] [blame] | 565 | droiddocArgs = append(droiddocArgs, "-showAnnotation android.annotation.SystemApi") |
Jiyong Park | df13054 | 2018-04-27 16:29:21 +0900 | [diff] [blame] | 566 | case apiScopeTest: |
Paul Duffin | 235ffff | 2019-12-24 10:41:30 +0000 | [diff] [blame] | 567 | droiddocArgs = append(droiddocArgs, " -showAnnotation android.annotation.TestApi") |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 568 | } |
Paul Duffin | 1151247 | 2019-02-11 15:55:17 +0000 | [diff] [blame] | 569 | props.Arg_files = module.sdkLibraryProperties.Droiddoc_option_files |
Paul Duffin | 235ffff | 2019-12-24 10:41:30 +0000 | [diff] [blame] | 570 | props.Args = proptools.StringPtr(strings.Join(droiddocArgs, " ")) |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 571 | |
| 572 | // List of APIs identified from the provided source files are created. They are later |
| 573 | // compared against to the not-yet-released (a.k.a current) list of APIs and to the |
| 574 | // last-released (a.k.a numbered) list of API. |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 575 | currentApiFileName := "current.txt" |
| 576 | removedApiFileName := "removed.txt" |
Jiyong Park | df13054 | 2018-04-27 16:29:21 +0900 | [diff] [blame] | 577 | switch apiScope { |
| 578 | case apiScopeSystem: |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 579 | currentApiFileName = "system-" + currentApiFileName |
| 580 | removedApiFileName = "system-" + removedApiFileName |
Jiyong Park | df13054 | 2018-04-27 16:29:21 +0900 | [diff] [blame] | 581 | case apiScopeTest: |
| 582 | currentApiFileName = "test-" + currentApiFileName |
| 583 | removedApiFileName = "test-" + removedApiFileName |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 584 | } |
| 585 | currentApiFileName = path.Join("api", currentApiFileName) |
| 586 | removedApiFileName = path.Join("api", removedApiFileName) |
Jiyong Park | 58c518b | 2018-05-12 22:29:12 +0900 | [diff] [blame] | 587 | // TODO(jiyong): remove these three props |
Jiyong Park | df13054 | 2018-04-27 16:29:21 +0900 | [diff] [blame] | 588 | props.Api_tag_name = proptools.StringPtr(module.apiTagName(apiScope)) |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 589 | props.Api_filename = proptools.StringPtr(currentApiFileName) |
| 590 | props.Removed_api_filename = proptools.StringPtr(removedApiFileName) |
| 591 | |
Jiyong Park | 58c518b | 2018-05-12 22:29:12 +0900 | [diff] [blame] | 592 | // check against the not-yet-release API |
| 593 | props.Check_api.Current.Api_file = proptools.StringPtr(currentApiFileName) |
| 594 | props.Check_api.Current.Removed_api_file = proptools.StringPtr(removedApiFileName) |
Jiyong Park | 58c518b | 2018-05-12 22:29:12 +0900 | [diff] [blame] | 595 | |
| 596 | // check against the latest released API |
| 597 | props.Check_api.Last_released.Api_file = proptools.StringPtr( |
| 598 | module.latestApiFilegroupName(apiScope)) |
| 599 | props.Check_api.Last_released.Removed_api_file = proptools.StringPtr( |
| 600 | module.latestRemovedApiFilegroupName(apiScope)) |
Inseob Kim | 38449af | 2019-02-28 14:24:05 +0900 | [diff] [blame] | 601 | props.Check_api.Ignore_missing_latest_api = proptools.BoolPtr(true) |
Jiyong Park | 58c518b | 2018-05-12 22:29:12 +0900 | [diff] [blame] | 602 | |
Colin Cross | 84dfc3d | 2019-09-25 11:33:01 -0700 | [diff] [blame] | 603 | mctx.CreateModule(DroidstubsFactory, &props) |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 604 | } |
| 605 | |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 606 | // Creates the xml file that publicizes the runtime library |
Colin Cross | f8b860a | 2019-04-16 14:43:28 -0700 | [diff] [blame] | 607 | func (module *SdkLibrary) createXmlFile(mctx android.LoadHookContext) { |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 608 | // creates a prebuilt_etc module to actually place the xml file under |
| 609 | // <partition>/etc/permissions |
| 610 | etcProps := struct { |
Sundong Ahn | 0d7dff4 | 2019-12-04 12:53:44 +0900 | [diff] [blame] | 611 | Name *string |
| 612 | Src *string |
| 613 | Sub_dir *string |
| 614 | Soc_specific *bool |
| 615 | Device_specific *bool |
| 616 | Product_specific *bool |
| 617 | System_ext_specific *bool |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 618 | }{} |
| 619 | etcProps.Name = proptools.StringPtr(module.xmlFileName()) |
Jooyung Han | 624058e | 2019-12-24 18:38:06 +0900 | [diff] [blame] | 620 | etcProps.Src = proptools.StringPtr(":" + module.BaseModuleName() + "{.xml}") |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 621 | etcProps.Sub_dir = proptools.StringPtr("permissions") |
| 622 | if module.SocSpecific() { |
| 623 | etcProps.Soc_specific = proptools.BoolPtr(true) |
| 624 | } else if module.DeviceSpecific() { |
| 625 | etcProps.Device_specific = proptools.BoolPtr(true) |
| 626 | } else if module.ProductSpecific() { |
| 627 | etcProps.Product_specific = proptools.BoolPtr(true) |
Sundong Ahn | 0d7dff4 | 2019-12-04 12:53:44 +0900 | [diff] [blame] | 628 | } else if module.SystemExtSpecific() { |
| 629 | etcProps.System_ext_specific = proptools.BoolPtr(true) |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 630 | } |
Colin Cross | 84dfc3d | 2019-09-25 11:33:01 -0700 | [diff] [blame] | 631 | mctx.CreateModule(android.PrebuiltEtcFactory, &etcProps) |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 632 | } |
| 633 | |
Colin Cross | 0ea8ba8 | 2019-06-06 14:33:29 -0700 | [diff] [blame] | 634 | func (module *SdkLibrary) PrebuiltJars(ctx android.BaseModuleContext, sdkVersion string) android.Paths { |
Sundong Ahn | 054b19a | 2018-10-19 13:46:09 +0900 | [diff] [blame] | 635 | var api, v string |
Paul Duffin | 52d398a | 2019-06-11 12:31:14 +0100 | [diff] [blame] | 636 | if sdkVersion == "" || sdkVersion == "none" { |
Sundong Ahn | 054b19a | 2018-10-19 13:46:09 +0900 | [diff] [blame] | 637 | api = "system" |
| 638 | v = "current" |
| 639 | } else if strings.Contains(sdkVersion, "_") { |
| 640 | t := strings.Split(sdkVersion, "_") |
| 641 | api = t[0] |
| 642 | v = t[1] |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 643 | } else { |
Sundong Ahn | 054b19a | 2018-10-19 13:46:09 +0900 | [diff] [blame] | 644 | api = "public" |
| 645 | v = sdkVersion |
| 646 | } |
| 647 | dir := filepath.Join("prebuilts", "sdk", v, api) |
| 648 | jar := filepath.Join(dir, module.BaseModuleName()+".jar") |
| 649 | jarPath := android.ExistentPathForSource(ctx, jar) |
Sundong Ahn | ae418ac | 2019-02-28 15:01:28 +0900 | [diff] [blame] | 650 | if !jarPath.Valid() { |
| 651 | ctx.PropertyErrorf("sdk_library", "invalid sdk version %q, %q does not exist", v, jar) |
| 652 | return nil |
| 653 | } |
Sundong Ahn | 054b19a | 2018-10-19 13:46:09 +0900 | [diff] [blame] | 654 | return android.Paths{jarPath.Path()} |
| 655 | } |
| 656 | |
| 657 | // to satisfy SdkLibraryDependency interface |
Colin Cross | 0ea8ba8 | 2019-06-06 14:33:29 -0700 | [diff] [blame] | 658 | func (module *SdkLibrary) SdkHeaderJars(ctx android.BaseModuleContext, sdkVersion string) android.Paths { |
Sundong Ahn | 054b19a | 2018-10-19 13:46:09 +0900 | [diff] [blame] | 659 | // This module is just a wrapper for the stubs. |
Colin Cross | 1093287 | 2019-04-18 14:27:12 -0700 | [diff] [blame] | 660 | if ctx.Config().UnbundledBuildUsePrebuiltSdks() { |
Sundong Ahn | 054b19a | 2018-10-19 13:46:09 +0900 | [diff] [blame] | 661 | return module.PrebuiltJars(ctx, sdkVersion) |
| 662 | } else { |
| 663 | if strings.HasPrefix(sdkVersion, "system_") { |
| 664 | return module.systemApiStubsPath |
| 665 | } else if sdkVersion == "" { |
| 666 | return module.Library.HeaderJars() |
| 667 | } else { |
| 668 | return module.publicApiStubsPath |
| 669 | } |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 670 | } |
| 671 | } |
| 672 | |
Sundong Ahn | 241cd37 | 2018-07-13 16:16:44 +0900 | [diff] [blame] | 673 | // to satisfy SdkLibraryDependency interface |
Colin Cross | 0ea8ba8 | 2019-06-06 14:33:29 -0700 | [diff] [blame] | 674 | func (module *SdkLibrary) SdkImplementationJars(ctx android.BaseModuleContext, sdkVersion string) android.Paths { |
Sundong Ahn | 241cd37 | 2018-07-13 16:16:44 +0900 | [diff] [blame] | 675 | // This module is just a wrapper for the stubs. |
Colin Cross | 1093287 | 2019-04-18 14:27:12 -0700 | [diff] [blame] | 676 | if ctx.Config().UnbundledBuildUsePrebuiltSdks() { |
Sundong Ahn | 054b19a | 2018-10-19 13:46:09 +0900 | [diff] [blame] | 677 | return module.PrebuiltJars(ctx, sdkVersion) |
Sundong Ahn | 241cd37 | 2018-07-13 16:16:44 +0900 | [diff] [blame] | 678 | } else { |
Sundong Ahn | 054b19a | 2018-10-19 13:46:09 +0900 | [diff] [blame] | 679 | if strings.HasPrefix(sdkVersion, "system_") { |
| 680 | return module.systemApiStubsImplPath |
| 681 | } else if sdkVersion == "" { |
| 682 | return module.Library.ImplementationJars() |
| 683 | } else { |
| 684 | return module.publicApiStubsImplPath |
| 685 | } |
Sundong Ahn | 241cd37 | 2018-07-13 16:16:44 +0900 | [diff] [blame] | 686 | } |
| 687 | } |
| 688 | |
Sundong Ahn | 80a87b3 | 2019-05-13 15:02:50 +0900 | [diff] [blame] | 689 | func (module *SdkLibrary) SetNoDist() { |
| 690 | module.sdkLibraryProperties.No_dist = proptools.BoolPtr(true) |
| 691 | } |
| 692 | |
Colin Cross | 571cccf | 2019-02-04 11:22:08 -0800 | [diff] [blame] | 693 | var javaSdkLibrariesKey = android.NewOnceKey("javaSdkLibraries") |
| 694 | |
Jiyong Park | 82484c0 | 2018-04-23 21:41:26 +0900 | [diff] [blame] | 695 | func javaSdkLibraries(config android.Config) *[]string { |
Colin Cross | 571cccf | 2019-02-04 11:22:08 -0800 | [diff] [blame] | 696 | return config.Once(javaSdkLibrariesKey, func() interface{} { |
Jiyong Park | 82484c0 | 2018-04-23 21:41:26 +0900 | [diff] [blame] | 697 | return &[]string{} |
| 698 | }).(*[]string) |
| 699 | } |
| 700 | |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 701 | // For a java_sdk_library module, create internal modules for stubs, docs, |
| 702 | // runtime libs and xml file. If requested, the stubs and docs are created twice |
| 703 | // once for public API level and once for system API level |
Colin Cross | f8b860a | 2019-04-16 14:43:28 -0700 | [diff] [blame] | 704 | func (module *SdkLibrary) CreateInternalModules(mctx android.LoadHookContext) { |
Inseob Kim | 6e93ac9 | 2019-03-21 17:43:49 +0900 | [diff] [blame] | 705 | if len(module.Library.Module.properties.Srcs) == 0 { |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 706 | mctx.PropertyErrorf("srcs", "java_sdk_library must specify srcs") |
Jooyung Han | 58f26ab | 2019-12-18 15:34:32 +0900 | [diff] [blame] | 707 | return |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 708 | } |
| 709 | |
Inseob Kim | 6e93ac9 | 2019-03-21 17:43:49 +0900 | [diff] [blame] | 710 | if len(module.sdkLibraryProperties.Api_packages) == 0 { |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 711 | mctx.PropertyErrorf("api_packages", "java_sdk_library must specify api_packages") |
Jooyung Han | 58f26ab | 2019-12-18 15:34:32 +0900 | [diff] [blame] | 712 | return |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 713 | } |
Inseob Kim | 8098faa | 2019-03-18 10:19:51 +0900 | [diff] [blame] | 714 | |
Paul Duffin | 37e0b77 | 2019-12-30 17:20:10 +0000 | [diff] [blame] | 715 | // If this builds against standard libraries (i.e. is not part of the core libraries) |
| 716 | // then assume it provides both system and test apis. Otherwise, assume it does not and |
| 717 | // also assume it does not contribute to the dist build. |
| 718 | sdkDep := decodeSdkDep(mctx, sdkContext(&module.Library)) |
| 719 | hasSystemAndTestApis := sdkDep.hasStandardLibs() |
| 720 | module.sdkLibraryProperties.Has_system_and_test_apis = hasSystemAndTestApis |
| 721 | module.sdkLibraryProperties.No_dist = proptools.BoolPtr(!hasSystemAndTestApis) |
| 722 | |
| 723 | scopes := []string{""} |
| 724 | if hasSystemAndTestApis { |
| 725 | scopes = append(scopes, "system-", "test-") |
| 726 | } |
| 727 | |
Inseob Kim | 8098faa | 2019-03-18 10:19:51 +0900 | [diff] [blame] | 728 | missing_current_api := false |
| 729 | |
Paul Duffin | 37e0b77 | 2019-12-30 17:20:10 +0000 | [diff] [blame] | 730 | for _, scope := range scopes { |
Inseob Kim | 8098faa | 2019-03-18 10:19:51 +0900 | [diff] [blame] | 731 | for _, api := range []string{"current.txt", "removed.txt"} { |
| 732 | path := path.Join(mctx.ModuleDir(), "api", scope+api) |
| 733 | p := android.ExistentPathForSource(mctx, path) |
| 734 | if !p.Valid() { |
| 735 | mctx.ModuleErrorf("Current api file %#v doesn't exist", path) |
| 736 | missing_current_api = true |
| 737 | } |
| 738 | } |
| 739 | } |
| 740 | |
| 741 | if missing_current_api { |
| 742 | script := "build/soong/scripts/gen-java-current-api-files.sh" |
| 743 | p := android.ExistentPathForSource(mctx, script) |
| 744 | |
| 745 | if !p.Valid() { |
| 746 | panic(fmt.Sprintf("script file %s doesn't exist", script)) |
| 747 | } |
| 748 | |
| 749 | mctx.ModuleErrorf("One or more current api files are missing. "+ |
| 750 | "You can update them by:\n"+ |
Paul Duffin | 37e0b77 | 2019-12-30 17:20:10 +0000 | [diff] [blame] | 751 | "%s %q %s && m update-api", |
| 752 | script, mctx.ModuleDir(), strings.Join(scopes, " ")) |
Inseob Kim | 8098faa | 2019-03-18 10:19:51 +0900 | [diff] [blame] | 753 | return |
| 754 | } |
| 755 | |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 756 | // for public API stubs |
| 757 | module.createStubsLibrary(mctx, apiScopePublic) |
Paul Duffin | c4cea76 | 2019-12-30 17:32:47 +0000 | [diff] [blame] | 758 | module.createStubsSources(mctx, apiScopePublic) |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 759 | |
Paul Duffin | 37e0b77 | 2019-12-30 17:20:10 +0000 | [diff] [blame] | 760 | if hasSystemAndTestApis { |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 761 | // for system API stubs |
| 762 | module.createStubsLibrary(mctx, apiScopeSystem) |
Paul Duffin | c4cea76 | 2019-12-30 17:32:47 +0000 | [diff] [blame] | 763 | module.createStubsSources(mctx, apiScopeSystem) |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 764 | |
| 765 | // for test API stubs |
| 766 | module.createStubsLibrary(mctx, apiScopeTest) |
Paul Duffin | c4cea76 | 2019-12-30 17:32:47 +0000 | [diff] [blame] | 767 | module.createStubsSources(mctx, apiScopeTest) |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 768 | |
| 769 | // for runtime |
| 770 | module.createXmlFile(mctx) |
| 771 | } |
| 772 | |
| 773 | // record java_sdk_library modules so that they are exported to make |
| 774 | javaSdkLibraries := javaSdkLibraries(mctx.Config()) |
| 775 | javaSdkLibrariesLock.Lock() |
| 776 | defer javaSdkLibrariesLock.Unlock() |
| 777 | *javaSdkLibraries = append(*javaSdkLibraries, module.BaseModuleName()) |
| 778 | } |
| 779 | |
| 780 | func (module *SdkLibrary) InitSdkLibraryProperties() { |
Sundong Ahn | 054b19a | 2018-10-19 13:46:09 +0900 | [diff] [blame] | 781 | module.AddProperties( |
| 782 | &module.sdkLibraryProperties, |
| 783 | &module.Library.Module.properties, |
| 784 | &module.Library.Module.dexpreoptProperties, |
| 785 | &module.Library.Module.deviceProperties, |
| 786 | &module.Library.Module.protoProperties, |
| 787 | ) |
| 788 | |
| 789 | module.Library.Module.properties.Installable = proptools.BoolPtr(true) |
| 790 | module.Library.Module.deviceProperties.IsSDKLibrary = true |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 791 | } |
Sundong Ahn | 054b19a | 2018-10-19 13:46:09 +0900 | [diff] [blame] | 792 | |
Jaewoong Jung | 4f158ee | 2019-07-11 10:05:35 -0700 | [diff] [blame] | 793 | // java_sdk_library is a special Java library that provides optional platform APIs to apps. |
| 794 | // In practice, it can be viewed as a combination of several modules: 1) stubs library that clients |
| 795 | // are linked against to, 2) droiddoc module that internally generates API stubs source files, |
| 796 | // 3) the real runtime shared library that implements the APIs, and 4) XML file for adding |
| 797 | // 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] | 798 | func SdkLibraryFactory() android.Module { |
| 799 | module := &SdkLibrary{} |
| 800 | module.InitSdkLibraryProperties() |
Jooyung Han | 58f26ab | 2019-12-18 15:34:32 +0900 | [diff] [blame] | 801 | android.InitApexModule(module) |
Sundong Ahn | 054b19a | 2018-10-19 13:46:09 +0900 | [diff] [blame] | 802 | InitJavaModule(module, android.HostAndDeviceSupported) |
Colin Cross | f8b860a | 2019-04-16 14:43:28 -0700 | [diff] [blame] | 803 | android.AddLoadHook(module, func(ctx android.LoadHookContext) { module.CreateInternalModules(ctx) }) |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 804 | return module |
| 805 | } |
Colin Cross | 79c7c26 | 2019-04-17 11:11:46 -0700 | [diff] [blame] | 806 | |
| 807 | // |
| 808 | // SDK library prebuilts |
| 809 | // |
| 810 | |
| 811 | type sdkLibraryImportProperties struct { |
| 812 | Jars []string `android:"path"` |
| 813 | |
| 814 | Sdk_version *string |
| 815 | |
| 816 | Installable *bool |
| 817 | |
| 818 | // List of shared java libs that this module has dependencies to |
| 819 | Libs []string |
| 820 | |
| 821 | // List of files to remove from the jar file(s) |
| 822 | Exclude_files []string |
| 823 | |
| 824 | // List of directories to remove from the jar file(s) |
| 825 | Exclude_dirs []string |
| 826 | } |
| 827 | |
| 828 | type sdkLibraryImport struct { |
| 829 | android.ModuleBase |
| 830 | android.DefaultableModuleBase |
| 831 | prebuilt android.Prebuilt |
| 832 | |
| 833 | properties sdkLibraryImportProperties |
| 834 | |
| 835 | stubsPath android.Paths |
| 836 | } |
| 837 | |
| 838 | var _ SdkLibraryDependency = (*sdkLibraryImport)(nil) |
| 839 | |
Jaewoong Jung | 4f158ee | 2019-07-11 10:05:35 -0700 | [diff] [blame] | 840 | // java_sdk_library_import imports a prebuilt java_sdk_library. |
Colin Cross | 79c7c26 | 2019-04-17 11:11:46 -0700 | [diff] [blame] | 841 | func sdkLibraryImportFactory() android.Module { |
| 842 | module := &sdkLibraryImport{} |
| 843 | |
| 844 | module.AddProperties(&module.properties) |
| 845 | |
| 846 | android.InitPrebuiltModule(module, &module.properties.Jars) |
| 847 | InitJavaModule(module, android.HostAndDeviceSupported) |
| 848 | |
| 849 | android.AddLoadHook(module, func(mctx android.LoadHookContext) { module.createInternalModules(mctx) }) |
| 850 | return module |
| 851 | } |
| 852 | |
| 853 | func (module *sdkLibraryImport) Prebuilt() *android.Prebuilt { |
| 854 | return &module.prebuilt |
| 855 | } |
| 856 | |
| 857 | func (module *sdkLibraryImport) Name() string { |
| 858 | return module.prebuilt.Name(module.ModuleBase.Name()) |
| 859 | } |
| 860 | |
| 861 | func (module *sdkLibraryImport) createInternalModules(mctx android.LoadHookContext) { |
| 862 | // Creates a java import for the jar with ".stubs" suffix |
| 863 | props := struct { |
Sundong Ahn | 0d7dff4 | 2019-12-04 12:53:44 +0900 | [diff] [blame] | 864 | Name *string |
| 865 | Soc_specific *bool |
| 866 | Device_specific *bool |
| 867 | Product_specific *bool |
| 868 | System_ext_specific *bool |
Colin Cross | 79c7c26 | 2019-04-17 11:11:46 -0700 | [diff] [blame] | 869 | }{} |
| 870 | |
| 871 | props.Name = proptools.StringPtr(module.BaseModuleName() + sdkStubsLibrarySuffix) |
| 872 | |
| 873 | if module.SocSpecific() { |
| 874 | props.Soc_specific = proptools.BoolPtr(true) |
| 875 | } else if module.DeviceSpecific() { |
| 876 | props.Device_specific = proptools.BoolPtr(true) |
| 877 | } else if module.ProductSpecific() { |
| 878 | props.Product_specific = proptools.BoolPtr(true) |
Sundong Ahn | 0d7dff4 | 2019-12-04 12:53:44 +0900 | [diff] [blame] | 879 | } else if module.SystemExtSpecific() { |
| 880 | props.System_ext_specific = proptools.BoolPtr(true) |
Colin Cross | 79c7c26 | 2019-04-17 11:11:46 -0700 | [diff] [blame] | 881 | } |
| 882 | |
Colin Cross | 84dfc3d | 2019-09-25 11:33:01 -0700 | [diff] [blame] | 883 | mctx.CreateModule(ImportFactory, &props, &module.properties) |
Colin Cross | 79c7c26 | 2019-04-17 11:11:46 -0700 | [diff] [blame] | 884 | |
| 885 | javaSdkLibraries := javaSdkLibraries(mctx.Config()) |
| 886 | javaSdkLibrariesLock.Lock() |
| 887 | defer javaSdkLibrariesLock.Unlock() |
| 888 | *javaSdkLibraries = append(*javaSdkLibraries, module.BaseModuleName()) |
| 889 | } |
| 890 | |
| 891 | func (module *sdkLibraryImport) DepsMutator(ctx android.BottomUpMutatorContext) { |
| 892 | // Add dependencies to the prebuilt stubs library |
| 893 | ctx.AddVariationDependencies(nil, publicApiStubsTag, module.BaseModuleName()+sdkStubsLibrarySuffix) |
| 894 | } |
| 895 | |
| 896 | func (module *sdkLibraryImport) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
| 897 | // Record the paths to the prebuilt stubs library. |
| 898 | ctx.VisitDirectDeps(func(to android.Module) { |
| 899 | tag := ctx.OtherModuleDependencyTag(to) |
| 900 | |
| 901 | switch tag { |
| 902 | case publicApiStubsTag: |
| 903 | module.stubsPath = to.(Dependency).HeaderJars() |
| 904 | } |
| 905 | }) |
| 906 | } |
| 907 | |
| 908 | // to satisfy SdkLibraryDependency interface |
Colin Cross | 0ea8ba8 | 2019-06-06 14:33:29 -0700 | [diff] [blame] | 909 | func (module *sdkLibraryImport) SdkHeaderJars(ctx android.BaseModuleContext, sdkVersion string) android.Paths { |
Colin Cross | 79c7c26 | 2019-04-17 11:11:46 -0700 | [diff] [blame] | 910 | // This module is just a wrapper for the prebuilt stubs. |
| 911 | return module.stubsPath |
| 912 | } |
| 913 | |
| 914 | // to satisfy SdkLibraryDependency interface |
Colin Cross | 0ea8ba8 | 2019-06-06 14:33:29 -0700 | [diff] [blame] | 915 | func (module *sdkLibraryImport) SdkImplementationJars(ctx android.BaseModuleContext, sdkVersion string) android.Paths { |
Colin Cross | 79c7c26 | 2019-04-17 11:11:46 -0700 | [diff] [blame] | 916 | // This module is just a wrapper for the stubs. |
| 917 | return module.stubsPath |
| 918 | } |