Anton Hansson | 0860aaf | 2021-10-08 16:48:03 +0100 | [diff] [blame] | 1 | // Copyright (C) 2021 The Android Open Source Project |
| 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 api |
| 16 | |
| 17 | import ( |
Anton Hansson | 07a1295 | 2022-01-12 17:28:39 +0000 | [diff] [blame] | 18 | "sort" |
| 19 | |
Anton Hansson | 0860aaf | 2021-10-08 16:48:03 +0100 | [diff] [blame] | 20 | "github.com/google/blueprint/proptools" |
| 21 | |
| 22 | "android/soong/android" |
| 23 | "android/soong/genrule" |
Anton Hansson | cb00f94 | 2022-01-13 09:45:12 +0000 | [diff] [blame] | 24 | "android/soong/java" |
Anton Hansson | 0860aaf | 2021-10-08 16:48:03 +0100 | [diff] [blame] | 25 | ) |
| 26 | |
Anton Hansson | 05e944d | 2022-01-13 12:26:30 +0000 | [diff] [blame] | 27 | const art = "art.module.public.api" |
| 28 | const conscrypt = "conscrypt.module.public.api" |
| 29 | const i18n = "i18n.module.public.api" |
Nikita Ioffe | d3f0a6f | 2022-11-15 11:26:53 +0000 | [diff] [blame^] | 30 | const virtualization = "framework-virtualization" |
Anton Hansson | 09a9c4e | 2022-04-08 10:59:46 +0100 | [diff] [blame] | 31 | |
Anton Hansson | 95e89a8 | 2022-01-28 11:31:50 +0000 | [diff] [blame] | 32 | var core_libraries_modules = []string{art, conscrypt, i18n} |
Nikita Ioffe | d3f0a6f | 2022-11-15 11:26:53 +0000 | [diff] [blame^] | 33 | // List of modules that are not yet updatable, and hence they can still compile |
| 34 | // against hidden APIs. These modules are filtered out when building the |
| 35 | // updatable-framework-module-impl (because updatable-framework-module-impl is |
| 36 | // built against module_current SDK). Instead they are directly statically |
| 37 | // linked into the all-framework-module-lib, which is building against hidden |
| 38 | // APIs. |
| 39 | var non_updatable_modules = []string{virtualization} |
Anton Hansson | 05e944d | 2022-01-13 12:26:30 +0000 | [diff] [blame] | 40 | |
Anton Hansson | 0860aaf | 2021-10-08 16:48:03 +0100 | [diff] [blame] | 41 | // The intention behind this soong plugin is to generate a number of "merged" |
| 42 | // API-related modules that would otherwise require a large amount of very |
| 43 | // similar Android.bp boilerplate to define. For example, the merged current.txt |
| 44 | // API definitions (created by merging the non-updatable current.txt with all |
| 45 | // the module current.txts). This simplifies the addition of new android |
| 46 | // modules, by reducing the number of genrules etc a new module must be added to. |
| 47 | |
| 48 | // The properties of the combined_apis module type. |
| 49 | type CombinedApisProperties struct { |
Anton Hansson | 16ff357 | 2022-01-11 18:36:35 +0000 | [diff] [blame] | 50 | // Module libraries in the bootclasspath |
| 51 | Bootclasspath []string |
Anton Hansson | 07a1295 | 2022-01-12 17:28:39 +0000 | [diff] [blame] | 52 | // Module libraries on the bootclasspath if include_nonpublic_framework_api is true. |
| 53 | Conditional_bootclasspath []string |
Anton Hansson | 16ff357 | 2022-01-11 18:36:35 +0000 | [diff] [blame] | 54 | // Module libraries in system server |
| 55 | System_server_classpath []string |
Anton Hansson | 0860aaf | 2021-10-08 16:48:03 +0100 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | type CombinedApis struct { |
| 59 | android.ModuleBase |
| 60 | |
| 61 | properties CombinedApisProperties |
| 62 | } |
| 63 | |
| 64 | func init() { |
| 65 | registerBuildComponents(android.InitRegistrationContext) |
| 66 | } |
| 67 | |
| 68 | func registerBuildComponents(ctx android.RegistrationContext) { |
| 69 | ctx.RegisterModuleType("combined_apis", combinedApisModuleFactory) |
| 70 | } |
| 71 | |
| 72 | var PrepareForCombinedApisTest = android.FixtureRegisterWithContext(registerBuildComponents) |
| 73 | |
| 74 | func (a *CombinedApis) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
| 75 | } |
| 76 | |
| 77 | type genruleProps struct { |
| 78 | Name *string |
| 79 | Cmd *string |
| 80 | Dists []android.Dist |
| 81 | Out []string |
| 82 | Srcs []string |
| 83 | Tools []string |
| 84 | Visibility []string |
| 85 | } |
| 86 | |
Anton Hansson | cb00f94 | 2022-01-13 09:45:12 +0000 | [diff] [blame] | 87 | type libraryProps struct { |
| 88 | Name *string |
| 89 | Sdk_version *string |
| 90 | Static_libs []string |
| 91 | Visibility []string |
| 92 | } |
| 93 | |
Anton Hansson | 4468d7c | 2022-01-14 12:10:01 +0000 | [diff] [blame] | 94 | type fgProps struct { |
| 95 | Name *string |
| 96 | Srcs []string |
| 97 | Visibility []string |
| 98 | } |
| 99 | |
Anton Hansson | 0860aaf | 2021-10-08 16:48:03 +0100 | [diff] [blame] | 100 | // Struct to pass parameters for the various merged [current|removed].txt file modules we create. |
| 101 | type MergedTxtDefinition struct { |
| 102 | // "current.txt" or "removed.txt" |
| 103 | TxtFilename string |
Anton Hansson | 09a9c4e | 2022-04-08 10:59:46 +0100 | [diff] [blame] | 104 | // Filename in the new dist dir. "android.txt" or "android-removed.txt" |
| 105 | DistFilename string |
Anton Hansson | 0860aaf | 2021-10-08 16:48:03 +0100 | [diff] [blame] | 106 | // The module for the non-updatable / non-module part of the api. |
| 107 | BaseTxt string |
| 108 | // The list of modules that are relevant for this merged txt. |
| 109 | Modules []string |
| 110 | // The output tag for each module to use.e.g. {.public.api.txt} for current.txt |
| 111 | ModuleTag string |
| 112 | // public, system, module-lib or system-server |
| 113 | Scope string |
| 114 | } |
| 115 | |
| 116 | func createMergedTxt(ctx android.LoadHookContext, txt MergedTxtDefinition) { |
| 117 | metalavaCmd := "$(location metalava)" |
| 118 | // Silence reflection warnings. See b/168689341 |
| 119 | metalavaCmd += " -J--add-opens=java.base/java.util=ALL-UNNAMED " |
| 120 | metalavaCmd += " --quiet --no-banner --format=v2 " |
| 121 | |
| 122 | filename := txt.TxtFilename |
| 123 | if txt.Scope != "public" { |
| 124 | filename = txt.Scope + "-" + filename |
| 125 | } |
Anton Hansson | 0860aaf | 2021-10-08 16:48:03 +0100 | [diff] [blame] | 126 | props := genruleProps{} |
| 127 | props.Name = proptools.StringPtr(ctx.ModuleName() + "-" + filename) |
| 128 | props.Tools = []string{"metalava"} |
Anton Hansson | 16ff357 | 2022-01-11 18:36:35 +0000 | [diff] [blame] | 129 | props.Out = []string{filename} |
Anton Hansson | 0860aaf | 2021-10-08 16:48:03 +0100 | [diff] [blame] | 130 | props.Cmd = proptools.StringPtr(metalavaCmd + "$(in) --api $(out)") |
Anton Hansson | fd31645 | 2022-01-14 11:15:52 +0000 | [diff] [blame] | 131 | props.Srcs = append([]string{txt.BaseTxt}, createSrcs(txt.Modules, txt.ModuleTag)...) |
Anton Hansson | 0860aaf | 2021-10-08 16:48:03 +0100 | [diff] [blame] | 132 | props.Dists = []android.Dist{ |
| 133 | { |
| 134 | Targets: []string{"droidcore"}, |
| 135 | Dir: proptools.StringPtr("api"), |
| 136 | Dest: proptools.StringPtr(filename), |
| 137 | }, |
| 138 | { |
Anton Hansson | 09a9c4e | 2022-04-08 10:59:46 +0100 | [diff] [blame] | 139 | Targets: []string{"api_txt", "sdk"}, |
Anton Hansson | 0860aaf | 2021-10-08 16:48:03 +0100 | [diff] [blame] | 140 | Dir: proptools.StringPtr("apistubs/android/" + txt.Scope + "/api"), |
Anton Hansson | 09a9c4e | 2022-04-08 10:59:46 +0100 | [diff] [blame] | 141 | Dest: proptools.StringPtr(txt.DistFilename), |
Anton Hansson | 0860aaf | 2021-10-08 16:48:03 +0100 | [diff] [blame] | 142 | }, |
| 143 | } |
| 144 | props.Visibility = []string{"//visibility:public"} |
| 145 | ctx.CreateModule(genrule.GenRuleFactory, &props) |
| 146 | } |
| 147 | |
| 148 | func createMergedStubsSrcjar(ctx android.LoadHookContext, modules []string) { |
| 149 | props := genruleProps{} |
| 150 | props.Name = proptools.StringPtr(ctx.ModuleName() + "-current.srcjar") |
| 151 | props.Tools = []string{"merge_zips"} |
| 152 | props.Out = []string{"current.srcjar"} |
| 153 | props.Cmd = proptools.StringPtr("$(location merge_zips) $(out) $(in)") |
Anton Hansson | fd31645 | 2022-01-14 11:15:52 +0000 | [diff] [blame] | 154 | props.Srcs = append([]string{":api-stubs-docs-non-updatable"}, createSrcs(modules, "{.public.stubs.source}")...) |
Anton Hansson | 0860aaf | 2021-10-08 16:48:03 +0100 | [diff] [blame] | 155 | props.Visibility = []string{"//visibility:private"} // Used by make module in //development, mind |
| 156 | ctx.CreateModule(genrule.GenRuleFactory, &props) |
| 157 | } |
| 158 | |
Cole Faust | dcda370 | 2022-10-04 14:46:35 -0700 | [diff] [blame] | 159 | func createMergedAnnotationsFilegroups(ctx android.LoadHookContext, modules, system_server_modules []string) { |
| 160 | for _, i := range []struct{ |
| 161 | name string |
| 162 | tag string |
| 163 | modules []string |
| 164 | }{ |
| 165 | { |
| 166 | name: "all-modules-public-annotations", |
| 167 | tag: "{.public.annotations.zip}", |
| 168 | modules: modules, |
| 169 | }, { |
| 170 | name: "all-modules-system-annotations", |
| 171 | tag: "{.system.annotations.zip}", |
| 172 | modules: modules, |
| 173 | }, { |
| 174 | name: "all-modules-module-lib-annotations", |
| 175 | tag: "{.module-lib.annotations.zip}", |
| 176 | modules: modules, |
| 177 | }, { |
| 178 | name: "all-modules-system-server-annotations", |
| 179 | tag: "{.system-server.annotations.zip}", |
| 180 | modules: system_server_modules, |
| 181 | }, |
| 182 | } { |
| 183 | props := fgProps{} |
| 184 | props.Name = proptools.StringPtr(i.name) |
| 185 | props.Srcs = createSrcs(i.modules, i.tag) |
| 186 | ctx.CreateModule(android.FileGroupFactory, &props) |
| 187 | } |
Anton Hansson | 74b1564 | 2022-06-23 08:27:23 +0000 | [diff] [blame] | 188 | } |
| 189 | |
Anton Hansson | 0860aaf | 2021-10-08 16:48:03 +0100 | [diff] [blame] | 190 | func createFilteredApiVersions(ctx android.LoadHookContext, modules []string) { |
Anton Hansson | 05e944d | 2022-01-13 12:26:30 +0000 | [diff] [blame] | 191 | // For the filtered api versions, we prune all APIs except art module's APIs. because |
| 192 | // 1) ART apis are available by default to all modules, while other module-to-module deps are |
| 193 | // explicit and probably receive more scrutiny anyway |
| 194 | // 2) The number of ART/libcore APIs is large, so not linting them would create a large gap |
| 195 | // 3) It's a compromise. Ideally we wouldn't be filtering out any module APIs, and have |
| 196 | // per-module lint databases that excludes just that module's APIs. Alas, that's more |
| 197 | // difficult to achieve. |
| 198 | modules = remove(modules, art) |
| 199 | |
Cole Faust | dcda370 | 2022-10-04 14:46:35 -0700 | [diff] [blame] | 200 | for _, i := range []struct{ |
| 201 | name string |
| 202 | out string |
| 203 | in string |
| 204 | }{ |
| 205 | { |
| 206 | // We shouldn't need public-filtered or system-filtered. |
| 207 | // public-filtered is currently used to lint things that |
| 208 | // use the module sdk or the system server sdk, but those |
| 209 | // should be switched over to module-filtered and |
| 210 | // system-server-filtered, and then public-filtered can |
| 211 | // be removed. |
| 212 | name: "api-versions-xml-public-filtered", |
| 213 | out: "api-versions-public-filtered.xml", |
| 214 | in: ":api_versions_public{.api_versions.xml}", |
| 215 | }, { |
| 216 | name: "api-versions-xml-module-lib-filtered", |
| 217 | out: "api-versions-module-lib-filtered.xml", |
| 218 | in: ":api_versions_module_lib{.api_versions.xml}", |
| 219 | }, { |
| 220 | name: "api-versions-xml-system-server-filtered", |
| 221 | out: "api-versions-system-server-filtered.xml", |
| 222 | in: ":api_versions_system_server{.api_versions.xml}", |
| 223 | }, |
| 224 | } { |
| 225 | props := genruleProps{} |
| 226 | props.Name = proptools.StringPtr(i.name) |
| 227 | props.Out = []string{i.out} |
| 228 | // Note: order matters: first parameter is the full api-versions.xml |
| 229 | // after that the stubs files in any order |
| 230 | // stubs files are all modules that export API surfaces EXCEPT ART |
| 231 | props.Srcs = append([]string{i.in}, createSrcs(modules, ".stubs{.jar}")...) |
| 232 | props.Tools = []string{"api_versions_trimmer"} |
| 233 | props.Cmd = proptools.StringPtr("$(location api_versions_trimmer) $(out) $(in)") |
| 234 | props.Dists = []android.Dist{{Targets: []string{"sdk"}}} |
| 235 | ctx.CreateModule(genrule.GenRuleFactory, &props) |
| 236 | } |
Anton Hansson | 0860aaf | 2021-10-08 16:48:03 +0100 | [diff] [blame] | 237 | } |
| 238 | |
Anton Hansson | c6e9d2f | 2022-01-25 15:53:43 +0000 | [diff] [blame] | 239 | func createMergedPublicStubs(ctx android.LoadHookContext, modules []string) { |
| 240 | props := libraryProps{} |
| 241 | props.Name = proptools.StringPtr("all-modules-public-stubs") |
| 242 | props.Static_libs = transformArray(modules, "", ".stubs") |
| 243 | props.Sdk_version = proptools.StringPtr("module_current") |
| 244 | props.Visibility = []string{"//frameworks/base"} |
| 245 | ctx.CreateModule(java.LibraryFactory, &props) |
| 246 | } |
| 247 | |
| 248 | func createMergedSystemStubs(ctx android.LoadHookContext, modules []string) { |
| 249 | props := libraryProps{} |
Anton Hansson | c6e9d2f | 2022-01-25 15:53:43 +0000 | [diff] [blame] | 250 | props.Name = proptools.StringPtr("all-modules-system-stubs") |
Paul Duffin | 57533b4 | 2022-01-25 16:25:35 +0000 | [diff] [blame] | 251 | props.Static_libs = transformArray(modules, "", ".stubs.system") |
Anton Hansson | c6e9d2f | 2022-01-25 15:53:43 +0000 | [diff] [blame] | 252 | props.Sdk_version = proptools.StringPtr("module_current") |
| 253 | props.Visibility = []string{"//frameworks/base"} |
| 254 | ctx.CreateModule(java.LibraryFactory, &props) |
| 255 | } |
| 256 | |
Anton Hansson | 95e89a8 | 2022-01-28 11:31:50 +0000 | [diff] [blame] | 257 | func createMergedFrameworkImpl(ctx android.LoadHookContext, modules []string) { |
| 258 | // This module is for the "framework-all" module, which should not include the core libraries. |
| 259 | modules = removeAll(modules, core_libraries_modules) |
Nikita Ioffe | d3f0a6f | 2022-11-15 11:26:53 +0000 | [diff] [blame^] | 260 | // Remove the modules that belong to non-updatable APEXes since those are allowed to compile |
| 261 | // against unstable APIs. |
| 262 | modules = removeAll(modules, non_updatable_modules) |
| 263 | // First create updatable-framework-module-impl, which contains all updatable modules. |
| 264 | // This module compiles against module_lib SDK. |
| 265 | { |
| 266 | props := libraryProps{} |
| 267 | props.Name = proptools.StringPtr("updatable-framework-module-impl") |
| 268 | props.Static_libs = transformArray(modules, "", ".impl") |
| 269 | props.Sdk_version = proptools.StringPtr("module_current") |
| 270 | props.Visibility = []string{"//frameworks/base"} |
| 271 | ctx.CreateModule(java.LibraryFactory, &props) |
| 272 | } |
| 273 | |
| 274 | // Now create all-framework-module-impl, which contains updatable-framework-module-impl |
| 275 | // and all non-updatable modules. This module compiles against hidden APIs. |
| 276 | { |
| 277 | props := libraryProps{} |
| 278 | props.Name = proptools.StringPtr("all-framework-module-impl") |
| 279 | props.Static_libs = transformArray(non_updatable_modules, "", ".impl") |
| 280 | props.Static_libs = append(props.Static_libs, "updatable-framework-module-impl") |
| 281 | props.Sdk_version = proptools.StringPtr("core_platform") |
| 282 | props.Visibility = []string{"//frameworks/base"} |
| 283 | ctx.CreateModule(java.LibraryFactory, &props) |
| 284 | } |
Anton Hansson | 95e89a8 | 2022-01-28 11:31:50 +0000 | [diff] [blame] | 285 | } |
| 286 | |
| 287 | func createMergedFrameworkModuleLibStubs(ctx android.LoadHookContext, modules []string) { |
Anton Hansson | cb00f94 | 2022-01-13 09:45:12 +0000 | [diff] [blame] | 288 | // The user of this module compiles against the "core" SDK, so remove core libraries to avoid dupes. |
Anton Hansson | 95e89a8 | 2022-01-28 11:31:50 +0000 | [diff] [blame] | 289 | modules = removeAll(modules, core_libraries_modules) |
Anton Hansson | cb00f94 | 2022-01-13 09:45:12 +0000 | [diff] [blame] | 290 | props := libraryProps{} |
| 291 | props.Name = proptools.StringPtr("framework-updatable-stubs-module_libs_api") |
Anton Hansson | fd31645 | 2022-01-14 11:15:52 +0000 | [diff] [blame] | 292 | props.Static_libs = transformArray(modules, "", ".stubs.module_lib") |
Anton Hansson | cb00f94 | 2022-01-13 09:45:12 +0000 | [diff] [blame] | 293 | props.Sdk_version = proptools.StringPtr("module_current") |
| 294 | props.Visibility = []string{"//frameworks/base"} |
| 295 | ctx.CreateModule(java.LibraryFactory, &props) |
| 296 | } |
| 297 | |
Anton Hansson | 4468d7c | 2022-01-14 12:10:01 +0000 | [diff] [blame] | 298 | func createPublicStubsSourceFilegroup(ctx android.LoadHookContext, modules []string) { |
| 299 | props := fgProps{} |
| 300 | props.Name = proptools.StringPtr("all-modules-public-stubs-source") |
| 301 | props.Srcs = createSrcs(modules, "{.public.stubs.source}") |
| 302 | props.Visibility = []string{"//frameworks/base"} |
| 303 | ctx.CreateModule(android.FileGroupFactory, &props) |
| 304 | } |
| 305 | |
Anton Hansson | 07a1295 | 2022-01-12 17:28:39 +0000 | [diff] [blame] | 306 | func createMergedTxts(ctx android.LoadHookContext, bootclasspath, system_server_classpath []string) { |
Anton Hansson | 0860aaf | 2021-10-08 16:48:03 +0100 | [diff] [blame] | 307 | var textFiles []MergedTxtDefinition |
Anton Hansson | 16ff357 | 2022-01-11 18:36:35 +0000 | [diff] [blame] | 308 | |
Anton Hansson | 0860aaf | 2021-10-08 16:48:03 +0100 | [diff] [blame] | 309 | tagSuffix := []string{".api.txt}", ".removed-api.txt}"} |
Anton Hansson | 09a9c4e | 2022-04-08 10:59:46 +0100 | [diff] [blame] | 310 | distFilename := []string{"android.txt", "android-removed.txt"} |
Anton Hansson | 0860aaf | 2021-10-08 16:48:03 +0100 | [diff] [blame] | 311 | for i, f := range []string{"current.txt", "removed.txt"} { |
| 312 | textFiles = append(textFiles, MergedTxtDefinition{ |
Anton Hansson | 09a9c4e | 2022-04-08 10:59:46 +0100 | [diff] [blame] | 313 | TxtFilename: f, |
| 314 | DistFilename: distFilename[i], |
| 315 | BaseTxt: ":non-updatable-" + f, |
| 316 | Modules: bootclasspath, |
| 317 | ModuleTag: "{.public" + tagSuffix[i], |
| 318 | Scope: "public", |
Anton Hansson | 0860aaf | 2021-10-08 16:48:03 +0100 | [diff] [blame] | 319 | }) |
| 320 | textFiles = append(textFiles, MergedTxtDefinition{ |
Anton Hansson | 09a9c4e | 2022-04-08 10:59:46 +0100 | [diff] [blame] | 321 | TxtFilename: f, |
| 322 | DistFilename: distFilename[i], |
| 323 | BaseTxt: ":non-updatable-system-" + f, |
| 324 | Modules: bootclasspath, |
| 325 | ModuleTag: "{.system" + tagSuffix[i], |
| 326 | Scope: "system", |
Anton Hansson | 0860aaf | 2021-10-08 16:48:03 +0100 | [diff] [blame] | 327 | }) |
| 328 | textFiles = append(textFiles, MergedTxtDefinition{ |
Anton Hansson | 09a9c4e | 2022-04-08 10:59:46 +0100 | [diff] [blame] | 329 | TxtFilename: f, |
| 330 | DistFilename: distFilename[i], |
| 331 | BaseTxt: ":non-updatable-module-lib-" + f, |
| 332 | Modules: bootclasspath, |
| 333 | ModuleTag: "{.module-lib" + tagSuffix[i], |
| 334 | Scope: "module-lib", |
Anton Hansson | 0860aaf | 2021-10-08 16:48:03 +0100 | [diff] [blame] | 335 | }) |
| 336 | textFiles = append(textFiles, MergedTxtDefinition{ |
Anton Hansson | 09a9c4e | 2022-04-08 10:59:46 +0100 | [diff] [blame] | 337 | TxtFilename: f, |
| 338 | DistFilename: distFilename[i], |
| 339 | BaseTxt: ":non-updatable-system-server-" + f, |
| 340 | Modules: system_server_classpath, |
| 341 | ModuleTag: "{.system-server" + tagSuffix[i], |
| 342 | Scope: "system-server", |
Anton Hansson | 0860aaf | 2021-10-08 16:48:03 +0100 | [diff] [blame] | 343 | }) |
| 344 | } |
| 345 | for _, txt := range textFiles { |
| 346 | createMergedTxt(ctx, txt) |
| 347 | } |
| 348 | } |
| 349 | |
| 350 | func (a *CombinedApis) createInternalModules(ctx android.LoadHookContext) { |
Anton Hansson | 07a1295 | 2022-01-12 17:28:39 +0000 | [diff] [blame] | 351 | bootclasspath := a.properties.Bootclasspath |
Cole Faust | dcda370 | 2022-10-04 14:46:35 -0700 | [diff] [blame] | 352 | system_server_classpath := a.properties.System_server_classpath |
Anton Hansson | 07a1295 | 2022-01-12 17:28:39 +0000 | [diff] [blame] | 353 | if ctx.Config().VendorConfig("ANDROID").Bool("include_nonpublic_framework_api") { |
| 354 | bootclasspath = append(bootclasspath, a.properties.Conditional_bootclasspath...) |
| 355 | sort.Strings(bootclasspath) |
| 356 | } |
Cole Faust | dcda370 | 2022-10-04 14:46:35 -0700 | [diff] [blame] | 357 | createMergedTxts(ctx, bootclasspath, system_server_classpath) |
Anton Hansson | 0860aaf | 2021-10-08 16:48:03 +0100 | [diff] [blame] | 358 | |
Anton Hansson | 07a1295 | 2022-01-12 17:28:39 +0000 | [diff] [blame] | 359 | createMergedStubsSrcjar(ctx, bootclasspath) |
Anton Hansson | 0860aaf | 2021-10-08 16:48:03 +0100 | [diff] [blame] | 360 | |
Anton Hansson | c6e9d2f | 2022-01-25 15:53:43 +0000 | [diff] [blame] | 361 | createMergedPublicStubs(ctx, bootclasspath) |
| 362 | createMergedSystemStubs(ctx, bootclasspath) |
Anton Hansson | 95e89a8 | 2022-01-28 11:31:50 +0000 | [diff] [blame] | 363 | createMergedFrameworkModuleLibStubs(ctx, bootclasspath) |
| 364 | createMergedFrameworkImpl(ctx, bootclasspath) |
Anton Hansson | cb00f94 | 2022-01-13 09:45:12 +0000 | [diff] [blame] | 365 | |
Cole Faust | dcda370 | 2022-10-04 14:46:35 -0700 | [diff] [blame] | 366 | createMergedAnnotationsFilegroups(ctx, bootclasspath, system_server_classpath) |
Anton Hansson | cc18e03 | 2022-01-12 14:45:22 +0000 | [diff] [blame] | 367 | |
Anton Hansson | 05e944d | 2022-01-13 12:26:30 +0000 | [diff] [blame] | 368 | createFilteredApiVersions(ctx, bootclasspath) |
Anton Hansson | 4468d7c | 2022-01-14 12:10:01 +0000 | [diff] [blame] | 369 | |
| 370 | createPublicStubsSourceFilegroup(ctx, bootclasspath) |
Anton Hansson | 0860aaf | 2021-10-08 16:48:03 +0100 | [diff] [blame] | 371 | } |
| 372 | |
| 373 | func combinedApisModuleFactory() android.Module { |
| 374 | module := &CombinedApis{} |
| 375 | module.AddProperties(&module.properties) |
| 376 | android.InitAndroidModule(module) |
| 377 | android.AddLoadHook(module, func(ctx android.LoadHookContext) { module.createInternalModules(ctx) }) |
| 378 | return module |
| 379 | } |
Anton Hansson | fd31645 | 2022-01-14 11:15:52 +0000 | [diff] [blame] | 380 | |
| 381 | // Various utility methods below. |
| 382 | |
| 383 | // Creates an array of ":<m><tag>" for each m in <modules>. |
| 384 | func createSrcs(modules []string, tag string) []string { |
| 385 | return transformArray(modules, ":", tag) |
| 386 | } |
| 387 | |
| 388 | // Creates an array of "<prefix><m><suffix>", for each m in <modules>. |
| 389 | func transformArray(modules []string, prefix, suffix string) []string { |
| 390 | a := make([]string, 0, len(modules)) |
| 391 | for _, module := range modules { |
| 392 | a = append(a, prefix+module+suffix) |
| 393 | } |
| 394 | return a |
| 395 | } |
| 396 | |
| 397 | func removeAll(s []string, vs []string) []string { |
| 398 | for _, v := range vs { |
| 399 | s = remove(s, v) |
| 400 | } |
| 401 | return s |
| 402 | } |
| 403 | |
| 404 | func remove(s []string, v string) []string { |
| 405 | s2 := make([]string, 0, len(s)) |
| 406 | for _, sv := range s { |
| 407 | if sv != v { |
| 408 | s2 = append(s2, sv) |
| 409 | } |
| 410 | } |
| 411 | return s2 |
| 412 | } |