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" |
satayev | 95e9c5b | 2021-04-29 11:50:26 +0100 | [diff] [blame] | 20 | ) |
| 21 | |
| 22 | func init() { |
| 23 | registerSystemserverClasspathBuildComponents(android.InitRegistrationContext) |
| 24 | } |
| 25 | |
| 26 | func registerSystemserverClasspathBuildComponents(ctx android.RegistrationContext) { |
satayev | 95e9c5b | 2021-04-29 11:50:26 +0100 | [diff] [blame] | 27 | ctx.RegisterModuleType("platform_systemserverclasspath", platformSystemServerClasspathFactory) |
satayev | aa86bac | 2021-05-13 19:01:52 +0100 | [diff] [blame] | 28 | ctx.RegisterModuleType("systemserverclasspath_fragment", systemServerClasspathFactory) |
satayev | 95e9c5b | 2021-04-29 11:50:26 +0100 | [diff] [blame] | 29 | } |
| 30 | |
| 31 | type platformSystemServerClasspathModule struct { |
| 32 | android.ModuleBase |
| 33 | |
| 34 | ClasspathFragmentBase |
| 35 | } |
| 36 | |
| 37 | func platformSystemServerClasspathFactory() android.Module { |
| 38 | m := &platformSystemServerClasspathModule{} |
| 39 | initClasspathFragment(m, SYSTEMSERVERCLASSPATH) |
| 40 | android.InitAndroidArchModule(m, android.DeviceSupported, android.MultilibCommon) |
| 41 | return m |
| 42 | } |
| 43 | |
satayev | aa86bac | 2021-05-13 19:01:52 +0100 | [diff] [blame] | 44 | func (p *platformSystemServerClasspathModule) AndroidMkEntries() (entries []android.AndroidMkEntries) { |
| 45 | return p.classpathFragmentBase().androidMkEntries() |
satayev | 95e9c5b | 2021-04-29 11:50:26 +0100 | [diff] [blame] | 46 | } |
| 47 | |
satayev | aa86bac | 2021-05-13 19:01:52 +0100 | [diff] [blame] | 48 | func (p *platformSystemServerClasspathModule) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
| 49 | configuredJars := configuredJarListToClasspathJars(ctx, p.ClasspathFragmentToConfiguredJarList(ctx), p.classpathType) |
| 50 | p.classpathFragmentBase().generateClasspathProtoBuildActions(ctx, configuredJars) |
satayev | 013485b | 2021-05-06 23:38:10 +0100 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | var platformSystemServerClasspathKey = android.NewOnceKey("platform_systemserverclasspath") |
| 54 | |
satayev | aa86bac | 2021-05-13 19:01:52 +0100 | [diff] [blame] | 55 | func (p *platformSystemServerClasspathModule) ClasspathFragmentToConfiguredJarList(ctx android.ModuleContext) android.ConfiguredJarList { |
satayev | 013485b | 2021-05-06 23:38:10 +0100 | [diff] [blame] | 56 | return ctx.Config().Once(platformSystemServerClasspathKey, func() interface{} { |
| 57 | global := dexpreopt.GetGlobalConfig(ctx) |
| 58 | |
| 59 | jars := global.SystemServerJars |
| 60 | |
| 61 | // TODO(satayev): split apex jars into separate configs. |
| 62 | for i := 0; i < global.UpdatableSystemServerJars.Len(); i++ { |
| 63 | jars = jars.Append(global.UpdatableSystemServerJars.Apex(i), global.UpdatableSystemServerJars.Jar(i)) |
| 64 | } |
| 65 | return jars |
| 66 | }).(android.ConfiguredJarList) |
satayev | 95e9c5b | 2021-04-29 11:50:26 +0100 | [diff] [blame] | 67 | } |
satayev | aa86bac | 2021-05-13 19:01:52 +0100 | [diff] [blame] | 68 | |
| 69 | type systemServerClasspathModule struct { |
| 70 | android.ModuleBase |
| 71 | |
| 72 | ClasspathFragmentBase |
| 73 | } |
| 74 | |
| 75 | func systemServerClasspathFactory() android.Module { |
| 76 | m := &systemServerClasspathModule{} |
| 77 | initClasspathFragment(m, SYSTEMSERVERCLASSPATH) |
| 78 | android.InitAndroidArchModule(m, android.DeviceSupported, android.MultilibCommon) |
| 79 | return m |
| 80 | } |
| 81 | |
| 82 | func (s *systemServerClasspathModule) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
| 83 | s.classpathFragmentBase().generateClasspathProtoBuildActions(ctx, configuredJarListToClasspathJars(ctx, s.ClasspathFragmentToConfiguredJarList(ctx))) |
| 84 | } |
| 85 | |
| 86 | func (s *systemServerClasspathModule) ClasspathFragmentToConfiguredJarList(ctx android.ModuleContext) android.ConfiguredJarList { |
| 87 | // TODO(satayev): populate with actual content |
| 88 | return android.EmptyConfiguredJarList() |
| 89 | } |