2021-04-29 12:50:26 +02:00
|
|
|
// 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"
|
2021-05-07 00:38:10 +02:00
|
|
|
"android/soong/dexpreopt"
|
2021-05-26 03:16:02 +02:00
|
|
|
|
2021-05-17 22:13:44 +02:00
|
|
|
"github.com/google/blueprint"
|
2021-04-29 12:50:26 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
registerSystemserverClasspathBuildComponents(android.InitRegistrationContext)
|
|
|
|
}
|
|
|
|
|
|
|
|
func registerSystemserverClasspathBuildComponents(ctx android.RegistrationContext) {
|
|
|
|
ctx.RegisterModuleType("platform_systemserverclasspath", platformSystemServerClasspathFactory)
|
2021-05-13 20:01:52 +02:00
|
|
|
ctx.RegisterModuleType("systemserverclasspath_fragment", systemServerClasspathFactory)
|
2021-04-29 12:50:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
type platformSystemServerClasspathModule struct {
|
|
|
|
android.ModuleBase
|
|
|
|
|
|
|
|
ClasspathFragmentBase
|
|
|
|
}
|
|
|
|
|
|
|
|
func platformSystemServerClasspathFactory() android.Module {
|
|
|
|
m := &platformSystemServerClasspathModule{}
|
|
|
|
initClasspathFragment(m, SYSTEMSERVERCLASSPATH)
|
|
|
|
android.InitAndroidArchModule(m, android.DeviceSupported, android.MultilibCommon)
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-05-13 20:01:52 +02:00
|
|
|
func (p *platformSystemServerClasspathModule) AndroidMkEntries() (entries []android.AndroidMkEntries) {
|
|
|
|
return p.classpathFragmentBase().androidMkEntries()
|
2021-04-29 12:50:26 +02:00
|
|
|
}
|
|
|
|
|
2021-05-13 20:01:52 +02:00
|
|
|
func (p *platformSystemServerClasspathModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
2021-06-15 18:49:10 +02:00
|
|
|
configuredJars := p.configuredJars(ctx)
|
|
|
|
classpathJars := configuredJarListToClasspathJars(ctx, configuredJars, p.classpathType)
|
|
|
|
p.classpathFragmentBase().generateClasspathProtoBuildActions(ctx, configuredJars, classpathJars)
|
2021-05-07 00:38:10 +02:00
|
|
|
}
|
|
|
|
|
2021-06-15 17:21:17 +02:00
|
|
|
func (p *platformSystemServerClasspathModule) configuredJars(ctx android.ModuleContext) android.ConfiguredJarList {
|
2021-06-15 18:49:10 +02:00
|
|
|
// TODO(satayev): include any apex jars that don't populate their classpath proto config.
|
|
|
|
return dexpreopt.GetGlobalConfig(ctx).SystemServerJars
|
2021-04-29 12:50:26 +02:00
|
|
|
}
|
2021-05-13 20:01:52 +02:00
|
|
|
|
2021-05-17 22:35:26 +02:00
|
|
|
type SystemServerClasspathModule struct {
|
2021-05-13 20:01:52 +02:00
|
|
|
android.ModuleBase
|
2021-05-17 22:35:26 +02:00
|
|
|
android.ApexModuleBase
|
2021-05-13 20:01:52 +02:00
|
|
|
|
|
|
|
ClasspathFragmentBase
|
2021-05-17 22:13:44 +02:00
|
|
|
|
|
|
|
properties systemServerClasspathFragmentProperties
|
2021-06-07 16:49:13 +02:00
|
|
|
|
|
|
|
// Collect the module directory for IDE info in java/jdeps.go.
|
|
|
|
modulePaths []string
|
2021-05-17 22:13:44 +02:00
|
|
|
}
|
|
|
|
|
2021-05-17 22:35:26 +02:00
|
|
|
func (s *SystemServerClasspathModule) ShouldSupportSdkVersion(ctx android.BaseModuleContext, sdkVersion android.ApiLevel) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-05-17 22:13:44 +02:00
|
|
|
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
|
2021-05-13 20:01:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func systemServerClasspathFactory() android.Module {
|
2021-05-17 22:35:26 +02:00
|
|
|
m := &SystemServerClasspathModule{}
|
2021-05-17 22:13:44 +02:00
|
|
|
m.AddProperties(&m.properties)
|
2021-05-17 22:35:26 +02:00
|
|
|
android.InitApexModule(m)
|
2021-05-13 20:01:52 +02:00
|
|
|
initClasspathFragment(m, SYSTEMSERVERCLASSPATH)
|
|
|
|
android.InitAndroidArchModule(m, android.DeviceSupported, android.MultilibCommon)
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-05-17 22:35:26 +02:00
|
|
|
func (s *SystemServerClasspathModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
2021-05-17 22:13:44 +02:00
|
|
|
if len(s.properties.Contents) == 0 {
|
|
|
|
ctx.PropertyErrorf("contents", "empty contents are not allowed")
|
|
|
|
}
|
|
|
|
|
2021-06-15 18:49:10 +02:00
|
|
|
configuredJars := s.configuredJars(ctx)
|
|
|
|
classpathJars := configuredJarListToClasspathJars(ctx, configuredJars, s.classpathType)
|
|
|
|
s.classpathFragmentBase().generateClasspathProtoBuildActions(ctx, configuredJars, classpathJars)
|
2021-06-07 16:49:13 +02:00
|
|
|
|
|
|
|
// Collect the module directory for IDE info in java/jdeps.go.
|
|
|
|
s.modulePaths = append(s.modulePaths, ctx.ModuleDir())
|
2021-05-13 20:01:52 +02:00
|
|
|
}
|
|
|
|
|
2021-06-15 17:21:17 +02:00
|
|
|
func (s *SystemServerClasspathModule) configuredJars(ctx android.ModuleContext) android.ConfiguredJarList {
|
2021-05-20 22:33:41 +02:00
|
|
|
global := dexpreopt.GetGlobalConfig(ctx)
|
|
|
|
|
2021-07-21 15:23:52 +02:00
|
|
|
possibleUpdatableModules := gatherPossibleApexModuleNamesAndStems(ctx, s.properties.Contents, systemServerClasspathFragmentContentDepTag)
|
2021-08-06 14:20:28 +02:00
|
|
|
jars, unknown := global.ApexSystemServerJars.Filter(possibleUpdatableModules)
|
|
|
|
// TODO(satayev): remove geotz ssc_fragment, since geotz is not part of SSCP anymore.
|
|
|
|
_, unknown = android.RemoveFromList("geotz", unknown)
|
|
|
|
|
|
|
|
// For non test apexes, make sure that all contents are actually declared in make.
|
|
|
|
if global.ApexSystemServerJars.Len() > 0 && len(unknown) > 0 {
|
|
|
|
ctx.ModuleErrorf("%s in contents must also be declared in PRODUCT_UPDATABLE_SYSTEM_SERVER_JARS", unknown)
|
|
|
|
}
|
|
|
|
|
|
|
|
return jars
|
2021-05-13 20:01:52 +02:00
|
|
|
}
|
2021-05-17 22:13:44 +02:00
|
|
|
|
|
|
|
type systemServerClasspathFragmentContentDependencyTag struct {
|
|
|
|
blueprint.BaseDependencyTag
|
|
|
|
}
|
|
|
|
|
2021-05-26 03:16:02 +02:00
|
|
|
// Contents of system server fragments in an apex are considered to be directly in the apex, as if
|
|
|
|
// they were listed in java_libs.
|
|
|
|
func (systemServerClasspathFragmentContentDependencyTag) CopyDirectlyInAnyApex() {}
|
|
|
|
|
|
|
|
var _ android.CopyDirectlyInAnyApexTag = systemServerClasspathFragmentContentDepTag
|
|
|
|
|
2021-05-17 22:13:44 +02:00
|
|
|
// 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
|
|
|
|
}
|
|
|
|
|
2021-05-17 22:35:26 +02:00
|
|
|
func (s *SystemServerClasspathModule) ComponentDepsMutator(ctx android.BottomUpMutatorContext) {
|
2021-05-17 22:13:44 +02:00
|
|
|
module := ctx.Module()
|
|
|
|
|
|
|
|
for _, name := range s.properties.Contents {
|
|
|
|
ctx.AddDependency(module, systemServerClasspathFragmentContentDepTag, name)
|
|
|
|
}
|
|
|
|
}
|
2021-06-07 16:49:13 +02:00
|
|
|
|
|
|
|
// Collect information for opening IDE project files in java/jdeps.go.
|
|
|
|
func (s *SystemServerClasspathModule) IDEInfo(dpInfo *android.IdeInfo) {
|
|
|
|
dpInfo.Deps = append(dpInfo.Deps, s.properties.Contents...)
|
|
|
|
dpInfo.Paths = append(dpInfo.Paths, s.modulePaths...)
|
|
|
|
}
|