Add systemserverclasspath_fragments property to apex.
- 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
This commit is contained in:
@@ -32,6 +32,7 @@ bootstrap_go_package {
|
||||
"apex_test.go",
|
||||
"bootclasspath_fragment_test.go",
|
||||
"platform_bootclasspath_test.go",
|
||||
"systemserver_classpath_fragment_test.go",
|
||||
"vndk_test.go",
|
||||
],
|
||||
pluginFor: ["soong_build"],
|
||||
|
25
apex/apex.go
25
apex/apex.go
@@ -102,6 +102,9 @@ type apexBundleProperties struct {
|
||||
// List of bootclasspath fragments that are embedded inside this APEX bundle.
|
||||
Bootclasspath_fragments []string
|
||||
|
||||
// List of systemserverclasspath fragments that are embedded inside this APEX bundle.
|
||||
Systemserverclasspath_fragments []string
|
||||
|
||||
// List of java libraries that are embedded inside this APEX bundle.
|
||||
Java_libs []string
|
||||
|
||||
@@ -575,6 +578,7 @@ var (
|
||||
executableTag = dependencyTag{name: "executable", payload: true}
|
||||
fsTag = dependencyTag{name: "filesystem", payload: true}
|
||||
bcpfTag = dependencyTag{name: "bootclasspathFragment", payload: true, sourceOnly: true}
|
||||
sscpfTag = dependencyTag{name: "systemserverclasspathFragment", payload: true, sourceOnly: true}
|
||||
compatConfigTag = dependencyTag{name: "compatConfig", payload: true, sourceOnly: true}
|
||||
javaLibTag = dependencyTag{name: "javaLib", payload: true}
|
||||
jniLibTag = dependencyTag{name: "jniLib", payload: true}
|
||||
@@ -755,6 +759,7 @@ func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) {
|
||||
// Common-arch dependencies come next
|
||||
commonVariation := ctx.Config().AndroidCommonTarget.Variations()
|
||||
ctx.AddFarVariationDependencies(commonVariation, bcpfTag, a.properties.Bootclasspath_fragments...)
|
||||
ctx.AddFarVariationDependencies(commonVariation, sscpfTag, a.properties.Systemserverclasspath_fragments...)
|
||||
ctx.AddFarVariationDependencies(commonVariation, javaLibTag, a.properties.Java_libs...)
|
||||
ctx.AddFarVariationDependencies(commonVariation, bpfTag, a.properties.Bpfs...)
|
||||
ctx.AddFarVariationDependencies(commonVariation, fsTag, a.properties.Filesystems...)
|
||||
@@ -1715,6 +1720,15 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
filesInfo = append(filesInfo, filesToAdd...)
|
||||
return true
|
||||
}
|
||||
case sscpfTag:
|
||||
{
|
||||
if _, ok := child.(*java.SystemServerClasspathModule); !ok {
|
||||
ctx.PropertyErrorf("systemserverclasspath_fragments", "%q is not a systemserverclasspath_fragment module", depName)
|
||||
return false
|
||||
}
|
||||
filesInfo = append(filesInfo, apexClasspathFragmentProtoFile(ctx, child))
|
||||
return true
|
||||
}
|
||||
case javaLibTag:
|
||||
switch child.(type) {
|
||||
case *java.Library, *java.SdkLibrary, *java.DexImport, *java.SdkLibraryImport, *java.Import:
|
||||
@@ -1941,7 +1955,16 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
default:
|
||||
ctx.PropertyErrorf("bootclasspath_fragments", "bootclasspath_fragment content %q of type %q is not supported", depName, ctx.OtherModuleType(child))
|
||||
}
|
||||
|
||||
} else if java.IsSystemServerClasspathFragmentContentDepTag(depTag) {
|
||||
// Add the contents of the systemserverclasspath fragment to the apex.
|
||||
switch child.(type) {
|
||||
case *java.Library, *java.SdkLibrary:
|
||||
af := apexFileForJavaModule(ctx, child.(javaModule))
|
||||
filesInfo = append(filesInfo, af)
|
||||
return true // track transitive dependencies
|
||||
default:
|
||||
ctx.PropertyErrorf("systemserverclasspath_fragments", "systemserverclasspath_fragment content %q of type %q is not supported", depName, ctx.OtherModuleType(child))
|
||||
}
|
||||
} else if _, ok := depTag.(android.CopyDirectlyInAnyApexTag); ok {
|
||||
// nothing
|
||||
} else if am.CanHaveApexVariants() && am.IsInstallableToApex() {
|
||||
|
78
apex/systemserver_classpath_fragment_test.go
Normal file
78
apex/systemserver_classpath_fragment_test.go
Normal file
@@ -0,0 +1,78 @@
|
||||
// Copyright (C) 2021 The Android Open Source Project
|
||||
//
|
||||
// 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 apex
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"android/soong/android"
|
||||
"android/soong/java"
|
||||
)
|
||||
|
||||
var prepareForTestWithSystemserverclasspathFragment = android.GroupFixturePreparers(
|
||||
java.PrepareForTestWithDexpreopt,
|
||||
PrepareForTestWithApexBuildComponents,
|
||||
)
|
||||
|
||||
func TestSystemserverclasspathFragmentContents(t *testing.T) {
|
||||
result := android.GroupFixturePreparers(
|
||||
prepareForTestWithSystemserverclasspathFragment,
|
||||
prepareForTestWithMyapex,
|
||||
).RunTestWithBp(t, `
|
||||
apex {
|
||||
name: "myapex",
|
||||
key: "myapex.key",
|
||||
systemserverclasspath_fragments: [
|
||||
"mysystemserverclasspathfragment",
|
||||
],
|
||||
updatable: false,
|
||||
}
|
||||
|
||||
apex_key {
|
||||
name: "myapex.key",
|
||||
public_key: "testkey.avbpubkey",
|
||||
private_key: "testkey.pem",
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "foo",
|
||||
srcs: ["b.java"],
|
||||
installable: true,
|
||||
apex_available: [
|
||||
"myapex",
|
||||
],
|
||||
}
|
||||
|
||||
systemserverclasspath_fragment {
|
||||
name: "mysystemserverclasspathfragment",
|
||||
contents: [
|
||||
"foo",
|
||||
],
|
||||
apex_available: [
|
||||
"myapex",
|
||||
],
|
||||
}
|
||||
`)
|
||||
|
||||
ensureExactContents(t, result.TestContext, "myapex", "android_common_myapex_image", []string{
|
||||
"etc/classpaths/mysystemserverclasspathfragment.pb",
|
||||
"javalib/foo.jar",
|
||||
})
|
||||
|
||||
java.CheckModuleDependencies(t, result.TestContext, "myapex", "android_common_myapex_image", []string{
|
||||
`myapex.key`,
|
||||
`mysystemserverclasspathfragment`,
|
||||
})
|
||||
}
|
@@ -67,14 +67,19 @@ func (p *platformSystemServerClasspathModule) ClasspathFragmentToConfiguredJarLi
|
||||
}).(android.ConfiguredJarList)
|
||||
}
|
||||
|
||||
type systemServerClasspathModule struct {
|
||||
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.
|
||||
//
|
||||
@@ -83,14 +88,15 @@ type systemServerClasspathFragmentProperties struct {
|
||||
}
|
||||
|
||||
func systemServerClasspathFactory() android.Module {
|
||||
m := &systemServerClasspathModule{}
|
||||
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) {
|
||||
func (s *SystemServerClasspathModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
if len(s.properties.Contents) == 0 {
|
||||
ctx.PropertyErrorf("contents", "empty contents are not allowed")
|
||||
}
|
||||
@@ -98,7 +104,7 @@ func (s *systemServerClasspathModule) GenerateAndroidBuildActions(ctx android.Mo
|
||||
s.classpathFragmentBase().generateClasspathProtoBuildActions(ctx, configuredJarListToClasspathJars(ctx, s.ClasspathFragmentToConfiguredJarList(ctx)))
|
||||
}
|
||||
|
||||
func (s *systemServerClasspathModule) ClasspathFragmentToConfiguredJarList(ctx android.ModuleContext) android.ConfiguredJarList {
|
||||
func (s *SystemServerClasspathModule) ClasspathFragmentToConfiguredJarList(ctx android.ModuleContext) android.ConfiguredJarList {
|
||||
// TODO(satayev): populate with actual content
|
||||
return android.EmptyConfiguredJarList()
|
||||
}
|
||||
@@ -114,7 +120,7 @@ func IsSystemServerClasspathFragmentContentDepTag(tag blueprint.DependencyTag) b
|
||||
return tag == systemServerClasspathFragmentContentDepTag
|
||||
}
|
||||
|
||||
func (s *systemServerClasspathModule) ComponentDepsMutator(ctx android.BottomUpMutatorContext) {
|
||||
func (s *SystemServerClasspathModule) ComponentDepsMutator(ctx android.BottomUpMutatorContext) {
|
||||
module := ctx.Module()
|
||||
|
||||
for _, name := range s.properties.Contents {
|
||||
|
Reference in New Issue
Block a user