Add support for host sdk

Adds HostSupported() method to ModuleBase for use by sdk. Adds
host_supported/device_supported to all prebuilt modules and the
sdk snapshot (where necessary).

Adds TestHostSnapshot to verify the behavior is correct.

Bug: 143678475
Test: m nothing
Change-Id: I8b4d097e46d5804f62cb8f651a83069299a3e639
This commit is contained in:
Paul Duffin
2019-11-26 18:04:12 +00:00
parent b645ec8e34
commit e44358fa8f
3 changed files with 212 additions and 0 deletions

View File

@@ -250,6 +250,7 @@ func (s *sdk) buildSnapshot(ctx android.ModuleContext) android.OutputPath {
builder := &snapshotBuilder{
ctx: ctx,
sdk: s,
version: "current",
snapshotDir: snapshotDir.OutputPath,
filesToZip: []android.Path{bp.path},
@@ -293,6 +294,7 @@ func (s *sdk) buildSnapshot(ctx android.ModuleContext) android.OutputPath {
snapshotName := ctx.ModuleName() + string(android.SdkVersionSeparator) + builder.version
snapshotModule := bpFile.newModule("sdk_snapshot")
snapshotModule.AddProperty("name", snapshotName)
addHostDeviceSupportedProperties(&s.ModuleBase, snapshotModule)
if len(s.properties.Java_libs) > 0 {
snapshotModule.AddProperty("java_libs", builder.versionedSdkMemberNames(s.properties.Java_libs))
}
@@ -505,6 +507,7 @@ func (info *nativeLibInfo) generatePrebuiltLibrary(ctx android.ModuleContext, bu
type snapshotBuilder struct {
ctx android.ModuleContext
sdk *sdk
version string
snapshotDir android.OutputPath
bpFile *bpFile
@@ -551,12 +554,22 @@ func (s *snapshotBuilder) AddPrebuiltModule(name string, moduleType string) andr
m := s.bpFile.newModule(moduleType)
m.AddProperty("name", name)
addHostDeviceSupportedProperties(&s.sdk.ModuleBase, m)
s.prebuiltModules[name] = m
s.prebuiltOrder = append(s.prebuiltOrder, m)
return m
}
func addHostDeviceSupportedProperties(module *android.ModuleBase, bpModule *bpModule) {
if !module.DeviceSupported() {
bpModule.AddProperty("device_supported", false)
}
if module.HostSupported() {
bpModule.AddProperty("host_supported", true)
}
}
// Get a versioned name appropriate for the SDK snapshot version being taken.
func (s *snapshotBuilder) versionedSdkMemberName(unversionedName string) string {
return versionedSdkMemberName(s.ctx, unversionedName, s.version)