diff --git a/cc/cc.go b/cc/cc.go index e209faa05..d400df088 100644 --- a/cc/cc.go +++ b/cc/cc.go @@ -401,8 +401,7 @@ func (c *ccBase) collectFlags(ctx common.AndroidModuleContext, toolchain Toolcha // TODO: debug flags.CFlags = append(flags.CFlags, c.properties.Release.Cflags...) - if ctx.Host() { - // TODO: allow per-module clang disable for host + if ctx.Host() && !ctx.ContainsProperty("clang") { flags.Clang = true } @@ -684,19 +683,15 @@ type ccLinked struct { func newCCDynamic(dynamic *ccLinked, module CCModuleType, hod common.HostOrDeviceSupported, multilib common.Multilib, props ...interface{}) (blueprint.Module, []interface{}) { - dynamic.properties.System_shared_libs = []string{defaultSystemSharedLibraries} - props = append(props, &dynamic.dynamicProperties) return newCCBase(&dynamic.ccBase, module, hod, multilib, props...) } -const defaultSystemSharedLibraries = "__default__" - func (c *ccLinked) systemSharedLibs(ctx common.AndroidBaseContext) []string { - if len(c.properties.System_shared_libs) == 1 && - c.properties.System_shared_libs[0] == defaultSystemSharedLibraries { - + if ctx.ContainsProperty("system_shared_libs") { + return c.properties.System_shared_libs + } else { if ctx.Host() { return []string{} } else if c.properties.Sdk_version != "" { @@ -714,7 +709,6 @@ func (c *ccLinked) systemSharedLibs(ctx common.AndroidBaseContext) []string { return []string{"libc", "libm"} } } - return c.properties.System_shared_libs } func (c *ccLinked) stl(ctx common.AndroidBaseContext) string { diff --git a/common/arch.go b/common/arch.go index 830a2ce7a..1758c0db7 100644 --- a/common/arch.go +++ b/common/arch.go @@ -355,7 +355,7 @@ func (a *AndroidModuleBase) setArchProperties(ctx blueprint.EarlyMutatorContext, // }, // }, t := arch.ArchType - extendProperties(ctx, "arch", t.Name, generalPropsValue, + a.extendProperties(ctx, "arch", t.Name, generalPropsValue, reflect.ValueOf(a.archProperties[i].Arch).FieldByName(t.Field).Elem().Elem()) // Handle multilib-specific properties in the form: @@ -364,7 +364,7 @@ func (a *AndroidModuleBase) setArchProperties(ctx blueprint.EarlyMutatorContext, // key: value, // }, // }, - extendProperties(ctx, "multilib", t.Multilib, generalPropsValue, + a.extendProperties(ctx, "multilib", t.Multilib, generalPropsValue, reflect.ValueOf(a.archProperties[i].Multilib).FieldByName(t.MultilibField).Elem().Elem()) // Handle host-or-device-specific properties in the form: @@ -374,7 +374,7 @@ func (a *AndroidModuleBase) setArchProperties(ctx blueprint.EarlyMutatorContext, // }, // }, hod := arch.HostOrDevice - extendProperties(ctx, "target", hod.FieldLower(), generalPropsValue, + a.extendProperties(ctx, "target", hod.FieldLower(), generalPropsValue, reflect.ValueOf(a.archProperties[i].Target).FieldByName(hod.Field()).Elem().Elem()) // Handle host target properties in the form: @@ -398,11 +398,11 @@ func (a *AndroidModuleBase) setArchProperties(ctx blueprint.EarlyMutatorContext, if hod.Host() { for _, v := range osList { if v.goos == runtime.GOOS { - extendProperties(ctx, "target", v.goos, generalPropsValue, + a.extendProperties(ctx, "target", v.goos, generalPropsValue, reflect.ValueOf(a.archProperties[i].Target).FieldByName(v.field).Elem().Elem()) } } - extendProperties(ctx, "target", "not_windows", generalPropsValue, + a.extendProperties(ctx, "target", "not_windows", generalPropsValue, reflect.ValueOf(a.archProperties[i].Target).FieldByName("Not_windows").Elem().Elem()) } @@ -421,10 +421,10 @@ func (a *AndroidModuleBase) setArchProperties(ctx blueprint.EarlyMutatorContext, // debuggerd that need to know when they are a 32-bit process running on a 64-bit device if hod.Device() { if true /* && target_is_64_bit */ { - extendProperties(ctx, "target", "android64", generalPropsValue, + a.extendProperties(ctx, "target", "android64", generalPropsValue, reflect.ValueOf(a.archProperties[i].Target).FieldByName("Android64").Elem().Elem()) } else { - extendProperties(ctx, "target", "android32", generalPropsValue, + a.extendProperties(ctx, "target", "android32", generalPropsValue, reflect.ValueOf(a.archProperties[i].Target).FieldByName("Android32").Elem().Elem()) } } @@ -450,12 +450,12 @@ func forEachInterface(v reflect.Value, f func(reflect.Value)) { } // TODO: move this to proptools -func extendProperties(ctx blueprint.EarlyMutatorContext, variationType, variationName string, +func (a *AndroidModuleBase) extendProperties(ctx blueprint.EarlyMutatorContext, variationType, variationName string, dstValue, srcValue reflect.Value) { - extendPropertiesRecursive(ctx, variationType, variationName, dstValue, srcValue, "") + a.extendPropertiesRecursive(ctx, variationType, variationName, dstValue, srcValue, "") } -func extendPropertiesRecursive(ctx blueprint.EarlyMutatorContext, variationType, variationName string, +func (a *AndroidModuleBase) extendPropertiesRecursive(ctx blueprint.EarlyMutatorContext, variationType, variationName string, dstValue, srcValue reflect.Value, recursePrefix string) { typ := dstValue.Type() @@ -497,6 +497,11 @@ func extendPropertiesRecursive(ctx blueprint.EarlyMutatorContext, variationType, continue } + if !ctx.ContainsProperty(propertyName) { + continue + } + a.extendedProperties[localPropertyName] = struct{}{} + switch srcFieldValue.Kind() { case reflect.Bool: // Replace the original value. @@ -508,7 +513,7 @@ func extendPropertiesRecursive(ctx blueprint.EarlyMutatorContext, variationType, case reflect.Struct: // Recursively extend the struct's fields. newRecursePrefix := fmt.Sprintf("%s%s.", recursePrefix, strings.ToLower(field.Name)) - extendPropertiesRecursive(ctx, variationType, variationName, + a.extendPropertiesRecursive(ctx, variationType, variationName, dstFieldValue, srcFieldValue, newRecursePrefix) case reflect.Slice: @@ -528,7 +533,7 @@ func extendPropertiesRecursive(ctx blueprint.EarlyMutatorContext, variationType, } if !dstFieldValue.IsNil() { newRecursePrefix := fmt.Sprintf("%s.%s", recursePrefix, field.Name) - extendPropertiesRecursive(ctx, variationType, variationName, + a.extendPropertiesRecursive(ctx, variationType, variationName, dstFieldValue.Elem(), srcFieldValue.Elem(), newRecursePrefix) } diff --git a/common/module.go b/common/module.go index d420fe1f9..73a9a61a8 100644 --- a/common/module.go +++ b/common/module.go @@ -113,6 +113,7 @@ func InitAndroidModule(m AndroidModule, base := m.base() base.module = m + base.extendedProperties = make(map[string]struct{}) propertyStructs = append(propertyStructs, &base.commonProperties) @@ -186,6 +187,7 @@ type AndroidModuleBase struct { hostAndDeviceProperties hostAndDeviceProperties generalProperties []interface{} archProperties []*archProperties + extendedProperties map[string]struct{} noAddressSanitizer bool installFiles []string @@ -313,8 +315,9 @@ func (a *AndroidModuleBase) GenerateBuildActions(ctx blueprint.ModuleContext) { androidBaseContextImpl: androidBaseContextImpl{ arch: a.commonProperties.CompileArch, }, - installDeps: a.computeInstallDeps(ctx), - installFiles: a.installFiles, + installDeps: a.computeInstallDeps(ctx), + installFiles: a.installFiles, + extendedProperties: a.extendedProperties, } if a.commonProperties.Disabled { @@ -343,9 +346,10 @@ type androidBaseContextImpl struct { type androidModuleContext struct { blueprint.ModuleContext androidBaseContextImpl - installDeps []string - installFiles []string - checkbuildFiles []string + installDeps []string + installFiles []string + checkbuildFiles []string + extendedProperties map[string]struct{} } func (a *androidModuleContext) Build(pctx *blueprint.PackageContext, params blueprint.BuildParams) { @@ -353,6 +357,14 @@ func (a *androidModuleContext) Build(pctx *blueprint.PackageContext, params blue a.ModuleContext.Build(pctx, params) } +func (a *androidModuleContext) ContainsProperty(property string) bool { + if a.ModuleContext.ContainsProperty(property) { + return true + } + _, ok := a.extendedProperties[property] + return ok +} + func (a *androidBaseContextImpl) Arch() Arch { return a.arch }