Merge "Add apexes property to sdk"

This commit is contained in:
Paul Duffin
2022-07-07 10:40:00 +00:00
committed by Gerrit Code Review
9 changed files with 404 additions and 71 deletions

View File

@@ -23,6 +23,7 @@ bootstrap_go_package {
srcs: [
"androidmk.go",
"apex.go",
"apex_sdk_member.go",
"apex_singleton.go",
"builder.go",
"constants.go",

View File

@@ -606,6 +606,18 @@ type dependencyTag struct {
// replacement. This is needed because some prebuilt modules do not provide all the information
// needed by the apex.
sourceOnly bool
// If not-nil and an APEX is a member of an SDK then dependencies of that APEX with this tag will
// also be added as exported members of that SDK.
memberType android.SdkMemberType
}
func (d *dependencyTag) SdkMemberType(_ android.Module) android.SdkMemberType {
return d.memberType
}
func (d *dependencyTag) ExportMember() bool {
return true
}
func (d *dependencyTag) String() string {
@@ -617,6 +629,7 @@ func (d *dependencyTag) ReplaceSourceWithPrebuilt() bool {
}
var _ android.ReplaceSourceWithPrebuilt = &dependencyTag{}
var _ android.SdkMemberDependencyTag = &dependencyTag{}
var (
androidAppTag = &dependencyTag{name: "androidApp", payload: true}
@@ -624,8 +637,8 @@ var (
certificateTag = &dependencyTag{name: "certificate"}
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}
bcpfTag = &dependencyTag{name: "bootclasspathFragment", payload: true, sourceOnly: true, memberType: java.BootclasspathFragmentSdkMemberType}
sscpfTag = &dependencyTag{name: "systemserverclasspathFragment", payload: true, sourceOnly: true, memberType: java.SystemServerClasspathFragmentSdkMemberType}
compatConfigTag = &dependencyTag{name: "compatConfig", payload: true, sourceOnly: true}
javaLibTag = &dependencyTag{name: "javaLib", payload: true}
jniLibTag = &dependencyTag{name: "jniLib", payload: true}

58
apex/apex_sdk_member.go Normal file
View File

@@ -0,0 +1,58 @@
// Copyright (C) 2022 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 (
"android/soong/android"
"github.com/google/blueprint"
"github.com/google/blueprint/proptools"
)
// This file contains support for using apex modules within an sdk.
func init() {
// Register sdk member types.
android.RegisterSdkMemberType(&apexSdkMemberType{
SdkMemberTypeBase: android.SdkMemberTypeBase{
PropertyName: "apexes",
SupportsSdk: true,
// The apexes property does not need to be included in the snapshot as adding an apex to an
// sdk does not produce any prebuilts of the apex.
PrebuiltsRequired: proptools.BoolPtr(false),
},
})
}
type apexSdkMemberType struct {
android.SdkMemberTypeBase
}
func (mt *apexSdkMemberType) AddDependencies(ctx android.SdkDependencyContext, dependencyTag blueprint.DependencyTag, names []string) {
ctx.AddVariationDependencies(nil, dependencyTag, names...)
}
func (mt *apexSdkMemberType) IsInstance(module android.Module) bool {
_, ok := module.(*apexBundle)
return ok
}
func (mt *apexSdkMemberType) AddPrebuiltModule(ctx android.SdkMemberContext, member android.SdkMember) android.BpModule {
panic("Sdk does not create prebuilts of the apexes in its snapshot")
}
func (mt *apexSdkMemberType) CreateVariantPropertiesStruct() android.SdkMemberProperties {
panic("Sdk does not create prebuilts of the apexes in its snapshot")
}