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 ( |
Cole Faust | b1fc07e | 2024-09-05 11:37:57 -0700 | [diff] [blame^] | 18 | "slices" |
Anton Hansson | 07a1295 | 2022-01-12 17:28:39 +0000 | [diff] [blame] | 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" |
Mark White | 3cc5e00 | 2023-08-07 11:18:09 +0000 | [diff] [blame] | 31 | const location = "framework-location" |
Anton Hansson | 09a9c4e | 2022-04-08 10:59:46 +0100 | [diff] [blame] | 32 | |
Anton Hansson | 95e89a8 | 2022-01-28 11:31:50 +0000 | [diff] [blame] | 33 | var core_libraries_modules = []string{art, conscrypt, i18n} |
Zi Wang | 0d6a530 | 2023-02-16 14:54:01 -0800 | [diff] [blame] | 34 | |
Nikita Ioffe | d3f0a6f | 2022-11-15 11:26:53 +0000 | [diff] [blame] | 35 | // List of modules that are not yet updatable, and hence they can still compile |
| 36 | // against hidden APIs. These modules are filtered out when building the |
| 37 | // updatable-framework-module-impl (because updatable-framework-module-impl is |
| 38 | // built against module_current SDK). Instead they are directly statically |
| 39 | // linked into the all-framework-module-lib, which is building against hidden |
| 40 | // APIs. |
Nikita Ioffe | 5593fbb | 2022-12-01 14:52:34 +0000 | [diff] [blame] | 41 | // In addition, the modules in this list are allowed to contribute to test APIs |
| 42 | // stubs. |
Roshan Pius | 96dac95 | 2023-12-07 10:54:05 -0800 | [diff] [blame] | 43 | var non_updatable_modules = []string{virtualization, location} |
Anton Hansson | 05e944d | 2022-01-13 12:26:30 +0000 | [diff] [blame] | 44 | |
Anton Hansson | 0860aaf | 2021-10-08 16:48:03 +0100 | [diff] [blame] | 45 | // The intention behind this soong plugin is to generate a number of "merged" |
| 46 | // API-related modules that would otherwise require a large amount of very |
| 47 | // similar Android.bp boilerplate to define. For example, the merged current.txt |
| 48 | // API definitions (created by merging the non-updatable current.txt with all |
| 49 | // the module current.txts). This simplifies the addition of new android |
| 50 | // modules, by reducing the number of genrules etc a new module must be added to. |
| 51 | |
| 52 | // The properties of the combined_apis module type. |
| 53 | type CombinedApisProperties struct { |
Anton Hansson | 16ff357 | 2022-01-11 18:36:35 +0000 | [diff] [blame] | 54 | // Module libraries in the bootclasspath |
Jihoon Kang | cc4c8f9 | 2024-07-18 18:52:03 +0000 | [diff] [blame] | 55 | Bootclasspath proptools.Configurable[[]string] |
Anton Hansson | 07a1295 | 2022-01-12 17:28:39 +0000 | [diff] [blame] | 56 | // Module libraries on the bootclasspath if include_nonpublic_framework_api is true. |
| 57 | Conditional_bootclasspath []string |
Anton Hansson | 16ff357 | 2022-01-11 18:36:35 +0000 | [diff] [blame] | 58 | // Module libraries in system server |
Jihoon Kang | cc4c8f9 | 2024-07-18 18:52:03 +0000 | [diff] [blame] | 59 | System_server_classpath proptools.Configurable[[]string] |
Anton Hansson | 0860aaf | 2021-10-08 16:48:03 +0100 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | type CombinedApis struct { |
| 63 | android.ModuleBase |
| 64 | |
| 65 | properties CombinedApisProperties |
| 66 | } |
| 67 | |
| 68 | func init() { |
| 69 | registerBuildComponents(android.InitRegistrationContext) |
| 70 | } |
| 71 | |
| 72 | func registerBuildComponents(ctx android.RegistrationContext) { |
| 73 | ctx.RegisterModuleType("combined_apis", combinedApisModuleFactory) |
| 74 | } |
| 75 | |
| 76 | var PrepareForCombinedApisTest = android.FixtureRegisterWithContext(registerBuildComponents) |
| 77 | |
Jihoon Kang | cc4c8f9 | 2024-07-18 18:52:03 +0000 | [diff] [blame] | 78 | func (a *CombinedApis) apiFingerprintStubDeps(ctx android.BottomUpMutatorContext) []string { |
Cole Faust | b1fc07e | 2024-09-05 11:37:57 -0700 | [diff] [blame^] | 79 | bootClasspath := a.properties.Bootclasspath.GetOrDefault(ctx, nil) |
| 80 | systemServerClasspath := a.properties.System_server_classpath.GetOrDefault(ctx, nil) |
| 81 | var ret []string |
Spandan Das | 67b7906 | 2024-02-12 11:40:51 +0000 | [diff] [blame] | 82 | ret = append( |
| 83 | ret, |
Cole Faust | b1fc07e | 2024-09-05 11:37:57 -0700 | [diff] [blame^] | 84 | transformArray(bootClasspath, "", ".stubs")..., |
Spandan Das | 67b7906 | 2024-02-12 11:40:51 +0000 | [diff] [blame] | 85 | ) |
| 86 | ret = append( |
| 87 | ret, |
Cole Faust | b1fc07e | 2024-09-05 11:37:57 -0700 | [diff] [blame^] | 88 | transformArray(bootClasspath, "", ".stubs.system")..., |
Spandan Das | 67b7906 | 2024-02-12 11:40:51 +0000 | [diff] [blame] | 89 | ) |
| 90 | ret = append( |
| 91 | ret, |
Cole Faust | b1fc07e | 2024-09-05 11:37:57 -0700 | [diff] [blame^] | 92 | transformArray(bootClasspath, "", ".stubs.module_lib")..., |
Spandan Das | 67b7906 | 2024-02-12 11:40:51 +0000 | [diff] [blame] | 93 | ) |
| 94 | ret = append( |
| 95 | ret, |
Cole Faust | b1fc07e | 2024-09-05 11:37:57 -0700 | [diff] [blame^] | 96 | transformArray(systemServerClasspath, "", ".stubs.system_server")..., |
Spandan Das | 67b7906 | 2024-02-12 11:40:51 +0000 | [diff] [blame] | 97 | ) |
| 98 | return ret |
| 99 | } |
| 100 | |
| 101 | func (a *CombinedApis) DepsMutator(ctx android.BottomUpMutatorContext) { |
Jihoon Kang | cc4c8f9 | 2024-07-18 18:52:03 +0000 | [diff] [blame] | 102 | ctx.AddDependency(ctx.Module(), nil, a.apiFingerprintStubDeps(ctx)...) |
Spandan Das | 67b7906 | 2024-02-12 11:40:51 +0000 | [diff] [blame] | 103 | } |
| 104 | |
Anton Hansson | 0860aaf | 2021-10-08 16:48:03 +0100 | [diff] [blame] | 105 | func (a *CombinedApis) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
Spandan Das | 67b7906 | 2024-02-12 11:40:51 +0000 | [diff] [blame] | 106 | ctx.WalkDeps(func(child, parent android.Module) bool { |
| 107 | if _, ok := child.(java.AndroidLibraryDependency); ok && child.Name() != "framework-res" { |
| 108 | // Stubs of BCP and SSCP libraries should not have any dependencies on apps |
| 109 | // This check ensures that we do not run into circular dependencies when UNBUNDLED_BUILD_TARGET_SDK_WITH_API_FINGERPRINT=true |
| 110 | ctx.ModuleErrorf( |
| 111 | "Module %s is not a valid dependency of the stub library %s\n."+ |
| 112 | "If this dependency has been added via `libs` of java_sdk_library, please move it to `impl_only_libs`\n", |
| 113 | child.Name(), parent.Name()) |
| 114 | return false // error detected |
| 115 | } |
| 116 | return true |
| 117 | }) |
| 118 | |
Anton Hansson | 0860aaf | 2021-10-08 16:48:03 +0100 | [diff] [blame] | 119 | } |
| 120 | |
| 121 | type genruleProps struct { |
| 122 | Name *string |
| 123 | Cmd *string |
| 124 | Dists []android.Dist |
| 125 | Out []string |
Cole Faust | b1fc07e | 2024-09-05 11:37:57 -0700 | [diff] [blame^] | 126 | Srcs proptools.Configurable[[]string] |
Anton Hansson | 0860aaf | 2021-10-08 16:48:03 +0100 | [diff] [blame] | 127 | Tools []string |
| 128 | Visibility []string |
| 129 | } |
| 130 | |
Anton Hansson | cb00f94 | 2022-01-13 09:45:12 +0000 | [diff] [blame] | 131 | type libraryProps struct { |
Jihoon Kang | a7073b5 | 2024-02-12 23:18:52 +0000 | [diff] [blame] | 132 | Name *string |
| 133 | Sdk_version *string |
Cole Faust | b1fc07e | 2024-09-05 11:37:57 -0700 | [diff] [blame^] | 134 | Static_libs proptools.Configurable[[]string] |
Jihoon Kang | a7073b5 | 2024-02-12 23:18:52 +0000 | [diff] [blame] | 135 | Visibility []string |
| 136 | Defaults []string |
| 137 | Is_stubs_module *bool |
Anton Hansson | cb00f94 | 2022-01-13 09:45:12 +0000 | [diff] [blame] | 138 | } |
| 139 | |
Anton Hansson | 4468d7c | 2022-01-14 12:10:01 +0000 | [diff] [blame] | 140 | type fgProps struct { |
| 141 | Name *string |
Cole Faust | b1fc07e | 2024-09-05 11:37:57 -0700 | [diff] [blame^] | 142 | Srcs proptools.Configurable[[]string] |
Anton Hansson | 4468d7c | 2022-01-14 12:10:01 +0000 | [diff] [blame] | 143 | Visibility []string |
| 144 | } |
| 145 | |
Jihoon Kang | 1e4ac1d | 2023-04-07 18:50:38 +0000 | [diff] [blame] | 146 | type defaultsProps struct { |
| 147 | Name *string |
| 148 | Api_surface *string |
| 149 | Api_contributions []string |
| 150 | Defaults_visibility []string |
Jihoon Kang | 471a05b | 2023-08-01 06:37:17 +0000 | [diff] [blame] | 151 | Previous_api *string |
Jihoon Kang | 1e4ac1d | 2023-04-07 18:50:38 +0000 | [diff] [blame] | 152 | } |
| 153 | |
Anton Hansson | 0860aaf | 2021-10-08 16:48:03 +0100 | [diff] [blame] | 154 | // Struct to pass parameters for the various merged [current|removed].txt file modules we create. |
| 155 | type MergedTxtDefinition struct { |
| 156 | // "current.txt" or "removed.txt" |
| 157 | TxtFilename string |
Anton Hansson | 09a9c4e | 2022-04-08 10:59:46 +0100 | [diff] [blame] | 158 | // Filename in the new dist dir. "android.txt" or "android-removed.txt" |
| 159 | DistFilename string |
Anton Hansson | 0860aaf | 2021-10-08 16:48:03 +0100 | [diff] [blame] | 160 | // The module for the non-updatable / non-module part of the api. |
| 161 | BaseTxt string |
| 162 | // The list of modules that are relevant for this merged txt. |
Cole Faust | b1fc07e | 2024-09-05 11:37:57 -0700 | [diff] [blame^] | 163 | Modules proptools.Configurable[[]string] |
Anton Hansson | 0860aaf | 2021-10-08 16:48:03 +0100 | [diff] [blame] | 164 | // The output tag for each module to use.e.g. {.public.api.txt} for current.txt |
| 165 | ModuleTag string |
| 166 | // public, system, module-lib or system-server |
| 167 | Scope string |
| 168 | } |
| 169 | |
Jihoon Kang | 31cf274 | 2024-02-07 19:52:19 +0000 | [diff] [blame] | 170 | func createMergedTxt(ctx android.LoadHookContext, txt MergedTxtDefinition, stubsTypeSuffix string, doDist bool) { |
Anton Hansson | 0860aaf | 2021-10-08 16:48:03 +0100 | [diff] [blame] | 171 | metalavaCmd := "$(location metalava)" |
| 172 | // Silence reflection warnings. See b/168689341 |
| 173 | metalavaCmd += " -J--add-opens=java.base/java.util=ALL-UNNAMED " |
Paul Duffin | f3b1fc4 | 2023-08-14 22:03:06 +0100 | [diff] [blame] | 174 | metalavaCmd += " --quiet merge-signatures --format=v2 " |
Anton Hansson | 0860aaf | 2021-10-08 16:48:03 +0100 | [diff] [blame] | 175 | |
| 176 | filename := txt.TxtFilename |
| 177 | if txt.Scope != "public" { |
| 178 | filename = txt.Scope + "-" + filename |
| 179 | } |
Jihoon Kang | 31cf274 | 2024-02-07 19:52:19 +0000 | [diff] [blame] | 180 | moduleName := ctx.ModuleName() + stubsTypeSuffix + filename |
Chris Parsons | 3b7e34b | 2023-09-27 22:34:57 +0000 | [diff] [blame] | 181 | |
Anton Hansson | 0860aaf | 2021-10-08 16:48:03 +0100 | [diff] [blame] | 182 | props := genruleProps{} |
Chris Parsons | 3b7e34b | 2023-09-27 22:34:57 +0000 | [diff] [blame] | 183 | props.Name = proptools.StringPtr(moduleName) |
Anton Hansson | 0860aaf | 2021-10-08 16:48:03 +0100 | [diff] [blame] | 184 | props.Tools = []string{"metalava"} |
Anton Hansson | 16ff357 | 2022-01-11 18:36:35 +0000 | [diff] [blame] | 185 | props.Out = []string{filename} |
Paul Duffin | f3b1fc4 | 2023-08-14 22:03:06 +0100 | [diff] [blame] | 186 | props.Cmd = proptools.StringPtr(metalavaCmd + "$(in) --out $(out)") |
Cole Faust | b1fc07e | 2024-09-05 11:37:57 -0700 | [diff] [blame^] | 187 | props.Srcs = proptools.NewSimpleConfigurable([]string{txt.BaseTxt}) |
| 188 | props.Srcs.Append(createSrcs(txt.Modules, txt.ModuleTag)) |
Jihoon Kang | 31cf274 | 2024-02-07 19:52:19 +0000 | [diff] [blame] | 189 | if doDist { |
| 190 | props.Dists = []android.Dist{ |
| 191 | { |
| 192 | Targets: []string{"droidcore"}, |
| 193 | Dir: proptools.StringPtr("api"), |
| 194 | Dest: proptools.StringPtr(filename), |
| 195 | }, |
| 196 | { |
| 197 | Targets: []string{"api_txt", "sdk"}, |
| 198 | Dir: proptools.StringPtr("apistubs/android/" + txt.Scope + "/api"), |
| 199 | Dest: proptools.StringPtr(txt.DistFilename), |
| 200 | }, |
| 201 | } |
Anton Hansson | 0860aaf | 2021-10-08 16:48:03 +0100 | [diff] [blame] | 202 | } |
| 203 | props.Visibility = []string{"//visibility:public"} |
Colin Cross | c642076 | 2023-12-07 12:38:40 -0800 | [diff] [blame] | 204 | ctx.CreateModule(genrule.GenRuleFactory, &props) |
Anton Hansson | 0860aaf | 2021-10-08 16:48:03 +0100 | [diff] [blame] | 205 | } |
| 206 | |
Cole Faust | b1fc07e | 2024-09-05 11:37:57 -0700 | [diff] [blame^] | 207 | func createMergedAnnotationsFilegroups(ctx android.LoadHookContext, modules, system_server_modules proptools.Configurable[[]string]) { |
Jihoon Kang | 1e4ac1d | 2023-04-07 18:50:38 +0000 | [diff] [blame] | 208 | for _, i := range []struct { |
Cole Faust | dcda370 | 2022-10-04 14:46:35 -0700 | [diff] [blame] | 209 | name string |
| 210 | tag string |
Cole Faust | b1fc07e | 2024-09-05 11:37:57 -0700 | [diff] [blame^] | 211 | modules proptools.Configurable[[]string] |
Cole Faust | dcda370 | 2022-10-04 14:46:35 -0700 | [diff] [blame] | 212 | }{ |
| 213 | { |
Jihoon Kang | 1e4ac1d | 2023-04-07 18:50:38 +0000 | [diff] [blame] | 214 | name: "all-modules-public-annotations", |
| 215 | tag: "{.public.annotations.zip}", |
Cole Faust | dcda370 | 2022-10-04 14:46:35 -0700 | [diff] [blame] | 216 | modules: modules, |
| 217 | }, { |
Jihoon Kang | 1e4ac1d | 2023-04-07 18:50:38 +0000 | [diff] [blame] | 218 | name: "all-modules-system-annotations", |
| 219 | tag: "{.system.annotations.zip}", |
Cole Faust | dcda370 | 2022-10-04 14:46:35 -0700 | [diff] [blame] | 220 | modules: modules, |
| 221 | }, { |
Jihoon Kang | 1e4ac1d | 2023-04-07 18:50:38 +0000 | [diff] [blame] | 222 | name: "all-modules-module-lib-annotations", |
| 223 | tag: "{.module-lib.annotations.zip}", |
Cole Faust | dcda370 | 2022-10-04 14:46:35 -0700 | [diff] [blame] | 224 | modules: modules, |
| 225 | }, { |
Jihoon Kang | 1e4ac1d | 2023-04-07 18:50:38 +0000 | [diff] [blame] | 226 | name: "all-modules-system-server-annotations", |
| 227 | tag: "{.system-server.annotations.zip}", |
Cole Faust | dcda370 | 2022-10-04 14:46:35 -0700 | [diff] [blame] | 228 | modules: system_server_modules, |
| 229 | }, |
| 230 | } { |
| 231 | props := fgProps{} |
| 232 | props.Name = proptools.StringPtr(i.name) |
| 233 | props.Srcs = createSrcs(i.modules, i.tag) |
Colin Cross | c642076 | 2023-12-07 12:38:40 -0800 | [diff] [blame] | 234 | ctx.CreateModule(android.FileGroupFactory, &props) |
Cole Faust | dcda370 | 2022-10-04 14:46:35 -0700 | [diff] [blame] | 235 | } |
Anton Hansson | 74b1564 | 2022-06-23 08:27:23 +0000 | [diff] [blame] | 236 | } |
| 237 | |
Cole Faust | b1fc07e | 2024-09-05 11:37:57 -0700 | [diff] [blame^] | 238 | func createMergedPublicStubs(ctx android.LoadHookContext, modules proptools.Configurable[[]string]) { |
| 239 | modules = modules.Clone() |
| 240 | transformConfigurableArray(modules, "", ".stubs") |
Anton Hansson | c6e9d2f | 2022-01-25 15:53:43 +0000 | [diff] [blame] | 241 | props := libraryProps{} |
| 242 | props.Name = proptools.StringPtr("all-modules-public-stubs") |
Cole Faust | b1fc07e | 2024-09-05 11:37:57 -0700 | [diff] [blame^] | 243 | props.Static_libs = modules |
Anton Hansson | c6e9d2f | 2022-01-25 15:53:43 +0000 | [diff] [blame] | 244 | props.Sdk_version = proptools.StringPtr("module_current") |
| 245 | props.Visibility = []string{"//frameworks/base"} |
Jihoon Kang | a7073b5 | 2024-02-12 23:18:52 +0000 | [diff] [blame] | 246 | props.Is_stubs_module = proptools.BoolPtr(true) |
Anton Hansson | c6e9d2f | 2022-01-25 15:53:43 +0000 | [diff] [blame] | 247 | ctx.CreateModule(java.LibraryFactory, &props) |
| 248 | } |
| 249 | |
Cole Faust | b1fc07e | 2024-09-05 11:37:57 -0700 | [diff] [blame^] | 250 | func createMergedPublicExportableStubs(ctx android.LoadHookContext, modules proptools.Configurable[[]string]) { |
| 251 | modules = modules.Clone() |
| 252 | transformConfigurableArray(modules, "", ".stubs.exportable") |
Jihoon Kang | 059b949 | 2023-12-29 00:40:34 +0000 | [diff] [blame] | 253 | props := libraryProps{} |
| 254 | props.Name = proptools.StringPtr("all-modules-public-stubs-exportable") |
Cole Faust | b1fc07e | 2024-09-05 11:37:57 -0700 | [diff] [blame^] | 255 | props.Static_libs = modules |
Jihoon Kang | 059b949 | 2023-12-29 00:40:34 +0000 | [diff] [blame] | 256 | props.Sdk_version = proptools.StringPtr("module_current") |
| 257 | props.Visibility = []string{"//frameworks/base"} |
Jihoon Kang | a7073b5 | 2024-02-12 23:18:52 +0000 | [diff] [blame] | 258 | props.Is_stubs_module = proptools.BoolPtr(true) |
Jihoon Kang | 059b949 | 2023-12-29 00:40:34 +0000 | [diff] [blame] | 259 | ctx.CreateModule(java.LibraryFactory, &props) |
| 260 | } |
| 261 | |
Cole Faust | b1fc07e | 2024-09-05 11:37:57 -0700 | [diff] [blame^] | 262 | func createMergedSystemStubs(ctx android.LoadHookContext, modules proptools.Configurable[[]string]) { |
Nikita Ioffe | 5593fbb | 2022-12-01 14:52:34 +0000 | [diff] [blame] | 263 | // First create the all-updatable-modules-system-stubs |
| 264 | { |
Cole Faust | b1fc07e | 2024-09-05 11:37:57 -0700 | [diff] [blame^] | 265 | updatable_modules := modules.Clone() |
| 266 | removeAll(updatable_modules, non_updatable_modules) |
| 267 | transformConfigurableArray(updatable_modules, "", ".stubs.system") |
Nikita Ioffe | 5593fbb | 2022-12-01 14:52:34 +0000 | [diff] [blame] | 268 | props := libraryProps{} |
| 269 | props.Name = proptools.StringPtr("all-updatable-modules-system-stubs") |
Cole Faust | b1fc07e | 2024-09-05 11:37:57 -0700 | [diff] [blame^] | 270 | props.Static_libs = updatable_modules |
Nikita Ioffe | 5593fbb | 2022-12-01 14:52:34 +0000 | [diff] [blame] | 271 | props.Sdk_version = proptools.StringPtr("module_current") |
| 272 | props.Visibility = []string{"//frameworks/base"} |
Jihoon Kang | a7073b5 | 2024-02-12 23:18:52 +0000 | [diff] [blame] | 273 | props.Is_stubs_module = proptools.BoolPtr(true) |
Nikita Ioffe | 5593fbb | 2022-12-01 14:52:34 +0000 | [diff] [blame] | 274 | ctx.CreateModule(java.LibraryFactory, &props) |
| 275 | } |
| 276 | // Now merge all-updatable-modules-system-stubs and stubs from non-updatable modules |
| 277 | // into all-modules-system-stubs. |
| 278 | { |
Cole Faust | b1fc07e | 2024-09-05 11:37:57 -0700 | [diff] [blame^] | 279 | static_libs := transformArray(non_updatable_modules, "", ".stubs.system") |
| 280 | static_libs = append(static_libs, "all-updatable-modules-system-stubs") |
Nikita Ioffe | 5593fbb | 2022-12-01 14:52:34 +0000 | [diff] [blame] | 281 | props := libraryProps{} |
| 282 | props.Name = proptools.StringPtr("all-modules-system-stubs") |
Cole Faust | b1fc07e | 2024-09-05 11:37:57 -0700 | [diff] [blame^] | 283 | props.Static_libs = proptools.NewSimpleConfigurable(static_libs) |
Nikita Ioffe | 5593fbb | 2022-12-01 14:52:34 +0000 | [diff] [blame] | 284 | props.Sdk_version = proptools.StringPtr("module_current") |
| 285 | props.Visibility = []string{"//frameworks/base"} |
Jihoon Kang | a7073b5 | 2024-02-12 23:18:52 +0000 | [diff] [blame] | 286 | props.Is_stubs_module = proptools.BoolPtr(true) |
Nikita Ioffe | 5593fbb | 2022-12-01 14:52:34 +0000 | [diff] [blame] | 287 | ctx.CreateModule(java.LibraryFactory, &props) |
| 288 | } |
| 289 | } |
| 290 | |
Cole Faust | b1fc07e | 2024-09-05 11:37:57 -0700 | [diff] [blame^] | 291 | func createMergedSystemExportableStubs(ctx android.LoadHookContext, modules proptools.Configurable[[]string]) { |
Jihoon Kang | 059b949 | 2023-12-29 00:40:34 +0000 | [diff] [blame] | 292 | // First create the all-updatable-modules-system-stubs |
| 293 | { |
Cole Faust | b1fc07e | 2024-09-05 11:37:57 -0700 | [diff] [blame^] | 294 | updatable_modules := modules.Clone() |
| 295 | removeAll(updatable_modules, non_updatable_modules) |
| 296 | transformConfigurableArray(updatable_modules, "", ".stubs.exportable.system") |
Jihoon Kang | 059b949 | 2023-12-29 00:40:34 +0000 | [diff] [blame] | 297 | props := libraryProps{} |
| 298 | props.Name = proptools.StringPtr("all-updatable-modules-system-stubs-exportable") |
Cole Faust | b1fc07e | 2024-09-05 11:37:57 -0700 | [diff] [blame^] | 299 | props.Static_libs = updatable_modules |
Jihoon Kang | 059b949 | 2023-12-29 00:40:34 +0000 | [diff] [blame] | 300 | props.Sdk_version = proptools.StringPtr("module_current") |
| 301 | props.Visibility = []string{"//frameworks/base"} |
Jihoon Kang | a7073b5 | 2024-02-12 23:18:52 +0000 | [diff] [blame] | 302 | props.Is_stubs_module = proptools.BoolPtr(true) |
Jihoon Kang | 059b949 | 2023-12-29 00:40:34 +0000 | [diff] [blame] | 303 | ctx.CreateModule(java.LibraryFactory, &props) |
| 304 | } |
| 305 | // Now merge all-updatable-modules-system-stubs and stubs from non-updatable modules |
| 306 | // into all-modules-system-stubs. |
| 307 | { |
Cole Faust | b1fc07e | 2024-09-05 11:37:57 -0700 | [diff] [blame^] | 308 | static_libs := transformArray(non_updatable_modules, "", ".stubs.exportable.system") |
| 309 | static_libs = append(static_libs, "all-updatable-modules-system-stubs-exportable") |
Jihoon Kang | 059b949 | 2023-12-29 00:40:34 +0000 | [diff] [blame] | 310 | props := libraryProps{} |
| 311 | props.Name = proptools.StringPtr("all-modules-system-stubs-exportable") |
Cole Faust | b1fc07e | 2024-09-05 11:37:57 -0700 | [diff] [blame^] | 312 | props.Static_libs = proptools.NewSimpleConfigurable(static_libs) |
Jihoon Kang | 059b949 | 2023-12-29 00:40:34 +0000 | [diff] [blame] | 313 | props.Sdk_version = proptools.StringPtr("module_current") |
| 314 | props.Visibility = []string{"//frameworks/base"} |
Jihoon Kang | a7073b5 | 2024-02-12 23:18:52 +0000 | [diff] [blame] | 315 | props.Is_stubs_module = proptools.BoolPtr(true) |
Jihoon Kang | 059b949 | 2023-12-29 00:40:34 +0000 | [diff] [blame] | 316 | ctx.CreateModule(java.LibraryFactory, &props) |
| 317 | } |
| 318 | } |
| 319 | |
Nikita Ioffe | 5593fbb | 2022-12-01 14:52:34 +0000 | [diff] [blame] | 320 | func createMergedTestStubsForNonUpdatableModules(ctx android.LoadHookContext) { |
Anton Hansson | c6e9d2f | 2022-01-25 15:53:43 +0000 | [diff] [blame] | 321 | props := libraryProps{} |
Nikita Ioffe | 5593fbb | 2022-12-01 14:52:34 +0000 | [diff] [blame] | 322 | props.Name = proptools.StringPtr("all-non-updatable-modules-test-stubs") |
Cole Faust | b1fc07e | 2024-09-05 11:37:57 -0700 | [diff] [blame^] | 323 | props.Static_libs = proptools.NewSimpleConfigurable(transformArray(non_updatable_modules, "", ".stubs.test")) |
Anton Hansson | c6e9d2f | 2022-01-25 15:53:43 +0000 | [diff] [blame] | 324 | props.Sdk_version = proptools.StringPtr("module_current") |
| 325 | props.Visibility = []string{"//frameworks/base"} |
Jihoon Kang | a7073b5 | 2024-02-12 23:18:52 +0000 | [diff] [blame] | 326 | props.Is_stubs_module = proptools.BoolPtr(true) |
Anton Hansson | c6e9d2f | 2022-01-25 15:53:43 +0000 | [diff] [blame] | 327 | ctx.CreateModule(java.LibraryFactory, &props) |
| 328 | } |
| 329 | |
Jihoon Kang | 059b949 | 2023-12-29 00:40:34 +0000 | [diff] [blame] | 330 | func createMergedTestExportableStubsForNonUpdatableModules(ctx android.LoadHookContext) { |
| 331 | props := libraryProps{} |
| 332 | props.Name = proptools.StringPtr("all-non-updatable-modules-test-stubs-exportable") |
Cole Faust | b1fc07e | 2024-09-05 11:37:57 -0700 | [diff] [blame^] | 333 | props.Static_libs = proptools.NewSimpleConfigurable(transformArray(non_updatable_modules, "", ".stubs.exportable.test")) |
Jihoon Kang | 059b949 | 2023-12-29 00:40:34 +0000 | [diff] [blame] | 334 | props.Sdk_version = proptools.StringPtr("module_current") |
| 335 | props.Visibility = []string{"//frameworks/base"} |
Jihoon Kang | a7073b5 | 2024-02-12 23:18:52 +0000 | [diff] [blame] | 336 | props.Is_stubs_module = proptools.BoolPtr(true) |
Jihoon Kang | 059b949 | 2023-12-29 00:40:34 +0000 | [diff] [blame] | 337 | ctx.CreateModule(java.LibraryFactory, &props) |
| 338 | } |
| 339 | |
Cole Faust | b1fc07e | 2024-09-05 11:37:57 -0700 | [diff] [blame^] | 340 | func createMergedFrameworkImpl(ctx android.LoadHookContext, modules proptools.Configurable[[]string]) { |
| 341 | modules = modules.Clone() |
Anton Hansson | 95e89a8 | 2022-01-28 11:31:50 +0000 | [diff] [blame] | 342 | // This module is for the "framework-all" module, which should not include the core libraries. |
Cole Faust | b1fc07e | 2024-09-05 11:37:57 -0700 | [diff] [blame^] | 343 | removeAll(modules, core_libraries_modules) |
Nikita Ioffe | d3f0a6f | 2022-11-15 11:26:53 +0000 | [diff] [blame] | 344 | // Remove the modules that belong to non-updatable APEXes since those are allowed to compile |
| 345 | // against unstable APIs. |
Cole Faust | b1fc07e | 2024-09-05 11:37:57 -0700 | [diff] [blame^] | 346 | removeAll(modules, non_updatable_modules) |
Nikita Ioffe | d3f0a6f | 2022-11-15 11:26:53 +0000 | [diff] [blame] | 347 | // First create updatable-framework-module-impl, which contains all updatable modules. |
| 348 | // This module compiles against module_lib SDK. |
| 349 | { |
Cole Faust | b1fc07e | 2024-09-05 11:37:57 -0700 | [diff] [blame^] | 350 | transformConfigurableArray(modules, "", ".impl") |
Nikita Ioffe | d3f0a6f | 2022-11-15 11:26:53 +0000 | [diff] [blame] | 351 | props := libraryProps{} |
| 352 | props.Name = proptools.StringPtr("updatable-framework-module-impl") |
Cole Faust | b1fc07e | 2024-09-05 11:37:57 -0700 | [diff] [blame^] | 353 | props.Static_libs = modules |
Nikita Ioffe | d3f0a6f | 2022-11-15 11:26:53 +0000 | [diff] [blame] | 354 | props.Sdk_version = proptools.StringPtr("module_current") |
| 355 | props.Visibility = []string{"//frameworks/base"} |
| 356 | ctx.CreateModule(java.LibraryFactory, &props) |
| 357 | } |
| 358 | |
| 359 | // Now create all-framework-module-impl, which contains updatable-framework-module-impl |
| 360 | // and all non-updatable modules. This module compiles against hidden APIs. |
| 361 | { |
Cole Faust | b1fc07e | 2024-09-05 11:37:57 -0700 | [diff] [blame^] | 362 | static_libs := transformArray(non_updatable_modules, "", ".impl") |
| 363 | static_libs = append(static_libs, "updatable-framework-module-impl") |
Nikita Ioffe | d3f0a6f | 2022-11-15 11:26:53 +0000 | [diff] [blame] | 364 | props := libraryProps{} |
| 365 | props.Name = proptools.StringPtr("all-framework-module-impl") |
Cole Faust | b1fc07e | 2024-09-05 11:37:57 -0700 | [diff] [blame^] | 366 | props.Static_libs = proptools.NewSimpleConfigurable(static_libs) |
Nikita Ioffe | d3f0a6f | 2022-11-15 11:26:53 +0000 | [diff] [blame] | 367 | props.Sdk_version = proptools.StringPtr("core_platform") |
| 368 | props.Visibility = []string{"//frameworks/base"} |
| 369 | ctx.CreateModule(java.LibraryFactory, &props) |
| 370 | } |
Anton Hansson | 95e89a8 | 2022-01-28 11:31:50 +0000 | [diff] [blame] | 371 | } |
| 372 | |
Cole Faust | b1fc07e | 2024-09-05 11:37:57 -0700 | [diff] [blame^] | 373 | func createMergedFrameworkModuleLibExportableStubs(ctx android.LoadHookContext, modules proptools.Configurable[[]string]) { |
| 374 | modules = modules.Clone() |
Jihoon Kang | 059b949 | 2023-12-29 00:40:34 +0000 | [diff] [blame] | 375 | // The user of this module compiles against the "core" SDK and against non-updatable modules, |
| 376 | // so remove to avoid dupes. |
Cole Faust | b1fc07e | 2024-09-05 11:37:57 -0700 | [diff] [blame^] | 377 | removeAll(modules, core_libraries_modules) |
| 378 | removeAll(modules, non_updatable_modules) |
| 379 | transformConfigurableArray(modules, "", ".stubs.exportable.module_lib") |
Jihoon Kang | 059b949 | 2023-12-29 00:40:34 +0000 | [diff] [blame] | 380 | props := libraryProps{} |
| 381 | props.Name = proptools.StringPtr("framework-updatable-stubs-module_libs_api-exportable") |
Cole Faust | b1fc07e | 2024-09-05 11:37:57 -0700 | [diff] [blame^] | 382 | props.Static_libs = modules |
Jihoon Kang | 059b949 | 2023-12-29 00:40:34 +0000 | [diff] [blame] | 383 | props.Sdk_version = proptools.StringPtr("module_current") |
| 384 | props.Visibility = []string{"//frameworks/base"} |
Jihoon Kang | a7073b5 | 2024-02-12 23:18:52 +0000 | [diff] [blame] | 385 | props.Is_stubs_module = proptools.BoolPtr(true) |
Jihoon Kang | 059b949 | 2023-12-29 00:40:34 +0000 | [diff] [blame] | 386 | ctx.CreateModule(java.LibraryFactory, &props) |
| 387 | } |
| 388 | |
Cole Faust | b1fc07e | 2024-09-05 11:37:57 -0700 | [diff] [blame^] | 389 | func createMergedFrameworkModuleLibStubs(ctx android.LoadHookContext, modules proptools.Configurable[[]string]) { |
| 390 | modules = modules.Clone() |
Mark White | 3cc5e00 | 2023-08-07 11:18:09 +0000 | [diff] [blame] | 391 | // The user of this module compiles against the "core" SDK and against non-updatable modules, |
| 392 | // so remove to avoid dupes. |
Cole Faust | b1fc07e | 2024-09-05 11:37:57 -0700 | [diff] [blame^] | 393 | removeAll(modules, core_libraries_modules) |
| 394 | removeAll(modules, non_updatable_modules) |
| 395 | transformConfigurableArray(modules, "", ".stubs.module_lib") |
Anton Hansson | cb00f94 | 2022-01-13 09:45:12 +0000 | [diff] [blame] | 396 | props := libraryProps{} |
| 397 | props.Name = proptools.StringPtr("framework-updatable-stubs-module_libs_api") |
Cole Faust | b1fc07e | 2024-09-05 11:37:57 -0700 | [diff] [blame^] | 398 | props.Static_libs = modules |
Anton Hansson | cb00f94 | 2022-01-13 09:45:12 +0000 | [diff] [blame] | 399 | props.Sdk_version = proptools.StringPtr("module_current") |
| 400 | props.Visibility = []string{"//frameworks/base"} |
Jihoon Kang | a7073b5 | 2024-02-12 23:18:52 +0000 | [diff] [blame] | 401 | props.Is_stubs_module = proptools.BoolPtr(true) |
Anton Hansson | cb00f94 | 2022-01-13 09:45:12 +0000 | [diff] [blame] | 402 | ctx.CreateModule(java.LibraryFactory, &props) |
| 403 | } |
| 404 | |
Cole Faust | b1fc07e | 2024-09-05 11:37:57 -0700 | [diff] [blame^] | 405 | func createMergedFrameworkSystemServerExportableStubs(ctx android.LoadHookContext, bootclasspath, system_server_classpath proptools.Configurable[[]string]) { |
Paul Duffin | fb5e07d | 2024-05-02 14:51:41 +0100 | [diff] [blame] | 406 | // The user of this module compiles against the "core" SDK and against non-updatable bootclasspathModules, |
| 407 | // so remove to avoid dupes. |
Cole Faust | b1fc07e | 2024-09-05 11:37:57 -0700 | [diff] [blame^] | 408 | bootclasspathModules := bootclasspath.Clone() |
| 409 | removeAll(bootclasspathModules, core_libraries_modules) |
| 410 | removeAll(bootclasspathModules, non_updatable_modules) |
| 411 | transformConfigurableArray(bootclasspathModules, "", ".stubs.exportable.module_lib") |
| 412 | |
| 413 | system_server_classpath = system_server_classpath.Clone() |
| 414 | transformConfigurableArray(system_server_classpath, "", ".stubs.exportable.system_server") |
| 415 | |
| 416 | // Include all the module-lib APIs from the bootclasspath libraries. |
| 417 | // Then add all the system-server APIs from the service-* libraries. |
| 418 | bootclasspathModules.Append(system_server_classpath) |
| 419 | |
Paul Duffin | fb5e07d | 2024-05-02 14:51:41 +0100 | [diff] [blame] | 420 | props := libraryProps{} |
| 421 | props.Name = proptools.StringPtr("framework-updatable-stubs-system_server_api-exportable") |
Cole Faust | b1fc07e | 2024-09-05 11:37:57 -0700 | [diff] [blame^] | 422 | props.Static_libs = bootclasspathModules |
Paul Duffin | fb5e07d | 2024-05-02 14:51:41 +0100 | [diff] [blame] | 423 | props.Sdk_version = proptools.StringPtr("system_server_current") |
| 424 | props.Visibility = []string{"//frameworks/base"} |
| 425 | props.Is_stubs_module = proptools.BoolPtr(true) |
| 426 | ctx.CreateModule(java.LibraryFactory, &props) |
| 427 | } |
| 428 | |
Cole Faust | b1fc07e | 2024-09-05 11:37:57 -0700 | [diff] [blame^] | 429 | func createPublicStubsSourceFilegroup(ctx android.LoadHookContext, modules proptools.Configurable[[]string]) { |
Anton Hansson | 4468d7c | 2022-01-14 12:10:01 +0000 | [diff] [blame] | 430 | props := fgProps{} |
| 431 | props.Name = proptools.StringPtr("all-modules-public-stubs-source") |
| 432 | props.Srcs = createSrcs(modules, "{.public.stubs.source}") |
| 433 | props.Visibility = []string{"//frameworks/base"} |
Colin Cross | c642076 | 2023-12-07 12:38:40 -0800 | [diff] [blame] | 434 | ctx.CreateModule(android.FileGroupFactory, &props) |
Anton Hansson | 4468d7c | 2022-01-14 12:10:01 +0000 | [diff] [blame] | 435 | } |
| 436 | |
Cole Faust | b1fc07e | 2024-09-05 11:37:57 -0700 | [diff] [blame^] | 437 | func createMergedTxts( |
| 438 | ctx android.LoadHookContext, |
| 439 | bootclasspath proptools.Configurable[[]string], |
| 440 | system_server_classpath proptools.Configurable[[]string], |
| 441 | baseTxtModulePrefix string, |
| 442 | stubsTypeSuffix string, |
| 443 | doDist bool, |
| 444 | ) { |
Anton Hansson | 0860aaf | 2021-10-08 16:48:03 +0100 | [diff] [blame] | 445 | var textFiles []MergedTxtDefinition |
Anton Hansson | 16ff357 | 2022-01-11 18:36:35 +0000 | [diff] [blame] | 446 | |
Anton Hansson | 0860aaf | 2021-10-08 16:48:03 +0100 | [diff] [blame] | 447 | tagSuffix := []string{".api.txt}", ".removed-api.txt}"} |
Anton Hansson | 09a9c4e | 2022-04-08 10:59:46 +0100 | [diff] [blame] | 448 | distFilename := []string{"android.txt", "android-removed.txt"} |
Anton Hansson | 0860aaf | 2021-10-08 16:48:03 +0100 | [diff] [blame] | 449 | for i, f := range []string{"current.txt", "removed.txt"} { |
| 450 | textFiles = append(textFiles, MergedTxtDefinition{ |
Colin Cross | c642076 | 2023-12-07 12:38:40 -0800 | [diff] [blame] | 451 | TxtFilename: f, |
| 452 | DistFilename: distFilename[i], |
Jihoon Kang | 31cf274 | 2024-02-07 19:52:19 +0000 | [diff] [blame] | 453 | BaseTxt: ":" + baseTxtModulePrefix + f, |
Colin Cross | c642076 | 2023-12-07 12:38:40 -0800 | [diff] [blame] | 454 | Modules: bootclasspath, |
| 455 | ModuleTag: "{.public" + tagSuffix[i], |
| 456 | Scope: "public", |
Anton Hansson | 0860aaf | 2021-10-08 16:48:03 +0100 | [diff] [blame] | 457 | }) |
| 458 | textFiles = append(textFiles, MergedTxtDefinition{ |
Colin Cross | c642076 | 2023-12-07 12:38:40 -0800 | [diff] [blame] | 459 | TxtFilename: f, |
| 460 | DistFilename: distFilename[i], |
Jihoon Kang | 31cf274 | 2024-02-07 19:52:19 +0000 | [diff] [blame] | 461 | BaseTxt: ":" + baseTxtModulePrefix + "system-" + f, |
Colin Cross | c642076 | 2023-12-07 12:38:40 -0800 | [diff] [blame] | 462 | Modules: bootclasspath, |
| 463 | ModuleTag: "{.system" + tagSuffix[i], |
| 464 | Scope: "system", |
Anton Hansson | 0860aaf | 2021-10-08 16:48:03 +0100 | [diff] [blame] | 465 | }) |
| 466 | textFiles = append(textFiles, MergedTxtDefinition{ |
Colin Cross | c642076 | 2023-12-07 12:38:40 -0800 | [diff] [blame] | 467 | TxtFilename: f, |
| 468 | DistFilename: distFilename[i], |
Jihoon Kang | 31cf274 | 2024-02-07 19:52:19 +0000 | [diff] [blame] | 469 | BaseTxt: ":" + baseTxtModulePrefix + "module-lib-" + f, |
Colin Cross | c642076 | 2023-12-07 12:38:40 -0800 | [diff] [blame] | 470 | Modules: bootclasspath, |
| 471 | ModuleTag: "{.module-lib" + tagSuffix[i], |
| 472 | Scope: "module-lib", |
Anton Hansson | 0860aaf | 2021-10-08 16:48:03 +0100 | [diff] [blame] | 473 | }) |
| 474 | textFiles = append(textFiles, MergedTxtDefinition{ |
Colin Cross | c642076 | 2023-12-07 12:38:40 -0800 | [diff] [blame] | 475 | TxtFilename: f, |
| 476 | DistFilename: distFilename[i], |
Jihoon Kang | 31cf274 | 2024-02-07 19:52:19 +0000 | [diff] [blame] | 477 | BaseTxt: ":" + baseTxtModulePrefix + "system-server-" + f, |
Colin Cross | c642076 | 2023-12-07 12:38:40 -0800 | [diff] [blame] | 478 | Modules: system_server_classpath, |
| 479 | ModuleTag: "{.system-server" + tagSuffix[i], |
| 480 | Scope: "system-server", |
Anton Hansson | 0860aaf | 2021-10-08 16:48:03 +0100 | [diff] [blame] | 481 | }) |
| 482 | } |
| 483 | for _, txt := range textFiles { |
Jihoon Kang | 31cf274 | 2024-02-07 19:52:19 +0000 | [diff] [blame] | 484 | createMergedTxt(ctx, txt, stubsTypeSuffix, doDist) |
Anton Hansson | 0860aaf | 2021-10-08 16:48:03 +0100 | [diff] [blame] | 485 | } |
| 486 | } |
| 487 | |
| 488 | func (a *CombinedApis) createInternalModules(ctx android.LoadHookContext) { |
Cole Faust | b1fc07e | 2024-09-05 11:37:57 -0700 | [diff] [blame^] | 489 | bootclasspath := a.properties.Bootclasspath.Clone() |
| 490 | system_server_classpath := a.properties.System_server_classpath.Clone() |
Anton Hansson | 07a1295 | 2022-01-12 17:28:39 +0000 | [diff] [blame] | 491 | if ctx.Config().VendorConfig("ANDROID").Bool("include_nonpublic_framework_api") { |
Cole Faust | b1fc07e | 2024-09-05 11:37:57 -0700 | [diff] [blame^] | 492 | bootclasspath.AppendSimpleValue(a.properties.Conditional_bootclasspath) |
Anton Hansson | 07a1295 | 2022-01-12 17:28:39 +0000 | [diff] [blame] | 493 | } |
Jihoon Kang | 31cf274 | 2024-02-07 19:52:19 +0000 | [diff] [blame] | 494 | createMergedTxts(ctx, bootclasspath, system_server_classpath, "non-updatable-", "-", false) |
| 495 | createMergedTxts(ctx, bootclasspath, system_server_classpath, "non-updatable-exportable-", "-exportable-", true) |
Anton Hansson | 0860aaf | 2021-10-08 16:48:03 +0100 | [diff] [blame] | 496 | |
Anton Hansson | c6e9d2f | 2022-01-25 15:53:43 +0000 | [diff] [blame] | 497 | createMergedPublicStubs(ctx, bootclasspath) |
| 498 | createMergedSystemStubs(ctx, bootclasspath) |
Nikita Ioffe | 5593fbb | 2022-12-01 14:52:34 +0000 | [diff] [blame] | 499 | createMergedTestStubsForNonUpdatableModules(ctx) |
Anton Hansson | 95e89a8 | 2022-01-28 11:31:50 +0000 | [diff] [blame] | 500 | createMergedFrameworkModuleLibStubs(ctx, bootclasspath) |
| 501 | createMergedFrameworkImpl(ctx, bootclasspath) |
Anton Hansson | cb00f94 | 2022-01-13 09:45:12 +0000 | [diff] [blame] | 502 | |
Jihoon Kang | 059b949 | 2023-12-29 00:40:34 +0000 | [diff] [blame] | 503 | createMergedPublicExportableStubs(ctx, bootclasspath) |
| 504 | createMergedSystemExportableStubs(ctx, bootclasspath) |
| 505 | createMergedTestExportableStubsForNonUpdatableModules(ctx) |
| 506 | createMergedFrameworkModuleLibExportableStubs(ctx, bootclasspath) |
Paul Duffin | fb5e07d | 2024-05-02 14:51:41 +0100 | [diff] [blame] | 507 | createMergedFrameworkSystemServerExportableStubs(ctx, bootclasspath, system_server_classpath) |
Jihoon Kang | 059b949 | 2023-12-29 00:40:34 +0000 | [diff] [blame] | 508 | |
Cole Faust | dcda370 | 2022-10-04 14:46:35 -0700 | [diff] [blame] | 509 | createMergedAnnotationsFilegroups(ctx, bootclasspath, system_server_classpath) |
Anton Hansson | cc18e03 | 2022-01-12 14:45:22 +0000 | [diff] [blame] | 510 | |
Anton Hansson | 4468d7c | 2022-01-14 12:10:01 +0000 | [diff] [blame] | 511 | createPublicStubsSourceFilegroup(ctx, bootclasspath) |
Anton Hansson | 0860aaf | 2021-10-08 16:48:03 +0100 | [diff] [blame] | 512 | } |
| 513 | |
| 514 | func combinedApisModuleFactory() android.Module { |
| 515 | module := &CombinedApis{} |
| 516 | module.AddProperties(&module.properties) |
| 517 | android.InitAndroidModule(module) |
| 518 | android.AddLoadHook(module, func(ctx android.LoadHookContext) { module.createInternalModules(ctx) }) |
| 519 | return module |
| 520 | } |
Anton Hansson | fd31645 | 2022-01-14 11:15:52 +0000 | [diff] [blame] | 521 | |
| 522 | // Various utility methods below. |
| 523 | |
| 524 | // Creates an array of ":<m><tag>" for each m in <modules>. |
Cole Faust | b1fc07e | 2024-09-05 11:37:57 -0700 | [diff] [blame^] | 525 | func createSrcs(modules proptools.Configurable[[]string], tag string) proptools.Configurable[[]string] { |
| 526 | result := modules.Clone() |
| 527 | transformConfigurableArray(result, ":", tag) |
| 528 | return result |
Anton Hansson | fd31645 | 2022-01-14 11:15:52 +0000 | [diff] [blame] | 529 | } |
| 530 | |
| 531 | // Creates an array of "<prefix><m><suffix>", for each m in <modules>. |
| 532 | func transformArray(modules []string, prefix, suffix string) []string { |
| 533 | a := make([]string, 0, len(modules)) |
| 534 | for _, module := range modules { |
| 535 | a = append(a, prefix+module+suffix) |
| 536 | } |
| 537 | return a |
| 538 | } |
| 539 | |
Cole Faust | b1fc07e | 2024-09-05 11:37:57 -0700 | [diff] [blame^] | 540 | // Creates an array of "<prefix><m><suffix>", for each m in <modules>. |
| 541 | func transformConfigurableArray(modules proptools.Configurable[[]string], prefix, suffix string) { |
| 542 | modules.AddPostProcessor(func(s []string) []string { |
| 543 | return transformArray(s, prefix, suffix) |
| 544 | }) |
| 545 | } |
| 546 | |
| 547 | func removeAll(s proptools.Configurable[[]string], vs []string) { |
| 548 | s.AddPostProcessor(func(s []string) []string { |
| 549 | a := make([]string, 0, len(s)) |
| 550 | for _, module := range s { |
| 551 | if !slices.Contains(vs, module) { |
| 552 | a = append(a, module) |
| 553 | } |
| 554 | } |
| 555 | return a |
| 556 | }) |
Anton Hansson | fd31645 | 2022-01-14 11:15:52 +0000 | [diff] [blame] | 557 | } |
| 558 | |
| 559 | func remove(s []string, v string) []string { |
| 560 | s2 := make([]string, 0, len(s)) |
| 561 | for _, sv := range s { |
| 562 | if sv != v { |
| 563 | s2 = append(s2, sv) |
| 564 | } |
| 565 | } |
| 566 | return s2 |
| 567 | } |