satayev | 95e9c5b | 2021-04-29 11:50:26 +0100 | [diff] [blame] | 1 | // Copyright 2021 Google Inc. All rights reserved. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | package java |
| 16 | |
| 17 | import ( |
| 18 | "android/soong/android" |
satayev | 013485b | 2021-05-06 23:38:10 +0100 | [diff] [blame] | 19 | "android/soong/dexpreopt" |
Colin Cross | c33e521 | 2021-05-25 18:16:02 -0700 | [diff] [blame] | 20 | |
satayev | 9366a05 | 2021-05-17 21:13:44 +0100 | [diff] [blame] | 21 | "github.com/google/blueprint" |
satayev | 95e9c5b | 2021-04-29 11:50:26 +0100 | [diff] [blame] | 22 | ) |
| 23 | |
| 24 | func init() { |
| 25 | registerSystemserverClasspathBuildComponents(android.InitRegistrationContext) |
Jiakai Zhang | a8d8660 | 2021-09-26 09:02:17 +0000 | [diff] [blame] | 26 | |
Paul Duffin | 4e7d1c4 | 2022-05-13 13:12:19 +0000 | [diff] [blame] | 27 | android.RegisterSdkMemberType(SystemServerClasspathFragmentSdkMemberType) |
satayev | 95e9c5b | 2021-04-29 11:50:26 +0100 | [diff] [blame] | 28 | } |
| 29 | |
| 30 | func registerSystemserverClasspathBuildComponents(ctx android.RegistrationContext) { |
satayev | 95e9c5b | 2021-04-29 11:50:26 +0100 | [diff] [blame] | 31 | ctx.RegisterModuleType("platform_systemserverclasspath", platformSystemServerClasspathFactory) |
satayev | aa86bac | 2021-05-13 19:01:52 +0100 | [diff] [blame] | 32 | ctx.RegisterModuleType("systemserverclasspath_fragment", systemServerClasspathFactory) |
Jiakai Zhang | c986427 | 2021-09-26 03:52:19 +0000 | [diff] [blame] | 33 | ctx.RegisterModuleType("prebuilt_systemserverclasspath_fragment", prebuiltSystemServerClasspathModuleFactory) |
satayev | 95e9c5b | 2021-04-29 11:50:26 +0100 | [diff] [blame] | 34 | } |
| 35 | |
Paul Duffin | 4e7d1c4 | 2022-05-13 13:12:19 +0000 | [diff] [blame] | 36 | var SystemServerClasspathFragmentSdkMemberType = &systemServerClasspathFragmentMemberType{ |
| 37 | SdkMemberTypeBase: android.SdkMemberTypeBase{ |
| 38 | PropertyName: "systemserverclasspath_fragments", |
| 39 | SupportsSdk: true, |
| 40 | |
| 41 | // Support for adding systemserverclasspath_fragments to the sdk snapshot was only added in |
| 42 | // Tiramisu. |
| 43 | SupportedBuildReleaseSpecification: "Tiramisu+", |
| 44 | }, |
| 45 | } |
| 46 | |
satayev | 95e9c5b | 2021-04-29 11:50:26 +0100 | [diff] [blame] | 47 | type platformSystemServerClasspathModule struct { |
| 48 | android.ModuleBase |
| 49 | |
| 50 | ClasspathFragmentBase |
| 51 | } |
| 52 | |
| 53 | func platformSystemServerClasspathFactory() android.Module { |
| 54 | m := &platformSystemServerClasspathModule{} |
| 55 | initClasspathFragment(m, SYSTEMSERVERCLASSPATH) |
| 56 | android.InitAndroidArchModule(m, android.DeviceSupported, android.MultilibCommon) |
| 57 | return m |
| 58 | } |
| 59 | |
satayev | aa86bac | 2021-05-13 19:01:52 +0100 | [diff] [blame] | 60 | func (p *platformSystemServerClasspathModule) AndroidMkEntries() (entries []android.AndroidMkEntries) { |
| 61 | return p.classpathFragmentBase().androidMkEntries() |
satayev | 95e9c5b | 2021-04-29 11:50:26 +0100 | [diff] [blame] | 62 | } |
| 63 | |
satayev | aa86bac | 2021-05-13 19:01:52 +0100 | [diff] [blame] | 64 | func (p *platformSystemServerClasspathModule) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
satayev | b309050 | 2021-06-15 17:49:10 +0100 | [diff] [blame] | 65 | configuredJars := p.configuredJars(ctx) |
| 66 | classpathJars := configuredJarListToClasspathJars(ctx, configuredJars, p.classpathType) |
Jiakai Zhang | cee9e19 | 2021-10-29 19:46:45 +0000 | [diff] [blame] | 67 | standaloneConfiguredJars := p.standaloneConfiguredJars(ctx) |
| 68 | standaloneClasspathJars := configuredJarListToClasspathJars(ctx, standaloneConfiguredJars, STANDALONE_SYSTEMSERVER_JARS) |
Jiakai Zhang | 389a647 | 2021-12-14 18:54:06 +0000 | [diff] [blame] | 69 | configuredJars = configuredJars.AppendList(&standaloneConfiguredJars) |
Jiakai Zhang | cee9e19 | 2021-10-29 19:46:45 +0000 | [diff] [blame] | 70 | classpathJars = append(classpathJars, standaloneClasspathJars...) |
satayev | b309050 | 2021-06-15 17:49:10 +0100 | [diff] [blame] | 71 | p.classpathFragmentBase().generateClasspathProtoBuildActions(ctx, configuredJars, classpathJars) |
satayev | 013485b | 2021-05-06 23:38:10 +0100 | [diff] [blame] | 72 | } |
| 73 | |
satayev | 142ed27 | 2021-06-15 16:21:17 +0100 | [diff] [blame] | 74 | func (p *platformSystemServerClasspathModule) configuredJars(ctx android.ModuleContext) android.ConfiguredJarList { |
satayev | b309050 | 2021-06-15 17:49:10 +0100 | [diff] [blame] | 75 | // TODO(satayev): include any apex jars that don't populate their classpath proto config. |
| 76 | return dexpreopt.GetGlobalConfig(ctx).SystemServerJars |
satayev | 95e9c5b | 2021-04-29 11:50:26 +0100 | [diff] [blame] | 77 | } |
satayev | aa86bac | 2021-05-13 19:01:52 +0100 | [diff] [blame] | 78 | |
Jiakai Zhang | cee9e19 | 2021-10-29 19:46:45 +0000 | [diff] [blame] | 79 | func (p *platformSystemServerClasspathModule) standaloneConfiguredJars(ctx android.ModuleContext) android.ConfiguredJarList { |
| 80 | return dexpreopt.GetGlobalConfig(ctx).StandaloneSystemServerJars |
| 81 | } |
| 82 | |
satayev | 333a173 | 2021-05-17 21:35:26 +0100 | [diff] [blame] | 83 | type SystemServerClasspathModule struct { |
satayev | aa86bac | 2021-05-13 19:01:52 +0100 | [diff] [blame] | 84 | android.ModuleBase |
satayev | 333a173 | 2021-05-17 21:35:26 +0100 | [diff] [blame] | 85 | android.ApexModuleBase |
Jiakai Zhang | a8d8660 | 2021-09-26 09:02:17 +0000 | [diff] [blame] | 86 | android.SdkBase |
satayev | aa86bac | 2021-05-13 19:01:52 +0100 | [diff] [blame] | 87 | |
| 88 | ClasspathFragmentBase |
satayev | 9366a05 | 2021-05-17 21:13:44 +0100 | [diff] [blame] | 89 | |
| 90 | properties systemServerClasspathFragmentProperties |
bralee | b0c1f0c | 2021-06-07 22:49:13 +0800 | [diff] [blame] | 91 | |
| 92 | // Collect the module directory for IDE info in java/jdeps.go. |
| 93 | modulePaths []string |
satayev | 9366a05 | 2021-05-17 21:13:44 +0100 | [diff] [blame] | 94 | } |
| 95 | |
satayev | 333a173 | 2021-05-17 21:35:26 +0100 | [diff] [blame] | 96 | func (s *SystemServerClasspathModule) ShouldSupportSdkVersion(ctx android.BaseModuleContext, sdkVersion android.ApiLevel) error { |
| 97 | return nil |
| 98 | } |
| 99 | |
satayev | 9366a05 | 2021-05-17 21:13:44 +0100 | [diff] [blame] | 100 | type systemServerClasspathFragmentProperties struct { |
Jiakai Zhang | cee9e19 | 2021-10-29 19:46:45 +0000 | [diff] [blame] | 101 | // List of system_server classpath jars, could be either java_library, or java_sdk_library. |
satayev | 9366a05 | 2021-05-17 21:13:44 +0100 | [diff] [blame] | 102 | // |
| 103 | // The order of this list matters as it is the order that is used in the SYSTEMSERVERCLASSPATH. |
| 104 | Contents []string |
Jiakai Zhang | cee9e19 | 2021-10-29 19:46:45 +0000 | [diff] [blame] | 105 | |
| 106 | // List of jars that system_server loads dynamically using separate classloaders. |
| 107 | // |
| 108 | // The order does not matter. |
| 109 | Standalone_contents []string |
satayev | aa86bac | 2021-05-13 19:01:52 +0100 | [diff] [blame] | 110 | } |
| 111 | |
| 112 | func systemServerClasspathFactory() android.Module { |
satayev | 333a173 | 2021-05-17 21:35:26 +0100 | [diff] [blame] | 113 | m := &SystemServerClasspathModule{} |
satayev | 9366a05 | 2021-05-17 21:13:44 +0100 | [diff] [blame] | 114 | m.AddProperties(&m.properties) |
satayev | 333a173 | 2021-05-17 21:35:26 +0100 | [diff] [blame] | 115 | android.InitApexModule(m) |
Jiakai Zhang | a8d8660 | 2021-09-26 09:02:17 +0000 | [diff] [blame] | 116 | android.InitSdkAwareModule(m) |
satayev | aa86bac | 2021-05-13 19:01:52 +0100 | [diff] [blame] | 117 | initClasspathFragment(m, SYSTEMSERVERCLASSPATH) |
| 118 | android.InitAndroidArchModule(m, android.DeviceSupported, android.MultilibCommon) |
| 119 | return m |
| 120 | } |
| 121 | |
satayev | 333a173 | 2021-05-17 21:35:26 +0100 | [diff] [blame] | 122 | func (s *SystemServerClasspathModule) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
Jiakai Zhang | cee9e19 | 2021-10-29 19:46:45 +0000 | [diff] [blame] | 123 | if len(s.properties.Contents) == 0 && len(s.properties.Standalone_contents) == 0 { |
| 124 | ctx.PropertyErrorf("contents", "Either contents or standalone_contents needs to be non-empty") |
satayev | 9366a05 | 2021-05-17 21:13:44 +0100 | [diff] [blame] | 125 | } |
| 126 | |
satayev | b309050 | 2021-06-15 17:49:10 +0100 | [diff] [blame] | 127 | configuredJars := s.configuredJars(ctx) |
| 128 | classpathJars := configuredJarListToClasspathJars(ctx, configuredJars, s.classpathType) |
Jiakai Zhang | cee9e19 | 2021-10-29 19:46:45 +0000 | [diff] [blame] | 129 | standaloneConfiguredJars := s.standaloneConfiguredJars(ctx) |
| 130 | standaloneClasspathJars := configuredJarListToClasspathJars(ctx, standaloneConfiguredJars, STANDALONE_SYSTEMSERVER_JARS) |
Jiakai Zhang | 389a647 | 2021-12-14 18:54:06 +0000 | [diff] [blame] | 131 | configuredJars = configuredJars.AppendList(&standaloneConfiguredJars) |
Jiakai Zhang | cee9e19 | 2021-10-29 19:46:45 +0000 | [diff] [blame] | 132 | classpathJars = append(classpathJars, standaloneClasspathJars...) |
satayev | b309050 | 2021-06-15 17:49:10 +0100 | [diff] [blame] | 133 | s.classpathFragmentBase().generateClasspathProtoBuildActions(ctx, configuredJars, classpathJars) |
bralee | b0c1f0c | 2021-06-07 22:49:13 +0800 | [diff] [blame] | 134 | |
| 135 | // Collect the module directory for IDE info in java/jdeps.go. |
| 136 | s.modulePaths = append(s.modulePaths, ctx.ModuleDir()) |
satayev | aa86bac | 2021-05-13 19:01:52 +0100 | [diff] [blame] | 137 | } |
| 138 | |
satayev | 142ed27 | 2021-06-15 16:21:17 +0100 | [diff] [blame] | 139 | func (s *SystemServerClasspathModule) configuredJars(ctx android.ModuleContext) android.ConfiguredJarList { |
satayev | 703c67a | 2021-05-20 21:33:41 +0100 | [diff] [blame] | 140 | global := dexpreopt.GetGlobalConfig(ctx) |
| 141 | |
satayev | d604b21 | 2021-07-21 14:23:52 +0100 | [diff] [blame] | 142 | possibleUpdatableModules := gatherPossibleApexModuleNamesAndStems(ctx, s.properties.Contents, systemServerClasspathFragmentContentDepTag) |
satayev | d34eb0c | 2021-08-06 13:20:28 +0100 | [diff] [blame] | 143 | jars, unknown := global.ApexSystemServerJars.Filter(possibleUpdatableModules) |
| 144 | // TODO(satayev): remove geotz ssc_fragment, since geotz is not part of SSCP anymore. |
| 145 | _, unknown = android.RemoveFromList("geotz", unknown) |
Keun young Park | d64ab23 | 2021-10-18 08:42:23 -0700 | [diff] [blame] | 146 | // This module only exists in car products. |
| 147 | // So ignore it even if it is not in PRODUCT_APEX_SYSTEM_SERVER_JARS. |
| 148 | // TODO(b/203233647): Add better mechanism to make it optional. |
| 149 | _, unknown = android.RemoveFromList("car-frameworks-service-module", unknown) |
Samiul Islam | 7b385c5 | 2021-10-11 22:47:13 +0100 | [diff] [blame] | 150 | |
Alan Stokes | bcd567e | 2021-11-12 15:21:43 +0000 | [diff] [blame] | 151 | // This module is optional, so it is not present in all products. |
| 152 | // (See PRODUCT_ISOLATED_COMPILATION_ENABLED.) |
| 153 | // So ignore it even if it is not in PRODUCT_APEX_SYSTEM_SERVER_JARS. |
| 154 | // TODO(b/203233647): Add better mechanism to make it optional. |
| 155 | _, unknown = android.RemoveFromList("service-compos", unknown) |
| 156 | |
Samiul Islam | 7b385c5 | 2021-10-11 22:47:13 +0100 | [diff] [blame] | 157 | // TODO(satayev): for apex_test we want to include all contents unconditionally to classpaths |
| 158 | // config. However, any test specific jars would not be present in ApexSystemServerJars. Instead, |
| 159 | // we should check if we are creating a config for apex_test via ApexInfo and amend the values. |
| 160 | // This is an exception to support end-to-end test for ApexdUnitTests, until such support exists. |
| 161 | if android.InList("test_service-apexd", possibleUpdatableModules) { |
| 162 | jars = jars.Append("com.android.apex.test_package", "test_service-apexd") |
Paul Duffin | 458a15b | 2022-11-25 12:18:24 +0000 | [diff] [blame^] | 163 | } else if global.ApexSystemServerJars.Len() > 0 && len(unknown) > 0 { |
Samiul Islam | 7b385c5 | 2021-10-11 22:47:13 +0100 | [diff] [blame] | 164 | // For non test apexes, make sure that all contents are actually declared in make. |
Ulya Trafimovich | e5b2b49 | 2021-10-04 15:42:53 +0100 | [diff] [blame] | 165 | ctx.ModuleErrorf("%s in contents must also be declared in PRODUCT_APEX_SYSTEM_SERVER_JARS", unknown) |
satayev | d34eb0c | 2021-08-06 13:20:28 +0100 | [diff] [blame] | 166 | } |
| 167 | |
| 168 | return jars |
satayev | aa86bac | 2021-05-13 19:01:52 +0100 | [diff] [blame] | 169 | } |
satayev | 9366a05 | 2021-05-17 21:13:44 +0100 | [diff] [blame] | 170 | |
Jiakai Zhang | cee9e19 | 2021-10-29 19:46:45 +0000 | [diff] [blame] | 171 | func (s *SystemServerClasspathModule) standaloneConfiguredJars(ctx android.ModuleContext) android.ConfiguredJarList { |
| 172 | global := dexpreopt.GetGlobalConfig(ctx) |
| 173 | |
| 174 | possibleUpdatableModules := gatherPossibleApexModuleNamesAndStems(ctx, s.properties.Standalone_contents, systemServerClasspathFragmentContentDepTag) |
| 175 | jars, _ := global.ApexStandaloneSystemServerJars.Filter(possibleUpdatableModules) |
| 176 | |
| 177 | // TODO(jiakaiz): add a check to ensure that the contents are declared in make. |
| 178 | |
| 179 | return jars |
| 180 | } |
| 181 | |
satayev | 9366a05 | 2021-05-17 21:13:44 +0100 | [diff] [blame] | 182 | type systemServerClasspathFragmentContentDependencyTag struct { |
| 183 | blueprint.BaseDependencyTag |
| 184 | } |
| 185 | |
Paul Duffin | 25322e4 | 2021-09-07 14:52:48 +0100 | [diff] [blame] | 186 | // The systemserverclasspath_fragment contents must never depend on prebuilts. |
| 187 | func (systemServerClasspathFragmentContentDependencyTag) ReplaceSourceWithPrebuilt() bool { |
| 188 | return false |
| 189 | } |
| 190 | |
Jiakai Zhang | a8d8660 | 2021-09-26 09:02:17 +0000 | [diff] [blame] | 191 | // SdkMemberType causes dependencies added with this tag to be automatically added to the sdk as if |
| 192 | // they were specified using java_systemserver_libs or java_sdk_libs. |
| 193 | func (b systemServerClasspathFragmentContentDependencyTag) SdkMemberType(child android.Module) android.SdkMemberType { |
| 194 | // If the module is a java_sdk_library then treat it as if it was specified in the java_sdk_libs |
| 195 | // property, otherwise treat if it was specified in the java_systemserver_libs property. |
| 196 | if javaSdkLibrarySdkMemberType.IsInstance(child) { |
| 197 | return javaSdkLibrarySdkMemberType |
| 198 | } |
| 199 | |
| 200 | return javaSystemserverLibsSdkMemberType |
| 201 | } |
| 202 | |
| 203 | func (b systemServerClasspathFragmentContentDependencyTag) ExportMember() bool { |
| 204 | return true |
| 205 | } |
| 206 | |
Colin Cross | c33e521 | 2021-05-25 18:16:02 -0700 | [diff] [blame] | 207 | // Contents of system server fragments in an apex are considered to be directly in the apex, as if |
| 208 | // they were listed in java_libs. |
| 209 | func (systemServerClasspathFragmentContentDependencyTag) CopyDirectlyInAnyApex() {} |
| 210 | |
Jiakai Zhang | 774dd30 | 2021-09-26 03:54:25 +0000 | [diff] [blame] | 211 | // Contents of system server fragments require files from prebuilt apex files. |
| 212 | func (systemServerClasspathFragmentContentDependencyTag) RequiresFilesFromPrebuiltApex() {} |
| 213 | |
Paul Duffin | 25322e4 | 2021-09-07 14:52:48 +0100 | [diff] [blame] | 214 | var _ android.ReplaceSourceWithPrebuilt = systemServerClasspathFragmentContentDepTag |
Jiakai Zhang | a8d8660 | 2021-09-26 09:02:17 +0000 | [diff] [blame] | 215 | var _ android.SdkMemberDependencyTag = systemServerClasspathFragmentContentDepTag |
Colin Cross | c33e521 | 2021-05-25 18:16:02 -0700 | [diff] [blame] | 216 | var _ android.CopyDirectlyInAnyApexTag = systemServerClasspathFragmentContentDepTag |
Jiakai Zhang | 774dd30 | 2021-09-26 03:54:25 +0000 | [diff] [blame] | 217 | var _ android.RequiresFilesFromPrebuiltApexTag = systemServerClasspathFragmentContentDepTag |
Colin Cross | c33e521 | 2021-05-25 18:16:02 -0700 | [diff] [blame] | 218 | |
satayev | 9366a05 | 2021-05-17 21:13:44 +0100 | [diff] [blame] | 219 | // The tag used for the dependency between the systemserverclasspath_fragment module and its contents. |
| 220 | var systemServerClasspathFragmentContentDepTag = systemServerClasspathFragmentContentDependencyTag{} |
| 221 | |
| 222 | func IsSystemServerClasspathFragmentContentDepTag(tag blueprint.DependencyTag) bool { |
| 223 | return tag == systemServerClasspathFragmentContentDepTag |
| 224 | } |
| 225 | |
satayev | 333a173 | 2021-05-17 21:35:26 +0100 | [diff] [blame] | 226 | func (s *SystemServerClasspathModule) ComponentDepsMutator(ctx android.BottomUpMutatorContext) { |
satayev | 9366a05 | 2021-05-17 21:13:44 +0100 | [diff] [blame] | 227 | module := ctx.Module() |
Jiakai Zhang | c986427 | 2021-09-26 03:52:19 +0000 | [diff] [blame] | 228 | _, isSourceModule := module.(*SystemServerClasspathModule) |
Jiakai Zhang | cee9e19 | 2021-10-29 19:46:45 +0000 | [diff] [blame] | 229 | var deps []string |
| 230 | deps = append(deps, s.properties.Contents...) |
| 231 | deps = append(deps, s.properties.Standalone_contents...) |
satayev | 9366a05 | 2021-05-17 21:13:44 +0100 | [diff] [blame] | 232 | |
Jiakai Zhang | cee9e19 | 2021-10-29 19:46:45 +0000 | [diff] [blame] | 233 | for _, name := range deps { |
Jiakai Zhang | c986427 | 2021-09-26 03:52:19 +0000 | [diff] [blame] | 234 | // A systemserverclasspath_fragment must depend only on other source modules, while the |
| 235 | // prebuilt_systemserverclasspath_fragment_fragment must only depend on other prebuilt modules. |
| 236 | if !isSourceModule { |
| 237 | name = android.PrebuiltNameFromSource(name) |
| 238 | } |
satayev | 9366a05 | 2021-05-17 21:13:44 +0100 | [diff] [blame] | 239 | ctx.AddDependency(module, systemServerClasspathFragmentContentDepTag, name) |
| 240 | } |
| 241 | } |
bralee | b0c1f0c | 2021-06-07 22:49:13 +0800 | [diff] [blame] | 242 | |
| 243 | // Collect information for opening IDE project files in java/jdeps.go. |
| 244 | func (s *SystemServerClasspathModule) IDEInfo(dpInfo *android.IdeInfo) { |
| 245 | dpInfo.Deps = append(dpInfo.Deps, s.properties.Contents...) |
Jiakai Zhang | cee9e19 | 2021-10-29 19:46:45 +0000 | [diff] [blame] | 246 | dpInfo.Deps = append(dpInfo.Deps, s.properties.Standalone_contents...) |
bralee | b0c1f0c | 2021-06-07 22:49:13 +0800 | [diff] [blame] | 247 | dpInfo.Paths = append(dpInfo.Paths, s.modulePaths...) |
| 248 | } |
Jiakai Zhang | c986427 | 2021-09-26 03:52:19 +0000 | [diff] [blame] | 249 | |
Jiakai Zhang | a8d8660 | 2021-09-26 09:02:17 +0000 | [diff] [blame] | 250 | type systemServerClasspathFragmentMemberType struct { |
| 251 | android.SdkMemberTypeBase |
| 252 | } |
| 253 | |
| 254 | func (s *systemServerClasspathFragmentMemberType) AddDependencies(ctx android.SdkDependencyContext, dependencyTag blueprint.DependencyTag, names []string) { |
| 255 | ctx.AddVariationDependencies(nil, dependencyTag, names...) |
| 256 | } |
| 257 | |
| 258 | func (s *systemServerClasspathFragmentMemberType) IsInstance(module android.Module) bool { |
| 259 | _, ok := module.(*SystemServerClasspathModule) |
| 260 | return ok |
| 261 | } |
| 262 | |
| 263 | func (s *systemServerClasspathFragmentMemberType) AddPrebuiltModule(ctx android.SdkMemberContext, member android.SdkMember) android.BpModule { |
| 264 | return ctx.SnapshotBuilder().AddPrebuiltModule(member, "prebuilt_systemserverclasspath_fragment") |
| 265 | } |
| 266 | |
| 267 | func (s *systemServerClasspathFragmentMemberType) CreateVariantPropertiesStruct() android.SdkMemberProperties { |
| 268 | return &systemServerClasspathFragmentSdkMemberProperties{} |
| 269 | } |
| 270 | |
| 271 | type systemServerClasspathFragmentSdkMemberProperties struct { |
| 272 | android.SdkMemberPropertiesBase |
| 273 | |
Jiakai Zhang | cee9e19 | 2021-10-29 19:46:45 +0000 | [diff] [blame] | 274 | // List of system_server classpath jars, could be either java_library, or java_sdk_library. |
| 275 | // |
| 276 | // The order of this list matters as it is the order that is used in the SYSTEMSERVERCLASSPATH. |
Jiakai Zhang | a8d8660 | 2021-09-26 09:02:17 +0000 | [diff] [blame] | 277 | Contents []string |
Jiakai Zhang | cee9e19 | 2021-10-29 19:46:45 +0000 | [diff] [blame] | 278 | |
| 279 | // List of jars that system_server loads dynamically using separate classloaders. |
| 280 | // |
| 281 | // The order does not matter. |
| 282 | Standalone_contents []string |
Jiakai Zhang | a8d8660 | 2021-09-26 09:02:17 +0000 | [diff] [blame] | 283 | } |
| 284 | |
| 285 | func (s *systemServerClasspathFragmentSdkMemberProperties) PopulateFromVariant(ctx android.SdkMemberContext, variant android.Module) { |
| 286 | module := variant.(*SystemServerClasspathModule) |
| 287 | |
| 288 | s.Contents = module.properties.Contents |
Jiakai Zhang | cee9e19 | 2021-10-29 19:46:45 +0000 | [diff] [blame] | 289 | s.Standalone_contents = module.properties.Standalone_contents |
Jiakai Zhang | a8d8660 | 2021-09-26 09:02:17 +0000 | [diff] [blame] | 290 | } |
| 291 | |
| 292 | func (s *systemServerClasspathFragmentSdkMemberProperties) AddToPropertySet(ctx android.SdkMemberContext, propertySet android.BpPropertySet) { |
| 293 | builder := ctx.SnapshotBuilder() |
| 294 | requiredMemberDependency := builder.SdkMemberReferencePropertyTag(true) |
| 295 | |
| 296 | if len(s.Contents) > 0 { |
| 297 | propertySet.AddPropertyWithTag("contents", s.Contents, requiredMemberDependency) |
| 298 | } |
Jiakai Zhang | cee9e19 | 2021-10-29 19:46:45 +0000 | [diff] [blame] | 299 | |
| 300 | if len(s.Standalone_contents) > 0 { |
| 301 | propertySet.AddPropertyWithTag("standalone_contents", s.Standalone_contents, requiredMemberDependency) |
| 302 | } |
Jiakai Zhang | a8d8660 | 2021-09-26 09:02:17 +0000 | [diff] [blame] | 303 | } |
| 304 | |
| 305 | var _ android.SdkMemberType = (*systemServerClasspathFragmentMemberType)(nil) |
| 306 | |
Jiakai Zhang | c986427 | 2021-09-26 03:52:19 +0000 | [diff] [blame] | 307 | // A prebuilt version of the systemserverclasspath_fragment module. |
| 308 | type prebuiltSystemServerClasspathModule struct { |
| 309 | SystemServerClasspathModule |
| 310 | prebuilt android.Prebuilt |
| 311 | } |
| 312 | |
| 313 | func (module *prebuiltSystemServerClasspathModule) Prebuilt() *android.Prebuilt { |
| 314 | return &module.prebuilt |
| 315 | } |
| 316 | |
| 317 | func (module *prebuiltSystemServerClasspathModule) Name() string { |
| 318 | return module.prebuilt.Name(module.ModuleBase.Name()) |
| 319 | } |
| 320 | |
Jiakai Zhang | 774dd30 | 2021-09-26 03:54:25 +0000 | [diff] [blame] | 321 | func (module *prebuiltSystemServerClasspathModule) RequiredFilesFromPrebuiltApex(ctx android.BaseModuleContext) []string { |
| 322 | return nil |
| 323 | } |
| 324 | |
| 325 | var _ android.RequiredFilesFromPrebuiltApex = (*prebuiltSystemServerClasspathModule)(nil) |
| 326 | |
Jiakai Zhang | c986427 | 2021-09-26 03:52:19 +0000 | [diff] [blame] | 327 | func prebuiltSystemServerClasspathModuleFactory() android.Module { |
| 328 | m := &prebuiltSystemServerClasspathModule{} |
| 329 | m.AddProperties(&m.properties) |
| 330 | // This doesn't actually have any prebuilt files of its own so pass a placeholder for the srcs |
| 331 | // array. |
| 332 | android.InitPrebuiltModule(m, &[]string{"placeholder"}) |
| 333 | android.InitApexModule(m) |
Jiakai Zhang | a8d8660 | 2021-09-26 09:02:17 +0000 | [diff] [blame] | 334 | android.InitSdkAwareModule(m) |
Jiakai Zhang | c986427 | 2021-09-26 03:52:19 +0000 | [diff] [blame] | 335 | android.InitAndroidArchModule(m, android.DeviceSupported, android.MultilibCommon) |
| 336 | return m |
| 337 | } |