Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ff966b13 authored by Liz Kammer's avatar Liz Kammer
Browse files

Remove unused bp2build logic from arch.go

Test: go test soong tests
Change-Id: I8a99e3d22b835f6e0d0b16543c738315c6abc4ce
parent 7ec40ccb
Loading
Loading
Loading
Loading
+3 −57
Original line number Diff line number Diff line
@@ -393,54 +393,6 @@ func (target Target) Variations() []blueprint.Variation {
	}
}

func registerBp2buildArchPathDepsMutator(ctx RegisterMutatorsContext) {
	ctx.BottomUp("bp2build-arch-pathdeps", bp2buildArchPathDepsMutator).Parallel()
}

// add dependencies for architecture specific properties tagged with `android:"path"`
func bp2buildArchPathDepsMutator(ctx BottomUpMutatorContext) {
	var module Module
	module = ctx.Module()

	m := module.base()
	if !m.ArchSpecific() {
		return
	}

	// addPathDepsForProps does not descend into sub structs, so we need to descend into the
	// arch-specific properties ourselves
	var properties []interface{}
	for _, archProperties := range m.archProperties {
		for _, archProps := range archProperties {
			archPropValues := reflect.ValueOf(archProps).Elem()
			// there are three "arch" variations, descend into each
			for _, variant := range []string{"Arch", "Multilib", "Target"} {
				// The properties are an interface, get the value (a pointer) that it points to
				archProps := archPropValues.FieldByName(variant).Elem()
				if archProps.IsNil() {
					continue
				}
				// And then a pointer to a struct
				archProps = archProps.Elem()
				for i := 0; i < archProps.NumField(); i += 1 {
					f := archProps.Field(i)
					// If the value of the field is a struct (as opposed to a pointer to a struct) then step
					// into the BlueprintEmbed field.
					if f.Kind() == reflect.Struct {
						f = f.FieldByName("BlueprintEmbed")
					}
					if f.IsZero() {
						continue
					}
					props := f.Interface().(interface{})
					properties = append(properties, props)
				}
			}
		}
	}
	addPathDepsForProps(ctx, properties)
}

// osMutator splits an arch-specific module into a variant for each OS that is enabled for the
// module.  It uses the HostOrDevice value passed to InitAndroidArchModule and the
// device_supported and host_supported properties to determine which OsTypes are enabled for this
@@ -998,19 +950,13 @@ func filterArchStruct(field reflect.StructField, prefix string) (bool, reflect.S
		if string(field.Tag) != `android:"`+strings.Join(values, ",")+`"` {
			panic(fmt.Errorf("unexpected tag format %q", field.Tag))
		}
		// don't delete path tag as it is needed for bp2build
		// these tags don't need to be present in the runtime generated struct type.
		values = RemoveListFromList(values, []string{"arch_variant", "variant_prepend"})
		if len(values) > 0 && values[0] != "path" {
		values = RemoveListFromList(values, []string{"arch_variant", "variant_prepend", "path"})
		if len(values) > 0 {
			panic(fmt.Errorf("unknown tags %q in field %q", values, prefix+field.Name))
		} else if len(values) == 1 {
			// FIXME(b/200678898): This assumes that the only tag type when there's
			// `android:"arch_variant"` is `android` itself and thus clobbers others
			field.Tag = reflect.StructTag(`android:"` + strings.Join(values, ",") + `"`)
		} else {
			field.Tag = ``
		}

		field.Tag = ``
		return true, field
	}
	return false, field
+3 −3
Original line number Diff line number Diff line
@@ -66,9 +66,9 @@ func TestFilterArchStruct(t *testing.T) {
			}{},
			out: &struct {
				A *string
				B *string `android:"path"`
				C *string `android:"path"`
				D *string `android:"path"`
				B *string
				C *string
				D *string
			}{},
			filtered: true,
		},