Disable all host OS variants except those explicitly included.

Necessary to avoid problems with implicitly enabled host OS'es, e.g.
linux_glibc getting enabled when we only supply a linux_bionic linker
in runtime-module-host-exports. That will then cause a non-functional
prebuilt to take precedence over source if the prebuilt is preferred.

We don't do this for device since we so far only support a single
device OS (android).

This introduces the notion that SDK member types can be host OS
dependent or not. That way java members with host prebuilts don't get
restricted to a specific host OS.

Test: m nothing
Test: build/soong/scripts/build-aml-prebuilts.sh runtime-module-host-exports
  Check that the generated Android.bp correctly disables the bionic
  linker prebuilt for linux_glibc.
Test: art/build/apex/runtests.sh
  on master-art with an updated runtime SDK snapshot
Test: art/tools/buildbot-build.sh {--host,--target}
  on master-art with an updated runtime SDK snapshot
Bug: 160349757
Change-Id: Idad7ef138cdbcbd209d390bf6c10ca8365d4619f
This commit is contained in:
Martin Stjernholm
2020-07-11 04:52:24 +01:00
parent 0d333752cf
commit caa47d7eed
6 changed files with 503 additions and 37 deletions

View File

@@ -262,7 +262,7 @@ func (s *sdk) buildSnapshot(ctx android.ModuleContext, sdkVariants []*sdk) andro
memberCtx := &memberContext{ctx, builder, memberType, member.name}
prebuiltModule := memberType.AddPrebuiltModule(memberCtx, member)
s.createMemberSnapshot(memberCtx, member, prebuiltModule)
s.createMemberSnapshot(memberCtx, member, prebuiltModule.(*bpModule))
}
// Create a transformer that will transform an unversioned module into a versioned module.
@@ -345,12 +345,37 @@ func (s *sdk) buildSnapshot(ctx android.ModuleContext, sdkVariants []*sdk) andro
snapshotModule.AddProperty("compile_multilib", commonVariantProperties.Compile_multilib)
}
// Iterate over the os types in a fixed order.
targetPropertySet := snapshotModule.AddPropertySet("target")
// If host is supported and any member is host OS dependent then disable host
// by default, so that we can enable each host OS variant explicitly. This
// avoids problems with implicitly enabled OS variants when the snapshot is
// used, which might be different from this run (e.g. different build OS).
hasHostOsDependentMember := false
if s.HostSupported() {
for _, memberRef := range memberRefs {
if memberRef.memberType.IsHostOsDependent() {
hasHostOsDependentMember = true
break
}
}
if hasHostOsDependentMember {
hostPropertySet := targetPropertySet.AddPropertySet("host")
hostPropertySet.AddProperty("enabled", false)
}
}
// Iterate over the os types in a fixed order.
for _, osType := range s.getPossibleOsTypes() {
if sdkVariant, ok := osTypeToMemberProperties[osType]; ok {
osPropertySet := targetPropertySet.AddPropertySet(sdkVariant.Target().Os.Name)
// Enable the variant explicitly when we've disabled it by default on host.
if hasHostOsDependentMember &&
(osType.Class == android.Host || osType.Class == android.HostCross) {
osPropertySet.AddProperty("enabled", true)
}
variantProps := variantToProperties[sdkVariant]
if variantProps.Compile_multilib != "" && variantProps.Compile_multilib != "both" {
osPropertySet.AddProperty("compile_multilib", variantProps.Compile_multilib)
@@ -993,9 +1018,12 @@ func (osInfo *osTypeSpecificInfo) addToPropertySet(ctx *memberContext, bpModule
var osPropertySet android.BpPropertySet
var archPropertySet android.BpPropertySet
var archOsPrefix string
if osInfo.Properties.Base().Os_count == 1 {
// There is only one os type present in the variants so don't bother
// with adding target specific properties.
if osInfo.Properties.Base().Os_count == 1 &&
(osInfo.osType.Class == android.Device || !ctx.memberType.IsHostOsDependent()) {
// There is only one OS type present in the variants and it shouldn't have a
// variant-specific target. The latter is the case if it's either for device
// where there is only one OS (android), or for host and the member type
// isn't host OS dependent.
// Create a structure that looks like:
// module_type {
@@ -1032,6 +1060,12 @@ func (osInfo *osTypeSpecificInfo) addToPropertySet(ctx *memberContext, bpModule
osPropertySet = targetPropertySet.AddPropertySet(osType.Name)
archPropertySet = targetPropertySet
// Enable the variant explicitly when we've disabled it by default on host.
if ctx.memberType.IsHostOsDependent() &&
(osType.Class == android.Host || osType.Class == android.HostCross) {
osPropertySet.AddProperty("enabled", true)
}
// Arch specific properties need to be added to an os and arch specific
// section prefixed with <os>_.
archOsPrefix = osType.Name + "_"
@@ -1202,7 +1236,7 @@ func (m *memberContext) Name() string {
return m.name
}
func (s *sdk) createMemberSnapshot(ctx *memberContext, member *sdkMember, bpModule android.BpModule) {
func (s *sdk) createMemberSnapshot(ctx *memberContext, member *sdkMember, bpModule *bpModule) {
memberType := member.memberType
@@ -1256,6 +1290,18 @@ func (s *sdk) createMemberSnapshot(ctx *memberContext, member *sdkMember, bpModu
// added.
targetPropertySet := bpModule.AddPropertySet("target")
// If the member is host OS dependent and has host_supported then disable by
// default and enable each host OS variant explicitly. This avoids problems
// with implicitly enabled OS variants when the snapshot is used, which might
// be different from this run (e.g. different build OS).
if ctx.memberType.IsHostOsDependent() {
hostSupported := bpModule.getValue("host_supported") == true // Missing means false.
if hostSupported {
hostPropertySet := targetPropertySet.AddPropertySet("host")
hostPropertySet.AddProperty("enabled", false)
}
}
// Iterate over the os types in a fixed order.
for _, osType := range s.getPossibleOsTypes() {
osInfo := osTypeToInfo[osType]