333a1732b1
- All contents of the fragment are added as java_lib dependencies. - Generated classpaths.proto is added into etc as required. Bug: 180105615 Test: m nothing Change-Id: I8e8e8b019c4ca2909182f205a47deffa946de6da
129 lines
4.6 KiB
Go
129 lines
4.6 KiB
Go
// Copyright 2021 Google Inc. All rights reserved.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
package java
|
|
|
|
import (
|
|
"android/soong/android"
|
|
"android/soong/dexpreopt"
|
|
"github.com/google/blueprint"
|
|
)
|
|
|
|
func init() {
|
|
registerSystemserverClasspathBuildComponents(android.InitRegistrationContext)
|
|
}
|
|
|
|
func registerSystemserverClasspathBuildComponents(ctx android.RegistrationContext) {
|
|
ctx.RegisterModuleType("platform_systemserverclasspath", platformSystemServerClasspathFactory)
|
|
ctx.RegisterModuleType("systemserverclasspath_fragment", systemServerClasspathFactory)
|
|
}
|
|
|
|
type platformSystemServerClasspathModule struct {
|
|
android.ModuleBase
|
|
|
|
ClasspathFragmentBase
|
|
}
|
|
|
|
func platformSystemServerClasspathFactory() android.Module {
|
|
m := &platformSystemServerClasspathModule{}
|
|
initClasspathFragment(m, SYSTEMSERVERCLASSPATH)
|
|
android.InitAndroidArchModule(m, android.DeviceSupported, android.MultilibCommon)
|
|
return m
|
|
}
|
|
|
|
func (p *platformSystemServerClasspathModule) AndroidMkEntries() (entries []android.AndroidMkEntries) {
|
|
return p.classpathFragmentBase().androidMkEntries()
|
|
}
|
|
|
|
func (p *platformSystemServerClasspathModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|
configuredJars := configuredJarListToClasspathJars(ctx, p.ClasspathFragmentToConfiguredJarList(ctx), p.classpathType)
|
|
p.classpathFragmentBase().generateClasspathProtoBuildActions(ctx, configuredJars)
|
|
}
|
|
|
|
var platformSystemServerClasspathKey = android.NewOnceKey("platform_systemserverclasspath")
|
|
|
|
func (p *platformSystemServerClasspathModule) ClasspathFragmentToConfiguredJarList(ctx android.ModuleContext) android.ConfiguredJarList {
|
|
return ctx.Config().Once(platformSystemServerClasspathKey, func() interface{} {
|
|
global := dexpreopt.GetGlobalConfig(ctx)
|
|
|
|
jars := global.SystemServerJars
|
|
|
|
// TODO(satayev): split apex jars into separate configs.
|
|
for i := 0; i < global.UpdatableSystemServerJars.Len(); i++ {
|
|
jars = jars.Append(global.UpdatableSystemServerJars.Apex(i), global.UpdatableSystemServerJars.Jar(i))
|
|
}
|
|
return jars
|
|
}).(android.ConfiguredJarList)
|
|
}
|
|
|
|
type SystemServerClasspathModule struct {
|
|
android.ModuleBase
|
|
android.ApexModuleBase
|
|
|
|
ClasspathFragmentBase
|
|
|
|
properties systemServerClasspathFragmentProperties
|
|
}
|
|
|
|
func (s *SystemServerClasspathModule) ShouldSupportSdkVersion(ctx android.BaseModuleContext, sdkVersion android.ApiLevel) error {
|
|
return nil
|
|
}
|
|
|
|
type systemServerClasspathFragmentProperties struct {
|
|
// The contents of this systemserverclasspath_fragment, could be either java_library, or java_sdk_library.
|
|
//
|
|
// The order of this list matters as it is the order that is used in the SYSTEMSERVERCLASSPATH.
|
|
Contents []string
|
|
}
|
|
|
|
func systemServerClasspathFactory() android.Module {
|
|
m := &SystemServerClasspathModule{}
|
|
m.AddProperties(&m.properties)
|
|
android.InitApexModule(m)
|
|
initClasspathFragment(m, SYSTEMSERVERCLASSPATH)
|
|
android.InitAndroidArchModule(m, android.DeviceSupported, android.MultilibCommon)
|
|
return m
|
|
}
|
|
|
|
func (s *SystemServerClasspathModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|
if len(s.properties.Contents) == 0 {
|
|
ctx.PropertyErrorf("contents", "empty contents are not allowed")
|
|
}
|
|
|
|
s.classpathFragmentBase().generateClasspathProtoBuildActions(ctx, configuredJarListToClasspathJars(ctx, s.ClasspathFragmentToConfiguredJarList(ctx)))
|
|
}
|
|
|
|
func (s *SystemServerClasspathModule) ClasspathFragmentToConfiguredJarList(ctx android.ModuleContext) android.ConfiguredJarList {
|
|
// TODO(satayev): populate with actual content
|
|
return android.EmptyConfiguredJarList()
|
|
}
|
|
|
|
type systemServerClasspathFragmentContentDependencyTag struct {
|
|
blueprint.BaseDependencyTag
|
|
}
|
|
|
|
// The tag used for the dependency between the systemserverclasspath_fragment module and its contents.
|
|
var systemServerClasspathFragmentContentDepTag = systemServerClasspathFragmentContentDependencyTag{}
|
|
|
|
func IsSystemServerClasspathFragmentContentDepTag(tag blueprint.DependencyTag) bool {
|
|
return tag == systemServerClasspathFragmentContentDepTag
|
|
}
|
|
|
|
func (s *SystemServerClasspathModule) ComponentDepsMutator(ctx android.BottomUpMutatorContext) {
|
|
module := ctx.Module()
|
|
|
|
for _, name := range s.properties.Contents {
|
|
ctx.AddDependency(module, systemServerClasspathFragmentContentDepTag, name)
|
|
}
|
|
}
|