blob: 82cdb89269d61195c55ef8ffd23ba824a3150aee [file] [log] [blame]
satayev95e9c5b2021-04-29 11:50:26 +01001// 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
15package java
16
17import (
18 "android/soong/android"
satayev013485b2021-05-06 23:38:10 +010019 "android/soong/dexpreopt"
satayev95e9c5b2021-04-29 11:50:26 +010020)
21
22func init() {
23 registerSystemserverClasspathBuildComponents(android.InitRegistrationContext)
24}
25
26func registerSystemserverClasspathBuildComponents(ctx android.RegistrationContext) {
27 // TODO(satayev): add systemserver_classpath_fragment module
28 ctx.RegisterModuleType("platform_systemserverclasspath", platformSystemServerClasspathFactory)
29}
30
31type platformSystemServerClasspathModule struct {
32 android.ModuleBase
33
34 ClasspathFragmentBase
35}
36
37func platformSystemServerClasspathFactory() android.Module {
38 m := &platformSystemServerClasspathModule{}
39 initClasspathFragment(m, SYSTEMSERVERCLASSPATH)
40 android.InitAndroidArchModule(m, android.DeviceSupported, android.MultilibCommon)
41 return m
42}
43
44func (b *platformSystemServerClasspathModule) AndroidMkEntries() (entries []android.AndroidMkEntries) {
45 return b.classpathFragmentBase().androidMkEntries()
46}
47
48func (b *platformSystemServerClasspathModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
satayev013485b2021-05-06 23:38:10 +010049 configuredJars := configuredJarListToClasspathJars(ctx, b.ClasspathFragmentToConfiguredJarList(ctx), b.classpathType)
50 b.classpathFragmentBase().generateClasspathProtoBuildActions(ctx, configuredJars)
51}
52
53var platformSystemServerClasspathKey = android.NewOnceKey("platform_systemserverclasspath")
54
55func (b *platformSystemServerClasspathModule) ClasspathFragmentToConfiguredJarList(ctx android.ModuleContext) android.ConfiguredJarList {
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)
satayev95e9c5b2021-04-29 11:50:26 +010067}