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